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: Stefano Stabellini <sstabellini@kernel.org>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Tim Deegan <tim@xen.org>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 12/15] xen: trace tasklets
Date: Thu, 01 Jun 2017 19:35:01 +0200	[thread overview]
Message-ID: <149633850145.12814.17354434813897681091.stgit@Solace.fritz.box> (raw)
In-Reply-To: <149633614204.12814.14390287626133023934.stgit@Solace.fritz.box>

Making it possible generate events showing the
activity and the behavior of tasklets.

Gate this with its specific Kconfig option (under
CONFIG_TRACING), and keep it in disabled state by
default.
---
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
---
 xen/Kconfig.debug          |    8 ++++
 xen/common/tasklet.c       |   87 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/public/trace.h |    9 +++++
 3 files changed, 104 insertions(+)

diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug
index 4979e83..f7b2e06 100644
--- a/xen/Kconfig.debug
+++ b/xen/Kconfig.debug
@@ -132,6 +132,14 @@ config TRACE_SOFTIRQS
 	  Makes it possible to generate events related to raising and
           handling of softirqs within Xen.
 
+config TRACE_TASKLETS
+	bool "Trace when tasklets are queued and scheduled" if EXPERT = "y"
+	default n
+	depends on TRACING
+	---help---
+	  Make it possible to generate events related to scheduling,
+          queueing and running of tasklets within Xen.
+
 config VERBOSE_DEBUG
 	bool "Verbose debug messages"
 	default DEBUG
diff --git a/xen/common/tasklet.c b/xen/common/tasklet.c
index 365a777..20b9d68 100644
--- a/xen/common/tasklet.c
+++ b/xen/common/tasklet.c
@@ -30,10 +30,87 @@ static DEFINE_PER_CPU(struct list_head, softirq_tasklet_list);
 /* Protects all lists and tasklet structures. */
 static DEFINE_SPINLOCK(tasklet_lock);
 
