Skip to content

Commit f4bf3ca

Browse files
Lingutla ChandrasekharKAGA-KOKO
authored andcommitted
softirq: Add trace points for tasklet entry/exit
Tasklets are supposed to finish their work quickly and should not block the current running process, but it is not guaranteed that they do so. Currently softirq_entry/exit can be used to analyse the total tasklets execution time, but that's not helpful to track individual tasklets execution time. That makes it hard to identify tasklet functions, which take more time than expected. Add tasklet_entry/exit trace point support to track individual tasklet execution. Trivial usage example: # echo 1 > /sys/kernel/debug/tracing/events/irq/tasklet_entry/enable # echo 1 > /sys/kernel/debug/tracing/events/irq/tasklet_exit/enable # cat /sys/kernel/debug/tracing/trace # tracer: nop # # entries-in-buffer/entries-written: 4/4 #P:4 # # _-----=> irqs-off/BH-disabled # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / _-=> migrate-disable # |||| / delay # TASK-PID CPU# ||||| TIMESTAMP FUNCTION # | | | ||||| | | <idle>-0 [003] ..s1. 314.011428: tasklet_entry: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func <idle>-0 [003] ..s1. 314.011432: tasklet_exit: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func <idle>-0 [003] ..s1. 314.017369: tasklet_entry: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func <idle>-0 [003] ..s1. 314.017371: tasklet_exit: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func Signed-off-by: Lingutla Chandrasekhar <[email protected]> Signed-off-by: J. Avila <[email protected]> Signed-off-by: John Stultz <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Steven Rostedt (Google) <[email protected]> Link: https://lore.kernel.org/r/[email protected] [elavila: Port to android-mainline] [jstultz: Rebased to upstream, cut unused trace points, added comments for the tracepoints, reworded commit]
1 parent 7e364e5 commit f4bf3ca

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

include/trace/events/irq.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,53 @@ DEFINE_EVENT(softirq, softirq_raise,
160160
TP_ARGS(vec_nr)
161161
);
162162

163+
DECLARE_EVENT_CLASS(tasklet,
164+
165+
TP_PROTO(struct tasklet_struct *t, void *func),
166+
167+
TP_ARGS(t, func),
168+
169+
TP_STRUCT__entry(
170+
__field( void *, tasklet)
171+
__field( void *, func)
172+
),
173+
174+
TP_fast_assign(
175+
__entry->tasklet = t;
176+
__entry->func = func;
177+
),
178+
179+
TP_printk("tasklet=%ps function=%ps", __entry->tasklet, __entry->func)
180+
);
181+
182+
/**
183+
* tasklet_entry - called immediately before the tasklet is run
184+
* @t: tasklet pointer
185+
* @func: tasklet callback or function being run
186+
*
187+
* Used to find individual tasklet execution time
188+
*/
189+
DEFINE_EVENT(tasklet, tasklet_entry,
190+
191+
TP_PROTO(struct tasklet_struct *t, void *func),
192+
193+
TP_ARGS(t, func)
194+
);
195+
196+
/**
197+
* tasklet_exit - called immediately after the tasklet is run
198+
* @t: tasklet pointer
199+
* @func: tasklet callback or function being run
200+
*
201+
* Used to find individual tasklet execution time
202+
*/
203+
DEFINE_EVENT(tasklet, tasklet_exit,
204+
205+
TP_PROTO(struct tasklet_struct *t, void *func),
206+
207+
TP_ARGS(t, func)
208+
);
209+
163210
#endif /* _TRACE_IRQ_H */
164211

165212
/* This part must be outside protection */

kernel/softirq.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,15 @@ static void tasklet_action_common(struct softirq_action *a,
793793
if (tasklet_trylock(t)) {
794794
if (!atomic_read(&t->count)) {
795795
if (tasklet_clear_sched(t)) {
796-
if (t->use_callback)
796+
if (t->use_callback) {
797+
trace_tasklet_entry(t, t->callback);
797798
t->callback(t);
798-
else
799+
trace_tasklet_exit(t, t->callback);
800+
} else {
801+
trace_tasklet_entry(t, t->func);
799802
t->func(t->data);
803+
trace_tasklet_exit(t, t->func);
804+
}
800805
}
801806
tasklet_unlock(t);
802807
continue;

0 commit comments

Comments
 (0)