From patchwork Sat Apr 15 08:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 83649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp903836vqo; Sat, 15 Apr 2023 01:28:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YnC3W1nMNnykn1KljSxi47q+YZZGUlTBx63M+yy7ta9DkXCoVYY1E9MigpJi1v7YUJ5Tzp X-Received: by 2002:a05:6a20:8e06:b0:ec:6e2d:5a32 with SMTP id y6-20020a056a208e0600b000ec6e2d5a32mr9174302pzj.62.1681547285720; Sat, 15 Apr 2023 01:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681547285; cv=none; d=google.com; s=arc-20160816; b=DSBuvyHu5n/I/tg6NCKXxdtJsbg4C/c0BIEoPGtMoomNw59pyrjdZDYkrAKRfLTdk9 o4cAOYYs+wIik3XUJ0WJ5hoD1na+QtgK2MW7DQNL+UUQVcdsOGgDGVEdipo7gs0DvOBy nI9juPC8Tw/RsmtM6LaL9M3TFG9gu8Mp2i5y2auTsWQ0P75qrd2aVp2xAfKHdePEfq8M py8wNwnSWCHl7wA2+GTH/9Cl8Obcmmsu6WTu+4oGGk+4ZMpNlpIcEZDWiQ/52KXgZ5Tf PHJ9vdFfk6BuEK7MboT+4c0fItcraRrGQ14jZ/0I9nXgL1iuLGQlLz3YTNgI8QJMMmLh yteg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=GnzE4raEONRJxVjFOSpczBdz0wF9vVGe9QBOs99a6Io=; b=clfiqqQZcaTSQevMVJ0QSV/OE/vVnwLwyhOX8AKYjI6Igou7e5dAQfa6T6x+e7H/Jz Q5xwuNGzzmk+3suIjE8DUhOul1TjE8pvv9vYUo+o4cMM1qRuIHJZD/A1gTHIKmuWPrRv FF++CfduMjbjBWnoViZIAfqYk9iB8e6G+eIu9uOQFV8VmhycODUH1LzDWtZ8VBVErSz+ a5dgLxvfNG3ITdOY3SWtNVY/+ANv8+EdLq5lBflDfP3ox6/45dKdg4WgJ1f6c0i1j6gX QUWz8SNnR/JpGc5s57LDgxqPqaz2VDL/wgokgPvbRMqJUoZdV+jc+clK/vtJWrdDSxIZ fZcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jGtfoOqT; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a63f20a000000b0050be7b93e73si1826176pgh.694.2023.04.15.01.27.53; Sat, 15 Apr 2023 01:28:05 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=jGtfoOqT; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjDOIUl (ORCPT + 99 others); Sat, 15 Apr 2023 04:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjDOIUh (ORCPT ); Sat, 15 Apr 2023 04:20:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4785583; Sat, 15 Apr 2023 01:20:35 -0700 (PDT) Date: Sat, 15 Apr 2023 08:20:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1681546833; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GnzE4raEONRJxVjFOSpczBdz0wF9vVGe9QBOs99a6Io=; b=jGtfoOqTGT8E5Do9fHd1GvUZxwj1vrZSvpdg8xhhvfk1ZkNHuvdDBL7jSUFpmYASiIEXyf IySLiUeTf2Rzfx+rXAss+HAwasbhs756hQk3V3qQ1JKN9BVQvFgBmpjEm/OAdypMWk4f/s 7bW8JnUBOF3OELRNJd9bdDT7uBTut4Dnfccmupdjbpk6V2N+luFxw9MsK8qC4d702M32Hu qdPQFlGFxkpkixwN3zosinErKAL71TcI6Jd1OFI2m+uQ8qs4GG//PSuwDhNfILfHDl4VkQ c7iK7mJE+dccbk+FAzcPwq6MbGZxDE5MWqssF32bqu3YoetRkBQ3G1EleXbUIA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1681546833; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GnzE4raEONRJxVjFOSpczBdz0wF9vVGe9QBOs99a6Io=; b=HNTu8wINmM5oDWBgRvFBNfmytR/i8xjyrsXdgYfQfZk/i/IN7rWORDJN+mAMlpD8ydk2Kw j96aB9AjkV/NVRBA== From: "tip-bot2 for Lingutla Chandrasekhar" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] softirq: Add trace points for tasklet entry/exit Cc: Lingutla Chandrasekhar , "J. Avila" , John Stultz , Thomas Gleixner , "Steven Rostedt (Google)" , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20230407230526.1685443-1-jstultz@google.com> References: <20230407230526.1685443-1-jstultz@google.com> MIME-Version: 1.0 Message-ID: <168154683281.404.4623946113472484183.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1763230126930536443?= X-GMAIL-MSGID: =?utf-8?q?1763230126930536443?= The following commit has been merged into the irq/core branch of tip: Commit-ID: f4bf3ca2e5cba655824b6e0893a98dfb33ed24e5 Gitweb: https://git.kernel.org/tip/f4bf3ca2e5cba655824b6e0893a98dfb33ed24e5 Author: Lingutla Chandrasekhar AuthorDate: Fri, 07 Apr 2023 23:05:26 Committer: Thomas Gleixner CommitterDate: Sat, 15 Apr 2023 10:17:16 +02:00 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 # | | | ||||| | | -0 [003] ..s1. 314.011428: tasklet_entry: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func -0 [003] ..s1. 314.011432: tasklet_exit: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func -0 [003] ..s1. 314.017369: tasklet_entry: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func -0 [003] ..s1. 314.017371: tasklet_exit: tasklet=0xffffa01ef8db2740 function=tcp_tasklet_func Signed-off-by: Lingutla Chandrasekhar Signed-off-by: J. Avila Signed-off-by: John Stultz Signed-off-by: Thomas Gleixner Reviewed-by: Steven Rostedt (Google) Link: https://lore.kernel.org/r/20230407230526.1685443-1-jstultz@google.com [elavila: Port to android-mainline] [jstultz: Rebased to upstream, cut unused trace points, added comments for the tracepoints, reworded commit] --- 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 eeceafa..a07b460 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 c8a6913..1b72551 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;