ia64/xen-unstable

changeset 19601:b7f4937d76d1

cpuidle: Fix possible false judge caused by type casting

For timer_deadline == 0 or timer_deadline - now > largest u32
case, the expected_us (in u32 type) may become wrong.

Add a tunable option to ease conditional adjustment.

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 14 15:46:43 2009 +0100 (2009-05-14)
parents 3bac2fcfbafc
children 40d4267296ad
files xen/arch/x86/acpi/cpu_idle.c xen/arch/x86/acpi/cpuidle_menu.c
line diff
     1.1 --- a/xen/arch/x86/acpi/cpu_idle.c	Thu May 14 15:46:04 2009 +0100
     1.2 +++ b/xen/arch/x86/acpi/cpu_idle.c	Thu May 14 15:46:43 2009 +0100
     1.3 @@ -624,6 +624,7 @@ static int check_cx(struct acpi_processo
     1.4  }
     1.5  
     1.6  static unsigned int latency_factor = 2;
     1.7 +integer_param("idle_latency_factor", latency_factor);
     1.8  
     1.9  static void set_cx(
    1.10      struct acpi_processor_power *acpi_power,
     2.1 --- a/xen/arch/x86/acpi/cpuidle_menu.c	Thu May 14 15:46:04 2009 +0100
     2.2 +++ b/xen/arch/x86/acpi/cpuidle_menu.c	Thu May 14 15:46:43 2009 +0100
     2.3 @@ -45,9 +45,15 @@ struct menu_device
     2.4  
     2.5  static DEFINE_PER_CPU(struct menu_device, menu_devices);
     2.6  
     2.7 -static s_time_t get_sleep_length_ns(void)
     2.8 +static unsigned int get_sleep_length_us(void)
     2.9  {
    2.10 -    return per_cpu(timer_deadline, smp_processor_id()) - NOW();
    2.11 +    s_time_t us = (per_cpu(timer_deadline, smp_processor_id()) - NOW()) / 1000;
    2.12 +    /*
    2.13 +     * while us < 0 or us > (u32)-1, return a large u32,
    2.14 +     * choose (unsigned int)-2000 to avoid wrapping while added with exit
    2.15 +     * latency because the latency should not larger than 2ms
    2.16 +     */
    2.17 +    return (us >> 32) ? (unsigned int)-2000 : (unsigned int)us;
    2.18  }
    2.19  
    2.20  static int menu_select(struct acpi_processor_power *power)
    2.21 @@ -56,7 +62,7 @@ static int menu_select(struct acpi_proce
    2.22      int i;
    2.23  
    2.24      /* determine the expected residency time */
    2.25 -    data->expected_us = (u32) get_sleep_length_ns() / 1000;
    2.26 +    data->expected_us = get_sleep_length_us();
    2.27  
    2.28      /* find the deepest idle state that satisfies our constraints */
    2.29      for ( i = 2; i < power->count; i++ )