All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yang, Xiaowei" <xiaowei.yang@intel.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] use atomic_t type for system wide credit scheduler statistics
Date: Mon, 09 Mar 2009 15:46:26 +0800	[thread overview]
Message-ID: <49B4C952.30005@intel.com> (raw)

[-- 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

             reply	other threads:[~2009-03-09  7:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09  7:46 Yang, Xiaowei [this message]
2009-03-09  8:09 ` [PATCH] use atomic_t type for system wide credit scheduler statistics Keir Fraser
2009-03-09  8:30   ` Yang, Xiaowei
2009-03-09  8:36     ` Keir Fraser
2009-03-09 10:04       ` Yang, Xiaowei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49B4C952.30005@intel.com \
    --to=xiaowei.yang@intel.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.