Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12331339rwl; Tue, 3 Jan 2023 12:40:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXs8+gleUZDPlc1ic2fKn+j31ZbxZU1bKQ849bA0XJP5asRnroIw98qI6Zp7MVJn35vXVSSu X-Received: by 2002:a17:906:32c3:b0:82a:5b57:3fe4 with SMTP id k3-20020a17090632c300b0082a5b573fe4mr39284214ejk.68.1672778404912; Tue, 03 Jan 2023 12:40:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672778404; cv=none; d=google.com; s=arc-20160816; b=lXdB02lMnbaLozK27fmg2UUmuVsyi9N3e4fsv9adufoFjRAKT7q8EUVYSNgiuy4Qel fzMTTXI35rLa3LuKDU5LygxemSDuClvr4TZt7+V7U1J3rfd+zLEN8ci10HnbkGYOtFNE sz0dgoGsl6hXsSQNnrtWxzrLKsYkwvtVU1Qth6tLjLbo20cntLEzViszhg2mtNRg0wXx aJemzn/I8ob4vLd9mg+61tNZbNTm6qm7I0x2H3MXV4ThUgdJiMkyloO5iAztGfDlpsNi T0vxPQ+3MuaObus0kzYYT+3tXNXX0YWP5zhH0ydRb2SPOcjGtlQ7Vx42Vuts5o4pgdyM DEug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=/ACouqs5bsEJQJmYQL3E/mZyXc+3/HndxtXaDX2XmQo=; b=RY0ZbhaOloOwv6uR6PuhrgQr35jkoxIZULPEUt/aAIFId6f1mSe8unPcFzoYGiAwjq 6HPMNHVI6UPyfaci0CZWgTpJrVopvXMsssDs6oTqQ3xJ4otp2fbbZl77n1IyhXUh2jrS Czr9BuAyQXrs7J7xPzPcWfZ8VVah9HEQwh9dSveOhxL+yz5LktEpzr/6n5M/6gykQlVz zASK3mfLKJB97pHoSnwgONicbbyA8he9p5C+jYJ3rxWp3X+b0x0/jzBcgDai4Evfzc3b rdYflSrh20ACQ8xVvqU1z3x2YAI5f5jgyiDk9Sf8jmxbUBsGJx13jQno8tFLjH/7k8Vg VSXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056402084500b00463b0df4604si32898747edz.488.2023.01.03.12.39.50; Tue, 03 Jan 2023 12:40:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238075AbjACUQH (ORCPT + 59 others); Tue, 3 Jan 2023 15:16:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237743AbjACUQA (ORCPT ); Tue, 3 Jan 2023 15:16:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1684E26E1 for ; Tue, 3 Jan 2023 12:15:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 331DB614B4 for ; Tue, 3 Jan 2023 20:15:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8634CC433EF; Tue, 3 Jan 2023 20:15:56 +0000 (UTC) Date: Tue, 3 Jan 2023 15:15:54 -0500 From: Steven Rostedt To: John Stultz Cc: LKML , Lingutla Chandrasekhar , Masami Hiramatsu , Thomas Gleixner , "Paul E. McKenney" , "Connor O'Brien" , kernel-team@android.com, "J . Avila" Subject: Re: [PATCH] trace: Add trace points for tasklet entry/exit Message-ID: <20230103151554.5c0a6c6f@gandalf.local.home> In-Reply-To: <20230103185408.2874345-1-jstultz@google.com> References: <20230103185408.2874345-1-jstultz@google.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Jan 2023 18:54:08 +0000 John Stultz wrote: > From: Lingutla Chandrasekhar > > 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 tasklet_entry/exit trace point support to track > individual tasklet execution. > > This patch has been carried in the Android tree for awhile > so I wanted to submit it for review upstream. Feedback would > be appreciated! > > Cc: Steven Rostedt > Cc: Masami Hiramatsu > Cc: Thomas Gleixner > Cc: "Paul E. McKenney" > Cc: Connor O'Brien > Cc: kernel-team@android.com > Reviewed-by: Steven Rostedt (Google) > Signed-off-by: Lingutla Chandrasekhar > [elavila: Port to android-mainline] > Signed-off-by: J. Avila > [jstultz: Rebased to upstream, cut unused trace points, added > comments for the tracepoints, reworded commit] > Signed-off-by: John Stultz > --- > include/trace/events/irq.h | 43 ++++++++++++++++++++++++++++++++++++++ > kernel/softirq.c | 9 ++++++-- > 2 files changed, 50 insertions(+), 2 deletions(-) > > diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h > index eeceafaaea4c..da85851d4ec1 100644 > --- a/include/trace/events/irq.h > +++ b/include/trace/events/irq.h > @@ -160,6 +160,49 @@ DEFINE_EVENT(softirq, softirq_raise, > TP_ARGS(vec_nr) > ); > > +DECLARE_EVENT_CLASS(tasklet, > + > + TP_PROTO(void *func), > + > + TP_ARGS(func), > + > + TP_STRUCT__entry( Could you also add a pointer to the tasklet too? __field( void *, tasklet) > + __field( void *, func) > + ), > + > + TP_fast_assign( __entry->tasklet = t; > + __entry->func = func; > + ), > + > + TP_printk("function=%ps", __entry->func) This way if we wanted more information, we could use event probes: # echo 'e:tasklet_info tasklet/tasklet_entry state=+8($tasklet):u64' > dynamic_events -- Steve > +); > + > +/** > + * tasklet_entry - called immediately before the tasklet is run > + * @func: tasklet callback or function being run > + * > + * Used to find individual tasklet execution time > + */ > +DEFINE_EVENT(tasklet, tasklet_entry, > + > + TP_PROTO(void *func), > + > + TP_ARGS(func) > +); > + > +/** > + * tasklet_exit - called immediately after the tasklet is run > + * @func: tasklet callback or function being run > + * > + * Used to find individual tasklet execution time > + */ > +DEFINE_EVENT(tasklet, tasklet_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 c8a6913c067d..dbd322524171 100644 > --- a/kernel/softirq.c > +++ b/kernel/softirq.c > @@ -793,10 +793,15 @@ static void tasklet_action_common(struct softirq_action *a, > if (tasklet_trylock(t)) { > if (!atomic_read(&t->count)) { > if (tasklet_clear_sched(t)) { > - 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;