debuggers.hg

changeset 21177:5d4038d41fd8

cpufreq: fix racing issue for cpu hotplug

To eliminate racing between dbs timer handler and cpufreq_del_cpu,
using kill_timer instead of stop_timer to make sure timer handler
execution finished before other stuff in cpufreq_del_cpu.

BTW, fix a lost point of cpufreq_statistic_lock taking sequence.

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 12 17:33:47 2010 +0100 (2010-04-12)
parents 1d3bec665289
children b65a41dc6c6a
files xen/drivers/acpi/pmstat.c xen/drivers/cpufreq/cpufreq_ondemand.c
line diff
     1.1 --- a/xen/drivers/acpi/pmstat.c	Mon Apr 12 17:30:08 2010 +0100
     1.2 +++ b/xen/drivers/acpi/pmstat.c	Mon Apr 12 17:33:47 2010 +0100
     1.3 @@ -86,12 +86,13 @@ int do_get_pm_info(struct xen_sysctl_get
     1.4      case PMSTAT_get_pxstat:
     1.5      {
     1.6          uint32_t ct;
     1.7 -        struct pm_px *pxpt = cpufreq_statistic_data[op->cpuid];
     1.8 +        struct pm_px *pxpt;
     1.9          spinlock_t *cpufreq_statistic_lock = 
    1.10                     &per_cpu(cpufreq_statistic_lock, op->cpuid);
    1.11  
    1.12          spin_lock(cpufreq_statistic_lock);
    1.13  
    1.14 +        pxpt = cpufreq_statistic_data[op->cpuid];
    1.15          if ( !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt )
    1.16          {
    1.17              spin_unlock(cpufreq_statistic_lock);
     2.1 --- a/xen/drivers/cpufreq/cpufreq_ondemand.c	Mon Apr 12 17:30:08 2010 +0100
     2.2 +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c	Mon Apr 12 17:33:47 2010 +0100
     2.3 @@ -189,9 +189,8 @@ static void dbs_timer_init(struct cpu_db
     2.4  {
     2.5      dbs_info->enable = 1;
     2.6  
     2.7 -    if ( !dbs_timer[dbs_info->cpu].function )
     2.8 -        init_timer(&dbs_timer[dbs_info->cpu], do_dbs_timer, 
     2.9 -            (void *)dbs_info, dbs_info->cpu);
    2.10 +    init_timer(&dbs_timer[dbs_info->cpu], do_dbs_timer, 
    2.11 +        (void *)dbs_info, dbs_info->cpu);
    2.12  
    2.13      set_timer(&dbs_timer[dbs_info->cpu], NOW()+dbs_tuners_ins.sampling_rate);
    2.14  
    2.15 @@ -206,7 +205,7 @@ static void dbs_timer_exit(struct cpu_db
    2.16  {
    2.17      dbs_info->enable = 0;
    2.18      dbs_info->stoppable = 0;
    2.19 -    stop_timer(&dbs_timer[dbs_info->cpu]);
    2.20 +    kill_timer(&dbs_timer[dbs_info->cpu]);
    2.21  }
    2.22  
    2.23  int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)