Comment 166 for bug 524281

Revision history for this message
Gurmeet (gurmeet1109) wrote :

For the learned .....
Adding as a point to start with .. no guarantees that this is the Saviour .... just a lead to who can get the heads and tails out of it

# diff -cp tick-sched.c(2.6.37-rc4) tick-sched.c(2.6.25-23)

...

*** tick.sched-2.6.37-rc4.c 2010-12-06 17:50:03.960025002 +0530
--- tick-sched-2.6.35-23.c 2010-11-18 03:45:19.000000000 +0530
*************** void tick_nohz_stop_sched_tick(int inidl
*** 405,411 ****
     * the scheduler tick in nohz_restart_sched_tick.
     */
    if (!ts->tick_stopped) {
! select_nohz_load_balancer(1);

     ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
     ts->tick_stopped = 1;
--- 405,417 ----
     * the scheduler tick in nohz_restart_sched_tick.
     */
    if (!ts->tick_stopped) {
! if (select_nohz_load_balancer(1)) {
! /*
! * sched tick not stopped!
! */
! cpumask_clear_cpu(cpu, nohz_cpu_mask);
! goto out;
! }

     ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
     ts->tick_stopped = 1;
*************** void tick_setup_sched_timer(void)
*** 774,779 ****
--- 780,786 ----
  {
   struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
   ktime_t now = ktime_get();
+ u64 offset;

   /*
    * Emulate tick processing via per-CPU hrtimers:
*************** void tick_setup_sched_timer(void)
*** 783,788 ****
--- 790,799 ----

   /* Get the next period (per cpu) */
   hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());
+ offset = ktime_to_ns(tick_period) >> 1;
+ do_div(offset, num_possible_cpus());
+ offset *= smp_processor_id();
+ hrtimer_add_expires_ns(&ts->sched_timer, offset);

   for (;;) {
    hrtimer_forward(&ts->sched_timer, now, tick_period);