Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1557862rwe; Sat, 15 Apr 2023 01:26:42 -0700 (PDT) X-Google-Smtp-Source: AKy350Ydiox2cUgYTPV9SOcJ/Rhhyfbs+W0ShYrML6VMW+HfZXoQ89irMT43bd6rNEvCpuQ6yssZ X-Received: by 2002:a05:6a00:813:b0:63b:7ab1:6c5c with SMTP id m19-20020a056a00081300b0063b7ab16c5cmr2002595pfk.18.1681547202449; Sat, 15 Apr 2023 01:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681547202; cv=none; d=google.com; s=arc-20160816; b=prVVa+i2oHUMStMNUhUpwEQc1oLzKse0ti00KiDHOsjZ2YODvQeL7FPDTTISznffk8 iLDsKMPd25oJI2TXuKCXBYTZEdK1RU0DsQIf6ECE7CU9pcIFcLcJLtl/byMy/pfyOah/ 8oHByBth2ZmLZkahRXwpS4wpq1q4SKTTK7sXPiAU1y1DYOZjKcuntSM6FwoJPcWzgHnc qPHvQUWtEIaMpO9+kfQzWwEM0DZURurzohxTBLyZbhblbmjAOy7CQDSkkWnIY/+i3WEX o8yBLzYoaIeTzBhbZbYk0qPCg86o3fVicRjJbPXA+gydcQMjZKKnx2R7serTYDVd/wyM vcmA== 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 Return-Path: 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.26.31; Sat, 15 Apr 2023 01:26:42 -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 S229841AbjDOIUk (ORCPT + 99 others); Sat, 15 Apr 2023 04:20:40 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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;