From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B375AC433F5 for ; Wed, 25 May 2022 01:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242957AbiEYBHU (ORCPT ); Tue, 24 May 2022 21:07:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242741AbiEYBHO (ORCPT ); Tue, 24 May 2022 21:07:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E159A62BC0 for ; Tue, 24 May 2022 18:07:12 -0700 (PDT) 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 3E78660B7D for ; Wed, 25 May 2022 01:07:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6717C34100; Wed, 25 May 2022 01:07:10 +0000 (UTC) Date: Tue, 24 May 2022 21:07:09 -0400 From: Steven Rostedt To: Junwen Wu Cc: mingo@redhat.com, tglx@linutronix.de, frederic@kernel.org, tannerlove@google.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] softirq: Add tracepoint for tasklet_entry/exit Message-ID: <20220524210709.3f0ddc3a@gandalf.local.home> In-Reply-To: <20220508160624.48643-1-wudaemon@163.com> References: <20220508160624.48643-1-wudaemon@163.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 8 May 2022 16:06:24 +0000 Junwen Wu wrote: > --- a/include/trace/events/irq.h > +++ b/include/trace/events/irq.h > @@ -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) 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 > +); > #endif /* _TRACE_IRQ_H */ > > /* This part must be outside protection */ > diff --git a/kernel/softirq.c b/kernel/softirq.c > index 41f470929e99..b3bce2b3b655 100644 > --- a/kernel/softirq.c > +++ b/kernel/softirq.c > @@ -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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47823C433FE for ; Sat, 28 May 2022 13:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236173AbiE1Nzd (ORCPT ); Sat, 28 May 2022 09:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235945AbiE1Nzb (ORCPT ); Sat, 28 May 2022 09:55:31 -0400 Received: from m12-16.163.com (m12-16.163.com [220.181.12.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B63E7283 for ; Sat, 28 May 2022 06:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=GsSYc +fe6QdvZyYkZ6XY8VfsUlV3aCJmso5J7Wnq8n8=; b=cnm9VPEpBN2pmgJOlRk9G zZ1YxCxw+M2ee5r7QXIO2ygxIjVcWMa+6JFW8ZxRdS67xx2BqzFw/FWEp0MWUuTQ mSXFTj2daDiFxEbT9vWvQPOmtdLz3xreg5IRdIAWUVO0iKTUKraAkvD4i8RDrV/u m+iI9LJLqTIbd+BnJKDI4o= Received: from localhost (unknown [113.89.247.110]) by smtp12 (Coremail) with SMTP id EMCowABn+1yTKZJirHDyAA--.14079S2; Sat, 28 May 2022 21:54:28 +0800 (CST) From: Junwen Wu To: rostedt@goodmis.org, Junwen Wu Cc: frederic@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tannerlove@google.com, tglx@linutronix.de Subject: Re: [PATCH v1] softirq: Add tracepoint for tasklet_entry/exit Date: Sat, 28 May 2022 13:54:11 +0000 Message-ID: <20220524210709.3f0ddc3a@gandalf.local.home> (raw) X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160624.48643-1-wudaemon@163.com> References: <20220524210709.3f0ddc3a@gandalf.local.home> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: EMCowABn+1yTKZJirHDyAA--.14079S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGrW7Wryxuw4fZF47Wr15urg_yoW5Xw47pa sF9ayYkrZ5Jr42vr13A3WUAr15Zws3GFy7Jrs7W3W3Zw1Uur1kt39rt3WjyFW0yr4F9Fy2 9a1aqry3u34kua7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRLvtXUUUUU= X-Originating-IP: [113.89.247.110] X-CM-SenderInfo: 5zxgtvxprqqiywtou0bp/xtbBxxUPbWB0Hw0dbAAAsH Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Message-ID: <20220528135411.rhT9_o4OOHXPsJCPXi52u-ihO8_dPxmk8NqT5a-O0OU@z> From: Steven Rostedt >> + >> + 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. I have use DECLARE_EVENT_CLASS() define use tracepoint,Steve. Thomas, can you give me acked-by,here is patch v2. >From 68d2298372018ec90c8587d5421a0e1a3c9f879f Mon Sep 17 00:00:00 2001 From: Junwen Wu Date: Sun, 8 May 2022 15:29:56 +0000 Subject: [PATCH v2] 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. Signed-off-by: Junwen Wu --- include/trace/events/irq.h | 41 ++++++++++++++++++++++++++++++++++++++ kernel/softirq.c | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h index eeceafaaea4c..62b7e53121da 100644 --- a/include/trace/events/irq.h +++ b/include/trace/events/irq.h @@ -160,6 +160,47 @@ 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) +); + +/** + * tasklet_entry - called immediately when a tasklet exec + * @func: the callback function when a tasklet exec + * + * When used in combination with the tasklet_entry tracepoint + * we can determine the callback function when a tasklet exec. + */ +DEFINE_EVENT(tasklet, tasklet_entry, + + TP_PROTO(void *func), + + TP_ARGS(func) +); + +/** + * tasklet_exit - called immediately after the tasklet handler returns + * @func: the callback function when a tasklet exec + */ +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 41f470929e99..79b3814ad166 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -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; -- 2.25.1