ChangeSet 1.2246, 2005/03/31 08:32:31-08:00, [EMAIL PROTECTED]

        [PATCH] x86: reduce cacheline bouncing in cpu_idle_wait
        
        Andi noted that during normal runtime cpu_idle_map is bounced around a 
lot,
        and occassionally at a higher frequency than the timer interrupt wakeup
        which we normally exit pm_idle from.  So switch to a percpu variable.
        
        I didn't move things to the slow path because it would involve adding
        scheduler code to wakeup the idle thread on the cpus we're waiting for.
        
        Signed-off-by: Zwane Mwaikambo <[EMAIL PROTECTED]>
        Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
        Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>



 process.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)


diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
--- a/arch/i386/kernel/process.c        2005-03-31 10:14:10 -08:00
+++ b/arch/i386/kernel/process.c        2005-03-31 10:14:10 -08:00
@@ -73,7 +73,7 @@
  * Powermanagement idle function, if any..
  */
 void (*pm_idle)(void);
-static cpumask_t cpu_idle_map;
+static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
 
 void disable_hlt(void)
 {
@@ -146,15 +146,14 @@
  */
 void cpu_idle (void)
 {
-       int cpu = _smp_processor_id();
-
        /* endless idle loop with no priority at all */
        while (1) {
                while (!need_resched()) {
                        void (*idle)(void);
 
-                       if (cpu_isset(cpu, cpu_idle_map))
-                               cpu_clear(cpu, cpu_idle_map);
+                       if (__get_cpu_var(cpu_idle_state))
+                               __get_cpu_var(cpu_idle_state) = 0;
+
                        rmb();
                        idle = pm_idle;
 
@@ -170,16 +169,28 @@
 
 void cpu_idle_wait(void)
 {
-       int cpu;
+       unsigned int cpu, this_cpu = get_cpu();
        cpumask_t map;
 
-       for_each_online_cpu(cpu)
-               cpu_set(cpu, cpu_idle_map);
+       set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
+       put_cpu();
+
+       cpus_clear(map);
+       for_each_online_cpu(cpu) {
+               per_cpu(cpu_idle_state, cpu) = 1;
+               cpu_set(cpu, map);
+       }
+
+       __get_cpu_var(cpu_idle_state) = 0;
 
        wmb();
        do {
                ssleep(1);
-               cpus_and(map, cpu_idle_map, cpu_online_map);
+               for_each_online_cpu(cpu) {
+                       if (cpu_isset(cpu, map) && !per_cpu(cpu_idle_state, 
cpu))
+                               cpu_clear(cpu, map);
+               }
+               cpus_and(map, map, cpu_online_map);
        } while (!cpus_empty(map));
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to