From 9889f08de4a1c81f8ba50e26b6d94bed921b3daf Mon Sep 17 00:00:00 2001 From: Lingutla Chandrasekhar Date: Fri, 1 Mar 2019 17:17:09 +0530 Subject: [PATCH] ANDROID: trace: 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. Currently softirq_entry/exit can be used to know total tasklets execution time, but not helpful to track individual tasklet's execution time. With that we can't find any culprit tasklet function, which is taking more time. Add {hi}-tasklet_entry/exit trace point support to track individual tasklet execution. Bug: 168521633 Change-Id: I3496d15f64d020916774e673ccb4a8116ea2f2c9 Signed-off-by: Lingutla Chandrasekhar [elavila: Port to mainline] Signed-off-by: J. Avila --- include/trace/events/irq.h | 45 ++++++++++++++++++++++++++++++++++++++ kernel/softirq.c | 9 ++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h index eeceafaaea4c..bb70f46656b2 100644 --- a/include/trace/events/irq.h +++ b/include/trace/events/irq.h @@ -160,6 +160,51 @@ DEFINE_EVENT(softirq, softirq_raise, TP_ARGS(vec_nr) ); +DECLARE_EVENT_CLASS(tasklet, + + 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) +); + +DEFINE_EVENT(tasklet, tasklet_entry, + + TP_PROTO(void *func), + + TP_ARGS(func) +); + +DEFINE_EVENT(tasklet, tasklet_exit, + + TP_PROTO(void *func), + + TP_ARGS(func) +); + +DEFINE_EVENT(tasklet, tasklet_hi_entry, + + TP_PROTO(void *func), + + TP_ARGS(func) +); + +DEFINE_EVENT(tasklet, tasklet_hi_exit, + + TP_PROTO(void *func), + + TP_ARGS(func) +); + #endif /* _TRACE_IRQ_H */ /* This part must be outside protection */ diff --git a/kernel/softirq.c b/kernel/softirq.c index 438c0e8f45e9..86e549d5dc23 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -559,10 +559,15 @@ static void tasklet_action_common(struct softirq_action *a, if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state)) BUG(); - if (t->use_callback) + if (t->use_callback) { + trace_tasklet_entry(t->callback); t->callback(t); - else + trace_tasklet_exit(t->callback); + } else { + trace_tasklet_entry(t->func); t->func(t->data); + trace_tasklet_exit(t->func); + } tasklet_unlock(t); continue; }