From patchwork Tue Jan 3 21:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 38657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4820919wrt; Tue, 3 Jan 2023 13:19:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMG0xfZLrA+xaSBAlcznPkbixj/nY1n2z6sPP8qg8mhZsVuIutUwfTE+nperIpyLo7rNDs X-Received: by 2002:a17:90a:d18b:b0:226:8005:c43a with SMTP id fu11-20020a17090ad18b00b002268005c43amr7120171pjb.23.1672780783061; Tue, 03 Jan 2023 13:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672780783; cv=none; d=google.com; s=arc-20160816; b=gU2oku3sso8arlORaA7wR4XpboaeP1c9IMF3PndJpUnU6ahW2+2ESzFT3YXNNdbA7l EmmroUnvhHQpYO17dSEZQgOwurGAjwfCaQ2HolFOXr/kHOOAnm5FRmzrcdpIFQO6UKIK sc/gY+25deqepT1UbkmjdTGjieVtE0Uiy6U+sA0a1LzruEprphP32gU/BopVNU0ObSp+ Q/UjgyfxBU3fZjhO1YR6Fnb4J3WG5ond7McPvczMTtdgfjrXsQyyGCVK8AIsqamLK9Oe B8wiZ3NkogteiAyUD8Ppjk3XbmhbEtoNDs++QPR/iq08I1qaMY6I0D1KZQn5nI53K1nw 4Jcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ANpneqDCJ+3KDxQkFjUAT/0LVWtajW2dqlpEiVRJX78=; b=W5bCYWCpGtf817a1FAY7haUz5M2a8RjBCTeUA9uHUvt9wxCa6TdZY3KXRr1je7nMre /CmUpEC8/hKX3drMjAvyjiUnnVTsjiDBIfMCdSAxLiGe6CJwV4Ba1hurXC1hVLkk+ic7 2B5n64vP6ww60kZjkjpql0nYLOVGPmVUUI7jnWnbPVNcrArC06d+KDUWrTqCVHfx/5nz BjHdjtxK698Pfq6J5cUbN8TL6SafIwpRs9ddYNZOdYRJ7IAoCHej+G2ViyUhV1yd5kst hEvlYXFRG/Qb8itIRNH5t0w6fkFVqdBqrPfhyBKEmWTMezNiEh6mmRQGj+Jfpd2wmD0L 4/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Pvg1wppJ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om14-20020a17090b3a8e00b00219c691992esi35160854pjb.131.2023.01.03.13.19.30; Tue, 03 Jan 2023 13:19:43 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=Pvg1wppJ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231226AbjACVJx (ORCPT + 99 others); Tue, 3 Jan 2023 16:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjACVJv (ORCPT ); Tue, 3 Jan 2023 16:09:51 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB9014D3B for ; Tue, 3 Jan 2023 13:09:49 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id n190-20020a25dac7000000b007447d7a25e4so31145164ybf.9 for ; Tue, 03 Jan 2023 13:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ANpneqDCJ+3KDxQkFjUAT/0LVWtajW2dqlpEiVRJX78=; b=Pvg1wppJZjphjhVqhO4J2TPpxFkdSWTgKMmeH0BKOHsuygBXm2vWF7hueOOYSYCSjk uC2F88QoX9eqkruEZnO+f55CKVsGBkkiYIaeM80M0fk18cSJxBskzD0UI9lb4b9hs9SZ ki5tIy4tJRzzJsHYjcTndIdIXU5cN+BZSSeABj5ET+bucob2VW88IEhHc+2xW/ASK5a5 30ceE47WYlSktl++FWoyUJatifclk3bmBuNGDDzWLT8EJlvum53QNbPeiSsJEhUZTPu6 qHDastODrUkdwLlLt+m7Ac12FbK+/dD5aimCTFh2mRxBq7y5YLt9govY4THwFuFqgBMZ euwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ANpneqDCJ+3KDxQkFjUAT/0LVWtajW2dqlpEiVRJX78=; b=DEzfnOY4irWWoiMuxTl8kAWkli95smMyB4qypQP5NnE+jrfkeVhYPYsYGH56MAoHNR bW0Z+29EV6L9sl+ynxm+D1MHT3esx34xXYxmDfuK5bl1ovvnOPci4xjzu9kiIkgpAGdK iP5hn43oIkTPjzA+kYjcSdb7YZs7v03890jln1lYXc2FJBtSQB7D2s57lO+pyqM1lpal SqEHWdhGeJJzcvMs0IkJgDpAs0MUjkPhzYsKLtAsKHr1LJHiiRoHQOJJfuxExvz9sxCf nZlz+q6a4cYgYooFjWBb3Heo6qd+jTbpDZm/zDM7w51eRAW9XRdKEay/qHjLz099Ahhx iSQA== X-Gm-Message-State: AFqh2ko/lXZH+6VMmosVfGaM3Uk1ZdolNQ192guLpkCS229B87b1HxPI NYi1G6pigJVYr3xzf0xzfUd/y4QIi3Ak/G2Vdk1FZ24rzLJBG/27WUUpFnkwdoGWgQQS7/e/cWV lLC8WhnNFKlZs5SBT2s8eOFDLfPepH/ShXYdCWaL96BSKEN6IlnpUHFbD93Fq1aVh+83Hd5Y= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a25:452:0:b0:713:a3c8:7baf with SMTP id 79-20020a250452000000b00713a3c87bafmr5283850ybe.641.1672780189166; Tue, 03 Jan 2023 13:09:49 -0800 (PST) Date: Tue, 3 Jan 2023 21:09:33 +0000 In-Reply-To: <20230103151554.5c0a6c6f@gandalf.local.home> Mime-Version: 1.0 References: <20230103151554.5c0a6c6f@gandalf.local.home> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230103210933.2979081-1-jstultz@google.com> Subject: [PATCH v2] trace: Add trace points for tasklet entry/exit From: John Stultz To: LKML Cc: Lingutla Chandrasekhar , Steven Rostedt , Masami Hiramatsu , Thomas Gleixner , "Paul E. McKenney" , "Connor O'Brien" , kernel-team@android.com, "J . Avila" , John Stultz X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754029537324249610?= X-GMAIL-MSGID: =?utf-8?q?1754037782165247683?= 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 --- v2: * Added tasklet pointer to the trace event as suggested by Steven --- include/trace/events/irq.h | 47 ++++++++++++++++++++++++++++++++++++++ kernel/softirq.c | 9 ++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h index eeceafaaea4c..a07b4607b663 100644 --- a/include/trace/events/irq.h +++ b/include/trace/events/irq.h @@ -160,6 +160,53 @@ DEFINE_EVENT(softirq, softirq_raise, TP_ARGS(vec_nr) ); +DECLARE_EVENT_CLASS(tasklet, + + TP_PROTO(struct tasklet_struct *t, void *func), + + TP_ARGS(t, func), + + TP_STRUCT__entry( + __field( void *, tasklet) + __field( void *, func) + ), + + TP_fast_assign( + __entry->tasklet = t; + __entry->func = func; + ), + + TP_printk("tasklet=%ps function=%ps", __entry->tasklet, __entry->func) +); + +/** + * tasklet_entry - called immediately before the tasklet is run + * @t: tasklet pointer + * @func: tasklet callback or function being run + * + * Used to find individual tasklet execution time + */ +DEFINE_EVENT(tasklet, tasklet_entry, + + TP_PROTO(struct tasklet_struct *t, void *func), + + TP_ARGS(t, func) +); + +/** + * tasklet_exit - called immediately after the tasklet is run + * @t: tasklet pointer + * @func: tasklet callback or function being run + * + * Used to find individual tasklet execution time + */ +DEFINE_EVENT(tasklet, tasklet_exit, + + TP_PROTO(struct tasklet_struct *t, void *func), + + TP_ARGS(t, func) +); + #endif /* _TRACE_IRQ_H */ /* This part must be outside protection */ diff --git a/kernel/softirq.c b/kernel/softirq.c index c8a6913c067d..1b725510dd0f 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, t->callback); t->callback(t); - else + trace_tasklet_exit(t, t->callback); + } else { + trace_tasklet_entry(t, t->func); t->func(t->data); + trace_tasklet_exit(t, t->func); + } } tasklet_unlock(t); continue;