From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Xiaowei" Subject: [PATCH] use atomic_t type for system wide credit scheduler statistics Date: Mon, 09 Mar 2009 15:46:26 +0800 Message-ID: <49B4C952.30005@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090509020309050502070505" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------090509020309050502070505 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Current code is not SMP safe. Use atomic_t type instead. Thanks, xiaowei --------------090509020309050502070505 Content-Type: text/x-patch; name="stats.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stats.patch" 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 \ --------------090509020309050502070505 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------090509020309050502070505--