+#ifdef CONFIG_TRACE_TASKLETS
+static inline void trace_enqueue(const struct tasklet *t)
+{
+    uint64_t addr;
+
+    if ( likely(!tb_init_done) )
+        return;
+
+    addr = (uint64_t)t->func;
+    __trace_var(TRC_XEN_TASKLET_ENQUEUE, 0, sizeof(addr), &addr);
+}
+static inline void trace_schedule(const struct tasklet *t)
+{
+    struct {
+        uint64_t addr;
+        int16_t sched_on, is_sirq;
+    } d;
+
+    if ( likely(!tb_init_done) )
+        return;
+
+    d.addr = (uint64_t)t->func;
+    d.sched_on = t->scheduled_on;
+    d.is_sirq = t->is_softirq;
+    __trace_var(TRC_XEN_TASKLET_SCHEDULE, 1, sizeof(d), &d);
+}
+static inline void trace_work(const struct tasklet *t)
+{
+    uint64_t addr;
+
+    if ( likely(!tb_init_done) )
+        return;
+
+    addr = (uint64_t)t->func;
+    __trace_var(TRC_XEN_TASKLET_WORK, 1, sizeof(addr), &addr);
+}
+static inline void trace_kill(const struct tasklet *t)
+{
+    struct {
+        uint64_t addr;
+        int16_t sched_on, is_run;
+    } d;
+
+    if ( likely(!tb_init_done) )
+        return;
+
+    d.addr = (uint64_t)t->func;
+    d.sched_on = t->scheduled_on;
+    d.is_run = t->is_running;
+    __trace_var(TRC_XEN_TASKLET_KILL, 0, sizeof(d), &d);
+}
+static inline void trace_init(const struct tasklet *t)
+{
+    struct {
+        uint64_t addr;
+        uint32_t is_sirq;
+    } d;
+
+    if ( likely(!tb_init_done) )
+        return;
+
+    d.addr = (uint64_t)t->func;
+    d.is_sirq = t->is_softirq;
+    __trace_var(TRC_XEN_TASKLET_INIT, 0, sizeof(d), &d);
+}
+#define trace_migrate()      TRACE_0D(TRC_XEN_TASKLET_MIGR);
+#else
+#define trace_enqueue(t)     do {} while ( 0 )
+#define trace_schedule(t)    do {} while ( 0 )
+#define trace_work(t)        do {} while ( 0 )
+#define trace_kill(t)        do {} while ( 0 )
+#define trace_migrate()      do {} while ( 0 )
+#define trace_init(t)        do {} while ( 0 )
+#endif /* TRACE_TASKLETS */
+
 static void tasklet_enqueue(struct tasklet *t)
 {
     unsigned int cpu = t->scheduled_on;
 
+    trace_enqueue(t);
+
     if ( t->is_softirq )
     {
         struct list_head *list = &per_cpu(softirq_tasklet_list, cpu);
@@ -60,6 +137,7 @@ void tasklet_schedule_on_cpu(struct tasklet *t, unsigned int cpu)
     if ( tasklets_initialised && !t->is_dead )
     {
         t->scheduled_on = cpu;
+        trace_schedule(t);
         if ( !t->is_running )
         {
             list_del(&t->list);
@@ -91,6 +169,7 @@ static void do_tasklet_work(unsigned int cpu, struct list_head *list)
 
     spin_unlock_irq(&tasklet_lock);
     sync_local_execstate();
+    trace_work(t);
     t->func(t->data);
     spin_lock_irq(&tasklet_lock);
 
@@ -158,6 +237,7 @@ void tasklet_kill(struct tasklet *t)
         list_del_init(&t->list);
     }
 
+    trace_kill(t);
     t->scheduled_on = -1;
     t->is_dead = 1;
 
@@ -178,6 +258,11 @@ static void migrate_tasklets_from_cpu(unsigned int cpu, struct list_head *list)
 
     spin_lock_irqsave(&tasklet_lock, flags);
 
+    if ( list_empty(list) )
+        goto out;
+
+    trace_migrate();
+
     while ( !list_empty(list) )
     {
         t = list_entry(list->next, struct tasklet, list);
@@ -187,6 +272,7 @@ static void migrate_tasklets_from_cpu(unsigned int cpu, struct list_head *list)
         tasklet_enqueue(t);
     }
 
+ out:
     spin_unlock_irqrestore(&tasklet_lock, flags);
 }
 
@@ -198,6 +284,7 @@ void tasklet_init(
     t->scheduled_on = -1;
     t->func = func;
     t->data = data;
+    trace_init(t);
 }
 
 void softirq_tasklet_init(
diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h
index 9d065aa..acee7d5 100644
--- a/xen/include/public/trace.h
+++ b/xen/include/public/trace.h
@@ -96,6 +96,7 @@
 /* Trace subclasses for Xen internals */
 #define TRC_XEN_RCU         0x01001000   /* RCU traces */
 #define TRC_XEN_SIRQ        0x01002000   /* Traces relating to softirqs */
+#define TRC_XEN_TSKLT       0x01004000   /* Traces relating to tasklets */
 
 /* Trace events per class */
 #define TRC_LOST_RECORDS        (TRC_GEN + 1)
@@ -299,6 +300,14 @@
 #define TRC_XEN_SIRQ_RAISE_CPU        (TRC_XEN_SIRQ + 0x3)
 #define TRC_XEN_SIRQ_RAISE            (TRC_XEN_SIRQ + 0x4)
 
+/* Trace events for tasklets */
+#define TRC_XEN_TASKLET_ENQUEUE       (TRC_XEN_TSKLT + 0x1)
+#define TRC_XEN_TASKLET_SCHEDULE      (TRC_XEN_TSKLT + 0x2)
+#define TRC_XEN_TASKLET_WORK          (TRC_XEN_TSKLT + 0x3)
+#define TRC_XEN_TASKLET_KILL          (TRC_XEN_TSKLT + 0x4)
+#define TRC_XEN_TASKLET_INIT          (TRC_XEN_TSKLT + 0x5)
+#define TRC_XEN_TASKLET_MIGR          (TRC_XEN_TSKLT + 0x6)
+
 /*
  * Event Flags
  *


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

  parent reply	other threads:[~2017-06-01 17:35 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 17:33 [PATCH 00/15] xen/tools: add tracing to various Xen subsystems Dario Faggioli
2017-06-01 17:33 ` [PATCH 01/15] xen: in do_softirq() sample smp_processor_id() once and for all Dario Faggioli
2017-06-07 14:38   ` Jan Beulich
2017-06-08 14:12     ` George Dunlap
2017-06-08 14:20   ` George Dunlap
2017-06-08 14:42     ` Jan Beulich
2017-06-01 17:33 ` [PATCH 02/15] xen: tracing: avoid checking tb_init_done multiple times Dario Faggioli
2017-06-01 17:53   ` Andrew Cooper
2017-06-01 23:08     ` Dario Faggioli
2017-06-07 14:46   ` Jan Beulich
2017-06-07 15:55     ` Dario Faggioli
2017-06-07 16:06       ` Jan Beulich
2017-06-08 14:34         ` George Dunlap
2017-06-08 14:37   ` George Dunlap
2017-06-01 17:33 ` [PATCH 03/15] xen/tools: tracing: several improvements on IRQs tracing Dario Faggioli
2017-06-01 18:02   ` Andrew Cooper
2017-06-01 23:12     ` Dario Faggioli
2017-06-07 15:05   ` Jan Beulich
2017-06-07 15:45     ` Dario Faggioli
2017-06-07 15:58       ` Jan Beulich
2017-06-08 14:53         ` George Dunlap
2017-06-08 15:34           ` Jan Beulich
2017-06-08 14:59   ` George Dunlap
2017-06-01 17:34 ` [PATCH 04/15] tools: xenalyze: fix dumping of PM_IDLE events Dario Faggioli
2017-06-08 15:06   ` George Dunlap
2017-06-01 17:34 ` [PATCH 05/15] xen: make it possible to disable tracing in Kconfig Dario Faggioli
2017-06-01 18:43   ` Andrew Cooper
2017-06-07 11:01     ` Julien Grall
2017-06-07 15:14   ` Jan Beulich
2017-06-08 15:16     ` George Dunlap
2017-06-08 15:35       ` Jan Beulich
2017-06-08 15:37         ` George Dunlap
2017-06-08 15:44           ` Jan Beulich
2017-06-08 15:17   ` George Dunlap
2017-06-01 17:34 ` [PATCH 06/15] xen: trace IRQ enabling/disabling Dario Faggioli
2017-06-01 19:08   ` Andrew Cooper
2017-06-01 23:42     ` Dario Faggioli
2017-06-08 15:51       ` George Dunlap
2017-06-08 16:05       ` Jan Beulich
2017-06-07 11:16   ` Julien Grall
2017-06-07 15:22     ` Dario Faggioli
2017-06-09 10:51       ` Julien Grall
2017-06-09 10:53         ` Julien Grall
2017-06-09 10:55         ` George Dunlap
2017-06-09 11:00           ` Julien Grall
2017-06-08 16:01   ` George Dunlap
2017-06-08 16:11     ` Dario Faggioli
2017-06-09 10:41   ` Jan Beulich
2017-06-01 17:34 ` [PATCH 07/15] tools: tracing: handle IRQs on/off events in xentrace and xenalyze Dario Faggioli
2017-06-13 15:58   ` George Dunlap
2017-06-01 17:34 ` [PATCH 08/15] xen: trace RCU behavior Dario Faggioli
2017-06-09 10:48   ` Jan Beulich
2017-06-13 16:05   ` George Dunlap
2017-06-01 17:34 ` [PATCH 09/15] tools: tracing: handle RCU events in xentrace and xenalyze Dario Faggioli
2017-06-13 16:12   ` George Dunlap
2017-06-01 17:34 ` [PATCH 10/15] xen: trace softirqs Dario Faggioli
2017-06-09 10:51   ` Jan Beulich
2017-06-01 17:34 ` [PATCH 11/15] tools: tracing: handle RCU events in xentrace and xenalyze Dario Faggioli
2017-06-01 17:35 ` Dario Faggioli [this message]
2017-06-09 10:59   ` [PATCH 12/15] xen: trace tasklets Jan Beulich
2017-06-09 11:17     ` Dario Faggioli
2017-06-09 11:29       ` Jan Beulich
2017-06-01 17:35 ` [PATCH 13/15] tools: tracing: handle tasklets events in xentrace and xenalyze Dario Faggioli
2017-06-01 17:35 ` [PATCH 14/15] xen: trace timers Dario Faggioli
2017-06-01 17:35 ` [PATCH 15/15] tools: tracing: handle timers events in xentrace and xenalyze Dario Faggioli
2017-06-07 14:13 ` [PATCH 00/15] xen/tools: add tracing to various Xen subsystems Konrad Rzeszutek Wilk
2017-06-08 16:45   ` Dario Faggioli
2017-06-13 16:34 ` 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=149633850145.12814.17354434813897681091.stgit@Solace.fritz.box \
    --to=dario.faggioli@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --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).