diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-03-26 08:49:13 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-03-26 08:49:13 +0000 |
commit | 56d00aa7945e01291b40d05c60dde4b4dab0ce4c (patch) | |
tree | beae702e214ed35a09538e4fee993d5ed8ad23d5 | |
parent | b8352255b3eac73ab2f15874575613603aa2e9c0 (diff) | |
download | xen-56d00aa7945e01291b40d05c60dde4b4dab0ce4c.tar.gz xen-56d00aa7945e01291b40d05c60dde4b4dab0ce4c.tar.bz2 xen-56d00aa7945e01291b40d05c60dde4b4dab0ce4c.zip |
cpufreq: fix statistic lock problem
cpufreq_statistic_lock should not only protect the statistic memory
pointed by cpufreq_statistic_data[cpu], but also have to protect the
pointer in cpufreq_statistic_data[cpu] itself. So move the read
operation of cpufreq_statistic_data[cpu] after
spin_lock(cpufreq_statistic_lock).
Signed-off-by: Wei Gang <gang.wei@intel.com>
-rw-r--r-- | xen/drivers/cpufreq/utility.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c index 2d9921dcc5..c730df951f 100644 --- a/xen/drivers/cpufreq/utility.c +++ b/xen/drivers/cpufreq/utility.c @@ -63,13 +63,14 @@ void cpufreq_residency_update(unsigned int cpu, uint8_t state) void cpufreq_statistic_update(unsigned int cpu, uint8_t from, uint8_t to) { - struct pm_px *pxpt = cpufreq_statistic_data[cpu]; + struct pm_px *pxpt; struct processor_pminfo *pmpt = processor_pminfo[cpu]; spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, cpu); spin_lock(cpufreq_statistic_lock); + pxpt = cpufreq_statistic_data[cpu]; if ( !pxpt || !pmpt ) { spin_unlock(cpufreq_statistic_lock); return; @@ -89,7 +90,7 @@ void cpufreq_statistic_update(unsigned int cpu, uint8_t from, uint8_t to) int cpufreq_statistic_init(unsigned int cpuid) { uint32_t i, count; - struct pm_px *pxpt = cpufreq_statistic_data[cpuid]; + struct pm_px *pxpt; const struct processor_pminfo *pmpt = processor_pminfo[cpuid]; spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, cpuid); @@ -99,6 +100,7 @@ int cpufreq_statistic_init(unsigned int cpuid) spin_lock(cpufreq_statistic_lock); + pxpt = cpufreq_statistic_data[cpuid]; if ( pxpt ) { spin_unlock(cpufreq_statistic_lock); return 0; @@ -148,12 +150,13 @@ int cpufreq_statistic_init(unsigned int cpuid) void cpufreq_statistic_exit(unsigned int cpuid) { - struct pm_px *pxpt = cpufreq_statistic_data[cpuid]; + struct pm_px *pxpt; spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, cpuid); spin_lock(cpufreq_statistic_lock); + pxpt = cpufreq_statistic_data[cpuid]; if (!pxpt) { spin_unlock(cpufreq_statistic_lock); return; @@ -170,13 +173,14 @@ void cpufreq_statistic_exit(unsigned int cpuid) void cpufreq_statistic_reset(unsigned int cpuid) { uint32_t i, j, count; - struct pm_px *pxpt = cpufreq_statistic_data[cpuid]; + struct pm_px *pxpt; const struct processor_pminfo *pmpt = processor_pminfo[cpuid]; spinlock_t *cpufreq_statistic_lock = &per_cpu(cpufreq_statistic_lock, cpuid); spin_lock(cpufreq_statistic_lock); + pxpt = cpufreq_statistic_data[cpuid]; if ( !pmpt || !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt ) { spin_unlock(cpufreq_statistic_lock); return; |