xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Subject: [PATCH v2 10/10] xen/tools: tracing: always report how long next slice will be.
Date: Thu, 09 Feb 2017 14:59:29 +0100	[thread overview]
Message-ID: <148664876901.595.6987450024828384400.stgit@Solace.fritz.box> (raw)
In-Reply-To: <148664844741.595.10506268024432565895.stgit@Solace.fritz.box>

In fact, it is quite useful a pice of information,
to know how long it is the "next time slice" a vCPU
has been granted. It allows one to assume (and then
check) when the scheduler is supposed to run next,
and other things.

While this information is indeed reported when a
context switch happens, it is not when the same vCPU
that is running, continues to run.

Fix that, with the following outcome.

Before this change:

 csched2:schedule cpu 9, rq# 1, idle, SMT idle, tickled
 csched2:runq_candidate d0v3, 0 vcpus skipped, cpu 9 was tickled
 sched_switch prev d32767v9, run for 991.186us
 sched_switch next d0v3, was runnable for 2.515us, next slice 10000.0us
 sched_switch prev d32767v9 next d0v3              ^^^^^^^^^^^^^^^^^^^^
 runstate_change d32767v9 running->runnable
 ...
 csched2:schedule cpu 2, rq# 0, busy, not tickled
 csched2:burn_credits d1v5, credit = 9996950, delta = 502913
 csched2:runq_candidate d1v5, 0 vcpus skipped, no cpu was tickled
 runstate_continue d1v5 running->running
                                         ?????????????

That is, in the second block, it is shown that d1v5
was already running and will continue to do so,
but we have no idea for how long.

OTOH, after the change:

 csched2:schedule cpu 1, rq# 0, busy, not tickled
 csched2:burn_credits d0v8, credit = 9998645, delta = 12104
 csched2:runq_candidate d0v8, credit = 9998645, 0 vcpus skipped, no cpu was tickled
 sched_switch continue d0v8, run for 1125.820us, next slice 9998.645us
 runstate_continue d0v8 running->running         ^^^^^^^^^^^^^^^^^^^^^

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
---
 tools/xentrace/formats     |    1 +
 tools/xentrace/xenalyze.c  |   17 +++++++++++++++++
 xen/common/schedule.c      |    4 ++++
 xen/include/public/trace.h |    1 +
 4 files changed, 23 insertions(+)

diff --git a/tools/xentrace/formats b/tools/xentrace/formats
index 72c0b24..a055231 100644
--- a/tools/xentrace/formats
+++ b/tools/xentrace/formats
@@ -35,6 +35,7 @@
 0x0002800e  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  switch_infprev    [ dom:vcpu = 0x%(1)04x%(2)04x, runtime = %(3)d ]
 0x0002800f  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  switch_infnext    [ new_dom:vcpu = 0x%(1)04x%(2)04x, time = %(3)d, r_time = %(4)d ]
 0x00028010  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  domain_shutdown_code [ dom:vcpu = 0x%(1)04x%(2)04x, reason = 0x%(3)08x ]
+0x00028011  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  switch_infcont    [ dom:vcpu = 0x%(1)04x%(2)04x, runtime = %(3)d, r_time = %(4)d ]
 
 0x00022001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  csched:sched_tasklet
 0x00022002  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  csched:account_start [ dom:vcpu = 0x%(1)04x%(2)04x, active = %(3)d ]
diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
index 2678e2a..68ffcc2 100644
--- a/tools/xentrace/xenalyze.c
+++ b/tools/xentrace/xenalyze.c
@@ -7528,6 +7528,23 @@ void sched_process(struct pcpu_info *p)
                 printf("\n");
             }
             break;
+        case TRC_SCHED_SWITCH_INFCONT:
+            if(opt.dump_all)
+            {
+                struct {
+                    unsigned int domid, vcpuid, rsince;
+                    int slice;
+                } *r = (typeof(r))ri->d;
+
+                printf(" %s sched_switch continue d%uv%u, run for %u.%uus",
+                       ri->dump_header, r->domid, r->vcpuid,
+                       r->rsince / 1000, r->rsince % 1000);
+                if ( r->slice > 0 )
+                    printf(", next slice %u.%uus", r->slice / 1000,
+                           r->slice % 1000);
+                printf("\n");
+            }
+            break;
         case TRC_SCHED_CTL:
         case TRC_SCHED_S_TIMER_FN:
         case TRC_SCHED_T_TIMER_FN:
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index e4320f3..495f138 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1398,6 +1398,10 @@ static void schedule(void)
     if ( unlikely(prev == next) )
     {
         pcpu_schedule_unlock_irq(lock, cpu);
+        TRACE_4D(TRC_SCHED_SWITCH_INFCONT,
+                 next->domain->domain_id, next->vcpu_id,
+                 now - prev->runstate.state_entry_time,
+                 next_slice.time);
         trace_continue_running(next);
         return continue_running(prev);
     }
diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h
index 5ef9c37..7f2e891 100644
--- a/xen/include/public/trace.h
+++ b/xen/include/public/trace.h
@@ -115,6 +115,7 @@
 #define TRC_SCHED_SWITCH_INFPREV (TRC_SCHED_VERBOSE + 14)
 #define TRC_SCHED_SWITCH_INFNEXT (TRC_SCHED_VERBOSE + 15)
 #define TRC_SCHED_SHUTDOWN_CODE  (TRC_SCHED_VERBOSE + 16)
+#define TRC_SCHED_SWITCH_INFCONT (TRC_SCHED_VERBOSE + 17)
 
 #define TRC_DOM0_DOM_ADD         (TRC_DOM0_DOMOPS + 1)
 #define TRC_DOM0_DOM_REM         (TRC_DOM0_DOMOPS + 2)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-02-09 13:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-09 13:58 [PATCH v2 00/10] xen: credit2: improve style, and tracing; fix two bugs Dario Faggioli
2017-02-09 13:58 ` [PATCH v2 01/10] xen: sched: harmonize debug dump output among schedulers Dario Faggioli
2017-02-15 10:17   ` George Dunlap
2017-02-15 10:31     ` Dario Faggioli
2017-02-09 13:58 ` [PATCH v2 02/10] xen: credit2: clear bit instead of skip step in runq_tickle() Dario Faggioli
2017-02-15 10:21   ` George Dunlap
2017-02-09 13:58 ` [PATCH v2 03/10] xen: credit2: improve comments' style and definition of CSFLAG-s Dario Faggioli
2017-02-15 10:44   ` George Dunlap
2017-02-09 13:58 ` [PATCH v2 04/10] xen: credit2: make accessor helpers inline functions instead of macros Dario Faggioli
2017-02-09 14:14   ` Andrew Cooper
2017-02-09 14:34     ` Jan Beulich
2017-02-09 14:36   ` Jan Beulich
2017-02-09 15:33     ` Dario Faggioli
2017-02-15 10:49       ` George Dunlap
2017-02-24 18:26         ` Dario Faggioli
2017-02-09 13:58 ` [PATCH v2 05/10] xen: credit2: tidy up functions names by removing leading '__' Dario Faggioli
2017-02-15 13:57   ` George Dunlap
2017-02-24 18:32     ` Dario Faggioli
2017-02-09 13:59 ` [PATCH v2 06/10] xen: credit2: group the runq manipulating functions Dario Faggioli
2017-02-15 14:42   ` George Dunlap
2017-02-27 18:25     ` Dario Faggioli
2017-02-09 13:59 ` [PATCH v2 07/10] xen: credit2: always mark a tickled pCPU as... tickled! Dario Faggioli
2017-02-09 23:48   ` Dario Faggioli
2017-02-15 14:55     ` George Dunlap
2017-02-09 13:59 ` [PATCH v2 08/10] xen: credit2: don't miss accounting while doing a credit reset Dario Faggioli
2017-02-15 15:07   ` George Dunlap
2017-02-09 13:59 ` [PATCH v2 09/10] xen/tools: tracing: trace (Credit2) runq traversal Dario Faggioli
2017-02-15 15:31   ` George Dunlap
2017-02-24 18:48     ` Dario Faggioli
2017-02-09 13:59 ` Dario Faggioli [this message]
2017-02-15 15:40   ` [PATCH v2 10/10] xen/tools: tracing: always report how long next slice will be George Dunlap
2017-02-27 18:12     ` Dario Faggioli
2017-02-09 14:37 ` [PATCH v2 00/10] xen: credit2: improve style, and tracing; fix two bugs Jan Beulich
2017-02-09 15:29   ` Dario Faggioli
2017-02-15 16:03 ` 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=148664876901.595.6987450024828384400.stgit@Solace.fritz.box \
    --to=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.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).