From nobody Mon Apr 6 23:08:41 2026 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 91A43ECAAD3 for ; Thu, 1 Sep 2022 10:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233516AbiIAKtO (ORCPT ); Thu, 1 Sep 2022 06:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbiIAKtM (ORCPT ); Thu, 1 Sep 2022 06:49:12 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4432311EB77 for ; Thu, 1 Sep 2022 03:49:11 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJHkc5llwzkWnM; Thu, 1 Sep 2022 18:45:28 +0800 (CST) Received: from dggpemm500016.china.huawei.com (7.185.36.25) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 18:49:09 +0800 Received: from huawei.com (10.67.175.41) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 18:49:09 +0800 From: Yipeng Zou To: , , , , , , CC: , , Subject: [PATCH 1/2] tracing: hold caller_addr to hardirq_{enable,disable}_ip Date: Thu, 1 Sep 2022 18:45:14 +0800 Message-ID: <20220901104515.135162-2-zouyipeng@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220901104515.135162-1-zouyipeng@huawei.com> References: <20220901104515.135162-1-zouyipeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.175.41] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, The arguments passing to lockdep_hardirqs_{on,off} was fixed in CALLER_ADDR0. The function trace_hardirqs_on_caller should have been intended to use caller_addr to represent the address that caller wants to be traced. For example, lockdep log in riscv showing the last {enabled,disabled} at __trace_hardirqs_{on,off} all the time(if called by): [ 57.853175] hardirqs last enabled at (2519): __trace_hardirqs_on+0xc/0x= 14 [ 57.853848] hardirqs last disabled at (2520): __trace_hardirqs_off+0xc/0= x14 After use trace_hardirqs_xx_caller, we can get more effective information: [ 53.781428] hardirqs last enabled at (2595): restore_all+0xe/0x66 [ 53.782185] hardirqs last disabled at (2596): ret_from_exception+0xa/0x10 Signed-off-by: Yipeng Zou --- kernel/trace/trace_preemptirq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptir= q.c index 95b58bd757ce..1e130da1b742 100644 --- a/kernel/trace/trace_preemptirq.c +++ b/kernel/trace/trace_preemptirq.c @@ -95,14 +95,14 @@ __visible void trace_hardirqs_on_caller(unsigned long c= aller_addr) } =20 lockdep_hardirqs_on_prepare(); - lockdep_hardirqs_on(CALLER_ADDR0); + lockdep_hardirqs_on(caller_addr); } EXPORT_SYMBOL(trace_hardirqs_on_caller); NOKPROBE_SYMBOL(trace_hardirqs_on_caller); =20 __visible void trace_hardirqs_off_caller(unsigned long caller_addr) { - lockdep_hardirqs_off(CALLER_ADDR0); + lockdep_hardirqs_off(caller_addr); =20 if (!this_cpu_read(tracing_irq_cpu)) { this_cpu_write(tracing_irq_cpu, 1); --=20 2.17.1 From nobody Mon Apr 6 23:08:41 2026 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 8F844ECAAD1 for ; Thu, 1 Sep 2022 10:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233881AbiIAKtV (ORCPT ); Thu, 1 Sep 2022 06:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233226AbiIAKtN (ORCPT ); Thu, 1 Sep 2022 06:49:13 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34B8D11EB7F for ; Thu, 1 Sep 2022 03:49:12 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJHjn4GCFzYcys; Thu, 1 Sep 2022 18:44:45 +0800 (CST) Received: from dggpemm500016.china.huawei.com (7.185.36.25) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 18:49:10 +0800 Received: from huawei.com (10.67.175.41) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 18:49:10 +0800 From: Yipeng Zou To: , , , , , , CC: , , Subject: [PATCH 2/2] riscv: tracing: Improve hardirq tracing message Date: Thu, 1 Sep 2022 18:45:15 +0800 Message-ID: <20220901104515.135162-3-zouyipeng@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220901104515.135162-1-zouyipeng@huawei.com> References: <20220901104515.135162-1-zouyipeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.175.41] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use trace_hardirqs_on_caller to improve irq_tracing message. lockdep log in riscv showing the last {enabled,disabled} at __trace_hardirqs_{on,off} all the time(if called by). But that's not what we want to see, the caller is what we want. Before this commit: [ 57.853175] hardirqs last enabled at (2519): __trace_hardirqs_on+0xc/0x= 14 [ 57.853848] hardirqs last disabled at (2520): __trace_hardirqs_off+0xc/0= x14 After this commit [ 53.781428] hardirqs last enabled at (2595): restore_all+0xe/0x66 [ 53.782185] hardirqs last disabled at (2596): ret_from_exception+0xa/0x10 Signed-off-by: Yipeng Zou --- arch/riscv/kernel/trace_irq.c | 4 ++-- include/linux/irqflags.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/trace_irq.c b/arch/riscv/kernel/trace_irq.c index 095ac976d7da..7ca24b26e19f 100644 --- a/arch/riscv/kernel/trace_irq.c +++ b/arch/riscv/kernel/trace_irq.c @@ -16,12 +16,12 @@ =20 void __trace_hardirqs_on(void) { - trace_hardirqs_on(); + trace_hardirqs_on_caller(CALLER_ADDR0); } NOKPROBE_SYMBOL(__trace_hardirqs_on); =20 void __trace_hardirqs_off(void) { - trace_hardirqs_off(); + trace_hardirqs_off_caller(CALLER_ADDR0); } NOKPROBE_SYMBOL(__trace_hardirqs_off); diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h index 5ec0fa71399e..46774fa85cde 100644 --- a/include/linux/irqflags.h +++ b/include/linux/irqflags.h @@ -53,6 +53,8 @@ extern void trace_hardirqs_on_prepare(void); extern void trace_hardirqs_off_finish(void); extern void trace_hardirqs_on(void); extern void trace_hardirqs_off(void); +extern void trace_hardirqs_on_caller(unsigned long caller_addr); +extern void trace_hardirqs_off_caller(unsigned long caller_addr); =20 # define lockdep_hardirq_context() (raw_cpu_read(hardirq_context)) # define lockdep_softirq_context(p) ((p)->softirq_context) --=20 2.17.1