Skip to contentSkip to conversation

linsched: avoid invoke tick_nohz_idle_enter() multiple times in idle

RFC PATCH New Michael Wang 1 participant 1 message Sep 3, 2012

lore
Share & tools
lore
#0 lore raw

RFC PATCH 3/4 linsched: avoid invoke tick_nohz_idle_enter() multiple times in idle

From: Michael Wang <[email protected]>

In real world, tick_nohz_idle_enter() will be invoked by idle thread when the cpu change from active to idle, and will only be invoked again after tick_nohz_idle_exit() was invoked by idle thread when cpu is going to recover, invoke it multiple times in one idle may cause unexpected troubles.

The patch add a check to avoid invoke tick_nohz_idle_enter() again after idle.

---
 tools/linsched/hrtimer.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
tools/linsched/hrtimer.c +10 -1
index de88b25..3203253 100644
@@ -149,6 +149,15 @@ void linsched_check_idle_cpu(void)
        } 
 }
 
+void linsched_enter_idle(void)
+{
+       int cpu = smp_processor_id();
+       struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
+
+       if (!ts->inidle && idle_cpu(cpu))
+               tick_nohz_idle_enter();
+}              
+
 /* Run a simulation for some number of ticks. Each tick,
  * scheduling and load balancing decisions are made. Obviously, we
  * could create tasks, change priorities, etc., at certain ticks
@@ -210,7 +219,7 @@ void linsched_run_sim(int sim_ticks)
 
                        BUG_ON(irqs_disabled());
                        if (idle_cpu(active_cpu) && !need_resched()) {
-                               tick_nohz_idle_enter();
+                               linsched_enter_idle();
                        } else {
                                linsched_current_handler();
                        }
Signature · 1 line
1.7.1