xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Paul Durrant <paul.durrant@citrix.com>,
	Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 5 of 6] xen: sched_sedf: beautify statisics in SEDF
Date: Mon, 22 Oct 2012 16:40:38 +0200	[thread overview]
Message-ID: <27c4c065efe366a5d761.1350916838@Solace> (raw)
In-Reply-To: <patchbomb.1350916833@Solace>

By gathering all the related fields in a struct (as it is being done
in credit) and using the macros we now have available. No functional
changes involved.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

diff --git a/xen/common/sched_sedf.c b/xen/common/sched_sedf.c
--- a/xen/common/sched_sedf.c
+++ b/xen/common/sched_sedf.c
@@ -14,7 +14,6 @@
 #include <xen/errno.h>
 
 #ifndef NDEBUG
-#define SEDF_STATS
 #define CHECK(_p)                                           \
     do {                                                    \
         if ( !(_p) )                                        \
@@ -45,6 +44,37 @@
 #define IMPLY(a, b) (!(a) || (b))
 #define EQ(a, b) ((!!(a)) == (!!(b)))
 
+/*
+ * SEDF_STATS
+ *
+ * Some statistics about vCPU execution.
+ *
+ * Some of them are displayed with runq dumps
+ * ('r' on the Xen console).
+ */
+#ifdef SCHED_STATS
+
+#define SEDF_STATS
+
+#define SCHED_VCPU_STATS_RESET(_V)                      \
+    do                                                  \
+    {                                                   \
+        memset(&(_V)->stats, 0, sizeof((_V)->stats));   \
+    } while ( 0 )
+
+#define SCHED_VCPU_STAT_CRANK(_V, _X)       (((_V)->stats._X)++)
+
+/*#define SCHED_VCPU_STAT_SET(_V, _X, _Y)     (((_V)->stats._X) = (_Y))*/
+
+#else /* !SCHED_STATS */
+
+#undef SEDF_STATS
+
+#define SCHED_VCPU_STATS_RESET(_V)         do {} while ( 0 )
+#define SCHED_VCPU_STAT_CRANK(_V, _X)      do {} while ( 0 )
+/*#define SCHED_VCPU_STAT_SET(_V, _X, _Y)    do {} while ( 0 )*/
+
+#endif /* SCHED_STATS */
 
 struct sedf_dom_info {
     struct domain  *domain;
@@ -92,14 +122,16 @@ struct sedf_vcpu_info {
     s_time_t  extra_time_tot;
 
 #ifdef SEDF_STATS
-    s_time_t  block_time_tot;
-    s_time_t  penalty_time_tot;
-    int   block_tot;
-    int   short_block_tot;
-    int   long_block_tot;
-    int   short_cont;
-    int   pen_extra_blocks;
-    int   pen_extra_slices;
+    struct {
+        s_time_t block_time_tot;
+        s_time_t penalty_time_tot;
+        int block_tot;
+        int short_block_tot;
+        int long_block_tot;
+        int short_cont;
+        int pen_extra_blocks;
+        int pen_extra_slices;
+    } stats;
 #endif
 };
 
@@ -332,6 +364,7 @@ static void *sedf_alloc_vdata(const stru
     INIT_LIST_HEAD(&(inf->extralist[EXTRA_PEN_Q]));
     INIT_LIST_HEAD(&(inf->extralist[EXTRA_UTIL_Q]));
 
+    SCHED_VCPU_STATS_RESET(inf);
     SCHED_STAT_CRANK(vcpu_init);
 
     return inf;
@@ -688,9 +721,7 @@ static struct task_slice sedf_do_extra_s
         runinf->status |= EXTRA_RUN_PEN;
         ret.task = runinf->vcpu;
         ret.time = EXTRA_QUANTUM;
-#ifdef SEDF_STATS
-        runinf->pen_extra_slices++;
-#endif
+        SCHED_VCPU_STAT_CRANK(runinf, pen_extra_slices);
     }
     else
     {
@@ -989,9 +1020,7 @@ static void unblock_short_extra_support(
         {
             inf->score[0] = (inf->period << 10) /
                 inf->short_block_lost_tot;
-#ifdef SEDF_STATS
-            inf->pen_extra_blocks++;
-#endif
+            SCHED_VCPU_STAT_CRANK(inf, pen_extra_blocks);
             if ( extraq_on(inf->vcpu, EXTRA_PEN_Q) )
                 /* Remove domain for possible resorting! */
                 extraq_del(inf->vcpu, EXTRA_PEN_Q);
@@ -1108,9 +1137,7 @@ static void sedf_wake(const struct sched
         inf->deadl_abs = now + inf->slice;
     }
   
-#ifdef SEDF_STATS 
-    inf->block_tot++;
-#endif
+    SCHED_VCPU_STAT_CRANK(inf, block_tot);
 
     if ( unlikely(now < PERIOD_BEGIN(inf)) )
     {
@@ -1132,9 +1159,7 @@ static void sedf_wake(const struct sched
         if ( now < inf->deadl_abs )
         {
             /* Short blocking */
-#ifdef SEDF_STATS
-            inf->short_block_tot++;
-#endif
+            SCHED_VCPU_STAT_CRANK(inf, short_block_tot);
             unblock_short_extra_support(inf, now);
 
             extraq_check_add_unblocked(d, 1);
@@ -1142,9 +1167,7 @@ static void sedf_wake(const struct sched
         else
         {
             /* Long unblocking */
-#ifdef SEDF_STATS
-            inf->long_block_tot++;
-#endif
+            SCHED_VCPU_STAT_CRANK(inf, long_block_tot);
             unblock_long_cons_b(inf, now);
 
             extraq_check_add_unblocked(d, 1);
@@ -1160,8 +1183,8 @@ static void sedf_wake(const struct sched
     /* Do some statistics here... */
     if ( inf->block_abs != 0 )
     {
-        inf->block_time_tot += now - inf->block_abs;
-        inf->penalty_time_tot +=
+        inf->stats.block_time_tot += now - inf->block_abs;
+        inf->stats.penalty_time_tot +=
             PERIOD_BEGIN(inf) + inf->cputime - inf->block_abs;
     }
 #endif
@@ -1197,22 +1220,22 @@ static void sedf_dump_domain(struct vcpu
            EDOM_INFO(d)->extra_time_tot, EDOM_INFO(d)->extraweight);
     
 #ifdef SEDF_STATS
-    if ( EDOM_INFO(d)->block_time_tot != 0 )
-        printk(" pen=%"PRIu64"%%", (EDOM_INFO(d)->penalty_time_tot * 100) /
-               EDOM_INFO(d)->block_time_tot);
-    if ( EDOM_INFO(d)->block_tot != 0 )
+    if ( EDOM_INFO(d)->stats.block_time_tot != 0 )
+        printk(" pen=%"PRIu64"%%", (EDOM_INFO(d)->stats.penalty_time_tot * 100) /
+               EDOM_INFO(d)->stats.block_time_tot);
+    if ( EDOM_INFO(d)->stats.block_tot != 0 )
         printk("\n   blks=%u sh=%u (%u%%) (shc=%u (%u%%) shex=%i "\
                "shexsl=%i) l=%u (%u%%) avg: b=%"PRIu64" p=%"PRIu64"",
-               EDOM_INFO(d)->block_tot, EDOM_INFO(d)->short_block_tot,
-               (EDOM_INFO(d)->short_block_tot * 100) 
-               / EDOM_INFO(d)->block_tot, EDOM_INFO(d)->short_cont,
-               (EDOM_INFO(d)->short_cont * 100) / EDOM_INFO(d)->block_tot,
-               EDOM_INFO(d)->pen_extra_blocks,
-               EDOM_INFO(d)->pen_extra_slices,
-               EDOM_INFO(d)->long_block_tot,
-               (EDOM_INFO(d)->long_block_tot * 100) / EDOM_INFO(d)->block_tot,
-               (EDOM_INFO(d)->block_time_tot) / EDOM_INFO(d)->block_tot,
-               (EDOM_INFO(d)->penalty_time_tot) / EDOM_INFO(d)->block_tot);
+               EDOM_INFO(d)->stats.block_tot, EDOM_INFO(d)->stats.short_block_tot,
+               (EDOM_INFO(d)->stats.short_block_tot * 100) 
+               / EDOM_INFO(d)->stats.block_tot, EDOM_INFO(d)->stats.short_cont,
+               (EDOM_INFO(d)->stats.short_cont * 100) / EDOM_INFO(d)->stats.block_tot,
+               EDOM_INFO(d)->stats.pen_extra_blocks,
+               EDOM_INFO(d)->stats.pen_extra_slices,
+               EDOM_INFO(d)->stats.long_block_tot,
+               (EDOM_INFO(d)->stats.long_block_tot * 100) / EDOM_INFO(d)->stats.block_tot,
+               (EDOM_INFO(d)->stats.block_time_tot) / EDOM_INFO(d)->stats.block_tot,
+               (EDOM_INFO(d)->stats.penalty_time_tot) / EDOM_INFO(d)->stats.block_tot);
 #endif
     printk("\n");
 }

  parent reply	other threads:[~2012-10-22 14:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 14:40 [PATCH 0 of 6] Xen: generalize and beautify scheduling related perfc and stats Dario Faggioli
2012-10-22 14:40 ` [PATCH 1 of 6] xen: fix build when 'perfc=y' Dario Faggioli
2012-10-23 16:01   ` George Dunlap
2012-10-22 14:40 ` [PATCH 2 of 6] xen: move `printk("Initializing domain")` from credit to generic scheduling code Dario Faggioli
2012-10-23 16:04   ` George Dunlap
2012-10-23 16:13     ` Dario Faggioli
2012-10-23 16:20       ` George Dunlap
2012-10-22 14:40 ` [PATCH 3 of 6] xen: sched: generalize scheduling related perfcounter macros Dario Faggioli
2012-10-23 16:27   ` George Dunlap
2012-10-22 14:40 ` [PATCH 4 of 6] xen: sched: introduce a couple of counters in credit2 and SEDF Dario Faggioli
2012-10-23 16:28   ` George Dunlap
2012-10-22 14:40 ` Dario Faggioli [this message]
2012-10-23 16:26   ` [PATCH 5 of 6] xen: sched_sedf: beautify statisics in SEDF George Dunlap
2012-10-23 16:33     ` Dario Faggioli
2012-10-23 16:35       ` George Dunlap
2012-10-22 14:40 ` [PATCH 6 of 6] xen: sched_sedf: remove an unused stat " Dario Faggioli
2012-10-23 16:30   ` George Dunlap

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=27c4c065efe366a5d761.1350916838@Solace \
    --to=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=paul.durrant@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).