All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] use atomic_t type for system wide credit scheduler statistics
@ 2009-03-09  7:46 Yang, Xiaowei
  2009-03-09  8:09 ` Keir Fraser
  0 siblings, 1 reply; 5+ messages in thread
From: Yang, Xiaowei @ 2009-03-09  7:46 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 74 bytes --]

Current code is not SMP safe. Use atomic_t type instead.

Thanks,
xiaowei

[-- Attachment #2: stats.patch --]
[-- Type: text/x-patch, Size: 2248 bytes --]

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                                                  \

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-09 10:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-09  7:46 [PATCH] use atomic_t type for system wide credit scheduler statistics Yang, Xiaowei
2009-03-09  8:09 ` Keir Fraser
2009-03-09  8:30   ` Yang, Xiaowei
2009-03-09  8:36     ` Keir Fraser
2009-03-09 10:04       ` Yang, Xiaowei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.