Skip to contentSkip to conversation

softirq: Add tracepoint for tasklet_entry/exit

PATCH Superseded Junwen Wu 2 participants 3 messages May 8, 2022 – May 28, 2022 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Junwen Wu

author
#0 lore raw

PATCH 1/1 softirq: Add tracepoint for tasklet_entry/exit

Usually softirq handler is pre-defined,only tasklet can be register by driver.We expand tracepoint for tasklet_entry/exit to trace tasklet handler.

---
 include/trace/events/irq.h | 32 ++++++++++++++++++++++++++++++++
 kernel/softirq.c           |  4 ++++
 2 files changed, 36 insertions(+)
include/trace/events/irq.h +32 -0
index eeceafaaea4c..d3e922dcd475 100644
@@ -160,6 +160,38 @@ DEFINE_EVENT(softirq, softirq_raise,
 	TP_ARGS(vec_nr)
 );
 
+TRACE_EVENT(tasklet_entry,
+
+	TP_PROTO(void *func),
+
+	TP_ARGS(func),
+
+	TP_STRUCT__entry(
+		__field(        void *,    func          )
+	),
+
+	TP_fast_assign(
+	__entry->func = func;
+	),
+
+	TP_printk("function=%ps", __entry->func)
+);
+TRACE_EVENT(tasklet_exit,
+
+	TP_PROTO(void *func),
+
+	TP_ARGS(func),
+
+	TP_STRUCT__entry(
+		__field(        void *,    func          )
+	),
+
+	TP_fast_assign(
+		__entry->func = func;
+	),
+
+	TP_printk("function=%ps", __entry->func)
+);
 #endif /*  _TRACE_IRQ_H */
 
 /* This part must be outside protection */
kernel/softirq.c +4 -0
index 41f470929e99..b3bce2b3b655 100644
@@ -780,10 +780,14 @@ static void tasklet_action_common(struct softirq_action *a,
 		if (tasklet_trylock(t)) {
 			if (!atomic_read(&t->count)) {
 				if (tasklet_clear_sched(t)) {
+					trace_tasklet_entry(t->use_callback ? (void *)t->callback 
+							: (void *)t->func);
 					if (t->use_callback)
 						t->callback(t);
 					else
 						t->func(t->data);
+					trace_tasklet_exit(t->use_callback ? (void *)t->callback
+							: (void *)t->func);
 				}
 				tasklet_unlock(t);
 				continue;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 27 lines · On Sun, 8 May 2022 16:06:24 +0000 Junwen Wu <[email protected]> wrote:
include/trace/events/irq.h +21 -0
@@ -160,6 +160,38 @@ DEFINE_EVENT(softirq, softirq_raise,
 	TP_ARGS(vec_nr)
 );
 
+TRACE_EVENT(tasklet_entry,
+
+	TP_PROTO(void *func),
+
+	TP_ARGS(func),
+
+	TP_STRUCT__entry(
+		__field(        void *,    func          )
+	),
+
+	TP_fast_assign(
+	__entry->func = func;
+	),
+
+	TP_printk("function=%ps", __entry->func)
+);
+TRACE_EVENT(tasklet_exit,
+
+	TP_PROTO(void *func),
+
+	TP_ARGS(func),

include/trace/events/irq.h DEFINE_EVENT(softirq, softirq_raise, · line 193

Quoted 10 lines
include/trace/events/irq.h +10 -0
+
+	TP_STRUCT__entry(
+		__field(        void *,    func          )
+	),
+
+	TP_fast_assign(
+		__entry->func = func;
+	),
+
+	TP_printk("function=%ps", __entry->func)

This needs an acked-by from Thomas, but regardless, the above two trace events are identical. You need to have a DECLARE_EVENT_CLASS() followed by two DEFINE_EVENT()s, otherwise you are wasting memory.

-- Steve

Quoted 23 lines
include/trace/events/irq.h +1 -0
+);
 #endif /*  _TRACE_IRQ_H */
 
 /* This part must be outside protection */
kernel/softirq.c +4 -0
index 41f470929e99..b3bce2b3b655 100644
@@ -780,10 +780,14 @@ static void tasklet_action_common(struct softirq_action *a,
 		if (tasklet_trylock(t)) {
 			if (!atomic_read(&t->count)) {
 				if (tasklet_clear_sched(t)) {
+					trace_tasklet_entry(t->use_callback ? (void *)t->callback 
+							: (void *)t->func);
 					if (t->use_callback)
 						t->callback(t);
 					else
 						t->func(t->data);
+					trace_tasklet_exit(t->use_callback ? (void *)t->callback
+							: (void *)t->func);
 				}
 				tasklet_unlock(t);
 				continue;
maintainer
#2 lore raw
Quoted 4 lines · On Sat, 28 May 2022 13:54:11 +0000 Junwen Wu <[email protected]> wrote:
Quoted 1 line

From 68d2298372018ec90c8587d5421a0e1a3c9f879f Mon Sep 17 00:00:00 2001

From: Junwen Wu <[email protected]>
Date: Sun, 8 May 2022 15:29:56 +0000
Subject: [PATCH v2] softirq: Add tracepoint for tasklet_entry/exit

You should always send a v2 as a separate email starting a new thread.

Quoted 7 lines

Usually softirq handler is pre-defined,only tasklet can be register by driver.We expand tracepoint for tasklet_entry/exit to trace tasklet handler.

---

And reference v1 here, by something like:

Changes since v1: https://lore.kernel.org/all/[email protected]/

- Used DECLARE_EVENT_CLASS (Steven Rostedt)

Quoted 3 lines
 include/trace/events/irq.h | 41 ++++++++++++++++++++++++++++++++++++++
 kernel/softirq.c           |  4 ++++
 2 files changed, 45 insertions(+)

-- Steve