ia64/xen-unstable

changeset 18434:bed1b98b63cc

CPUIDLE: Write to ARB_DISABLE conditionally to reduce some idle overheads.

By protecting entry/exit with a spinlock we can safely determine
precisely when it is required that we assert/deassert ARB_DISABLE.

Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Sep 04 11:19:17 2008 +0100 (2008-09-04)
parents c9db93b0660a
children 5b133625223a
files xen/arch/x86/acpi/cpu_idle.c
line diff
     1.1 --- a/xen/arch/x86/acpi/cpu_idle.c	Wed Sep 03 14:56:08 2008 +0100
     1.2 +++ b/xen/arch/x86/acpi/cpu_idle.c	Thu Sep 04 11:19:17 2008 +0100
     1.3 @@ -263,7 +263,10 @@ static void acpi_idle_do_entry(struct ac
     1.4      }
     1.5  }
     1.6  
     1.7 -static atomic_t c3_cpu_count;
     1.8 +static struct {
     1.9 +    spinlock_t lock;
    1.10 +    unsigned int count;
    1.11 +} c3_cpu_status = { .lock = SPIN_LOCK_UNLOCKED };
    1.12  
    1.13  static void acpi_processor_idle(void)
    1.14  {
    1.15 @@ -416,8 +419,8 @@ static void acpi_processor_idle(void)
    1.16           */
    1.17          if ( power->flags.bm_check && power->flags.bm_control )
    1.18          {
    1.19 -            atomic_inc(&c3_cpu_count);
    1.20 -            if ( atomic_read(&c3_cpu_count) == num_online_cpus() )
    1.21 +            spin_lock(&c3_cpu_status.lock);
    1.22 +            if ( ++c3_cpu_status.count == num_online_cpus() )
    1.23              {
    1.24                  /*
    1.25                   * All CPUs are trying to go to C3
    1.26 @@ -425,6 +428,7 @@ static void acpi_processor_idle(void)
    1.27                   */
    1.28                  acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
    1.29              }
    1.30 +            spin_unlock(&c3_cpu_status.lock);
    1.31          }
    1.32          else if ( !power->flags.bm_check )
    1.33          {
    1.34 @@ -455,8 +459,10 @@ static void acpi_processor_idle(void)
    1.35          if ( power->flags.bm_check && power->flags.bm_control )
    1.36          {
    1.37              /* Enable bus master arbitration */
    1.38 -            atomic_dec(&c3_cpu_count);
    1.39 -            acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
    1.40 +            spin_lock(&c3_cpu_status.lock);
    1.41 +            if ( c3_cpu_status.count-- == num_online_cpus() )
    1.42 +                acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
    1.43 +            spin_unlock(&c3_cpu_status.lock);
    1.44          }
    1.45  
    1.46          /* Re-enable interrupts */