mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muchun Song <songmuchun@bytedance.com>
To: rostedt@goodmis.org, mingo@kernel.org, tglx@linutronix.de,
	peterz@infradead.org, will@kernel.org, romain.perier@gmail.com
Cc: linux-kernel@vger.kernel.org, Muchun Song <songmuchun@bytedance.com>
Subject: [PATCH] tasklet: Introduce tasklet tracepoints
Date: Sat,  5 Sep 2020 14:04:12 +0800	[thread overview]
Message-ID: <20200905060412.88560-1-songmuchun@bytedance.com> (raw)

Introduce tracepoints for tasklets just like softirq does. In this case,
we can calculate tasklet latency and know what tasklet run.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 include/trace/events/irq.h | 44 ++++++++++++++++++++++++++++++++++++++
 kernel/softirq.c           |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
index eeceafaaea4c..69a16f3a21c2 100644
--- a/include/trace/events/irq.h
+++ b/include/trace/events/irq.h
@@ -160,6 +160,50 @@ DEFINE_EVENT(softirq, softirq_raise,
 	TP_ARGS(vec_nr)
 );
 
+DECLARE_EVENT_CLASS(tasklet,
+
+	TP_PROTO(struct tasklet_struct *t),
+
+	TP_ARGS(t),
+
+	TP_STRUCT__entry(
+		__field(	void *,	callback	)
+	),
+
+	TP_fast_assign(
+		__entry->callback = t->callback;
+	),
+
+	TP_printk("callback=%ps", __entry->callback)
+);
+
+/**
+ * tasklet_entry - called immediately before the tasklet handler
+ * @t: pointer to struct tasklet_struct
+ *
+ * When used in combination with the tasklet_exit tracepoint
+ * we can determine the tasklet handler routine.
+ */
+DEFINE_EVENT(tasklet, tasklet_entry,
+
+	TP_PROTO(struct tasklet_struct *t),
+
+	TP_ARGS(t)
+);
+
+/**
+ * tasklet_exit - called immediately after the tasklet handler returns
+ * @t: pointer to struct tasklet_struct
+ *
+ * When used in combination with the tasklet_entry tracepoint
+ * we can determine the tasklet handler routine.
+ */
+DEFINE_EVENT(tasklet, tasklet_exit,
+
+	TP_PROTO(struct tasklet_struct *t),
+
+	TP_ARGS(t)
+);
 #endif /*  _TRACE_IRQ_H */
 
 /* This part must be outside protection */
diff --git a/kernel/softirq.c b/kernel/softirq.c
index bf88d7f62433..0f9f5b2cc3d3 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -553,10 +553,12 @@ static void tasklet_action_common(struct softirq_action *a,
 				if (!test_and_clear_bit(TASKLET_STATE_SCHED,
 							&t->state))
 					BUG();
+				trace_tasklet_entry(t);
 				if (t->use_callback)
 					t->callback(t);
 				else
 					t->func(t->data);
+				trace_tasklet_exit(t);
 				tasklet_unlock(t);
 				continue;
 			}
-- 
2.20.1


             reply	other threads:[~2020-09-05  6:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-05  6:04 Muchun Song [this message]
2020-09-18 16:46 ` Steven Rostedt
2020-09-19  4:04   ` [External] " Muchun Song
2020-09-24 17:59 ` Thomas Gleixner
2020-09-25  2:47   ` [External] " Muchun Song

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=20200905060412.88560-1-songmuchun@bytedance.com \
    --to=songmuchun@bytedance.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=romain.perier@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.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

all inboxes | Powered by JetHome®