WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [patch] cpufreq: fix statistic lock problem

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [patch] cpufreq: fix statistic lock problem
From: "Wei, Gang" <gang.wei@xxxxxxxxx>
Date: Fri, 26 Mar 2010 09:31:53 +0800
Accept-language: zh-CN, en-US
Acceptlanguage: zh-CN, en-US
Cc: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Thu, 25 Mar 2010 18:32:28 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcrMhB2FbIZuM2s3RZWbxOlvIx3UGw==
Thread-topic: [patch] cpufreq: fix statistic lock problem
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@xxxxxxxxx>

diff -r f7aeab5b7796 xen/drivers/cpufreq/utility.c
--- a/xen/drivers/cpufreq/utility.c     Wed Mar 24 17:05:16 2010 +0800
+++ b/xen/drivers/cpufreq/utility.c     Thu Mar 25 16:58:44 2010 +0800
@@ -63,13 +63,14 @@ void cpufreq_residency_update(unsigned i
 
 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 @@ int cpufreq_statistic_init(unsigned int 
 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 
 
     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 
 
 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_reset(unsigned in
 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;

Attachment: fix-cpufreq-stat-lock.patch
Description: fix-cpufreq-stat-lock.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [patch] cpufreq: fix statistic lock problem, Wei, Gang <=