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] use atomic_t type for system wide credit scheduler s

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] use atomic_t type for system wide credit scheduler statistics
From: "Yang, Xiaowei" <xiaowei.yang@xxxxxxxxx>
Date: Mon, 09 Mar 2009 15:46:26 +0800
Delivery-date: Mon, 09 Mar 2009 00:49:18 -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
User-agent: Thunderbird 2.0.0.19 (X11/20090105)
Current code is not SMP safe. Use atomic_t type instead.

Thanks,
xiaowei
diff -r 5b9f282679ae -r 7b843d53b3ea xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Mon Mar 09 00:09:52 2009 +0800
+++ b/xen/common/sched_credit.c Mon Mar 09 01:26:09 2009 +0800
@@ -79,12 +79,17 @@
  */
 #ifdef CSCHED_STATS
 
-#define CSCHED_STAT(_X)         (csched_priv.stats._X)
-#define CSCHED_STAT_DEFINE(_X)  uint32_t _X;
+#define CSCHED_STAT(_X)         (atomic_read(&csched_priv.stats._X))
+#define CSCHED_STAT_DEFINE(_X)  atomic_t _X;
 #define CSCHED_STAT_PRINTK(_X)                                  \
     do                                                          \
     {                                                           \
-        printk("\t%-30s = %u\n", #_X, CSCHED_STAT(_X));  \
+        printk("\t%-30s = %i\n", #_X, CSCHED_STAT(_X));         \
+    } while ( 0 );
+#define CSCHED_STAT_RESET(_X)                                   \
+    do                                                          \
+    {                                                           \
+        atomic_set(&csched_priv.stats._X, 0);                   \
     } while ( 0 );
 
 /*
@@ -137,12 +142,6 @@
     CSCHED_STATS_EXPAND_CHECKS(_MACRO)      \
     CSCHED_STATS_EXPAND_SCHED(_MACRO)
 
-#define CSCHED_STATS_RESET()                                        \
-    do                                                              \
-    {                                                               \
-        memset(&csched_priv.stats, 0, sizeof(csched_priv.stats));   \
-    } while ( 0 )
-
 #define CSCHED_STATS_DEFINE()                   \
     struct                                      \
     {                                           \
@@ -156,7 +155,13 @@
         CSCHED_STATS_EXPAND(CSCHED_STAT_PRINTK) \
     } while ( 0 )
 
-#define CSCHED_STAT_CRANK(_X)               (CSCHED_STAT(_X)++)
+#define CSCHED_STATS_RESET()                    \
+    do                                          \
+    {                                           \
+        CSCHED_STATS_EXPAND(CSCHED_STAT_RESET)  \
+    } while ( 0 )
+
+#define CSCHED_STAT_CRANK(_X)               (atomic_inc(&csched_priv.stats._X))
 
 #define CSCHED_VCPU_STATS_RESET(_V)                     \
     do                                                  \
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel