Resend. 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 diff -r 824d35c72a8d xen/drivers/acpi/pmstat.c --- a/xen/drivers/acpi/pmstat.c Mon Apr 12 15:32:32 2010 +0800 +++ b/xen/drivers/acpi/pmstat.c Mon Apr 12 15:33:00 2010 +0800 @@ -86,12 +86,13 @@ int do_get_pm_info(struct xen_sysctl_get case PMSTAT_get_pxstat: { uint32_t ct; - struct pm_px *pxpt = cpufreq_statistic_data[op->cpuid]; + struct pm_px *pxpt; spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, op->cpuid); spin_lock(cpufreq_statistic_lock); + pxpt = cpufreq_statistic_data[op->cpuid]; if ( !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt ) { spin_unlock(cpufreq_statistic_lock); diff -r 824d35c72a8d xen/drivers/cpufreq/cpufreq_ondemand.c --- a/xen/drivers/cpufreq/cpufreq_ondemand.c Mon Apr 12 15:32:32 2010 +0800 +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c Mon Apr 12 15:33:17 2010 +0800 @@ -196,9 +196,8 @@ static void dbs_timer_init(struct cpu_db { dbs_info->enable = 1; - if ( !dbs_timer[dbs_info->cpu].function ) - init_timer(&dbs_timer[dbs_info->cpu], do_dbs_timer, - (void *)dbs_info, dbs_info->cpu); + init_timer(&dbs_timer[dbs_info->cpu], do_dbs_timer, + (void *)dbs_info, dbs_info->cpu); set_timer(&dbs_timer[dbs_info->cpu], NOW()+dbs_tuners_ins.sampling_rate); @@ -213,7 +212,7 @@ static void dbs_timer_exit(struct cpu_db { dbs_info->enable = 0; dbs_info->stoppable = 0; - stop_timer(&dbs_timer[dbs_info->cpu]); + kill_timer(&dbs_timer[dbs_info->cpu]); } int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)