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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED7D3C433EF for ; Tue, 9 Nov 2021 12:09:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5C3061152 for ; Tue, 9 Nov 2021 12:09:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240242AbhKIMMV (ORCPT ); Tue, 9 Nov 2021 07:12:21 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:18529 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241399AbhKIMMP (ORCPT ); Tue, 9 Nov 2021 07:12:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1636459770; x=1667995770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wibJ7XHVuZ+6iwinPjJS/TIrz46zXgv6aJtkV5FrU90=; b=PnBHDLc/05SPVbG23chrpYBsU9AVNc3is+uCD1CRImEKllg+v++JhN8V jcFPZaq8Ju5Rtvnk4srWxUzDF4Q7RCyp7ecHhRj/Og9myhJ0AQsCRRHJN 59lifatFX515/X1taHQz5WQ1PQOzeTND+xN42CUgAqzGWuFGTP+u554k8 M=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 09 Nov 2021 04:09:30 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 04:09:29 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Tue, 9 Nov 2021 04:09:29 -0800 Received: from blr-ubuntu-253.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Tue, 9 Nov 2021 04:09:24 -0800 From: Sai Prakash Ranjan To: Will Deacon , , Catalin Marinas , CC: Marc Zyngier , , , , , , , , , "Sai Prakash Ranjan" Subject: [PATCHv3 3/3] dynamic_debug: Add a flag for dynamic event tracing Date: Tue, 9 Nov 2021 17:38:21 +0530 Message-ID: <3706af20bc64a320ff8f3ff8950738b988f4bdf5.1636452784.git.quic_saipraka@quicinc.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Debugging a specific driver or subsystem can be a lot easier if we can trace events specific to that driver or subsystem. This type of filtering can be achieved using existing dynamic debug library which provides a way to filter based on files, functions and modules. Using this, provide an additional flag 'e' to filter event tracing to specified input. For example, tracing all MMIO read/write can be overwhelming and of no use when debugging a specific driver or a subsystem. So switch to dynamic event tracing for register accesses. Example: Tracing register accesses for all drivers in drivers/soc/qcom/* and the trace output is given below: # dyndbg="file drivers/soc/qcom/* +e" trace_event=rwmmio or # echo "file drivers/soc/qcom/* +e" > /sys/kernel/debug/dynamic_debug/control # cat /sys/kernel/debug/tracing/trace rwmmio_read: rpmh_rsc_probe+0x35c/0x410 readl addr=0xffff80001071000c rwmmio_read: rpmh_rsc_probe+0x3d0/0x410 readl addr=0xffff800010710004 rwmmio_write: rpmh_rsc_probe+0x3b0/0x410 writel addr=0xffff800010710d00 val=0x3 rwmmio_write: write_tcs_cmd+0x6c/0x78 writel addr=0xffff800010710d30 val=0x10108 Cc: Jason Baron Signed-off-by: Sai Prakash Ranjan --- include/linux/dynamic_debug.h | 1 + include/linux/mmio-instrumented.h | 29 +++++++++++++++++++++++++++-- lib/dynamic_debug.c | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..80a1ae234a3b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,6 +32,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) +#define _DPRINTK_FLAGS_EVENT (1<<5) #define _DPRINTK_FLAGS_INCL_ANY \ (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ diff --git a/include/linux/mmio-instrumented.h b/include/linux/mmio-instrumented.h index 4304224f3be4..4ff5af4bbee8 100644 --- a/include/linux/mmio-instrumented.h +++ b/include/linux/mmio-instrumented.h @@ -6,6 +6,7 @@ #ifndef _LINUX_MMIO_INSTRUMENTED_H #define _LINUX_MMIO_INSTRUMENTED_H +#include #include /* @@ -25,7 +26,7 @@ void log_read_mmio(const char *width, const volatile void __iomem *addr); #define __raw_write(v, a, _l) ({ \ volatile void __iomem *_a = (a); \ if (tracepoint_enabled(rwmmio_write)) \ - log_write_mmio(__stringify(write##_l), v, _a); \ + dynamic_log_write_mmio(__stringify(write##_l), v, _a);\ arch_raw_write##_l((v), _a); \ }) @@ -38,7 +39,7 @@ void log_read_mmio(const char *width, const volatile void __iomem *addr); _t __a; \ const volatile void __iomem *_a = (a); \ if (tracepoint_enabled(rwmmio_read)) \ - log_read_mmio(__stringify(read##_l), _a); \ + dynamic_log_read_mmio(__stringify(read##_l), _a);\ __a = arch_raw_read##_l(_a); \ __a; \ }) @@ -48,6 +49,26 @@ void log_read_mmio(const char *width, const volatile void __iomem *addr); #define __raw_readl(a) __raw_read((a), l, u32) #define __raw_readq(a) __raw_read((a), q, u64) +#if defined(CONFIG_DYNAMIC_DEBUG) +#define dynamic_log_write_mmio(width, value, addr) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, width); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_EVENT)) \ + log_write_mmio(width, value, addr); \ +} while (0) + +#define dynamic_log_read_mmio(width, addr) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, width); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_EVENT)) \ + log_read_mmio(width, addr); \ +} while (0) + +#else +#define dynamic_log_write_mmio(width, val, addr) log_write_mmio(width, val, addr) +#define dynamic_log_read_mmio(width, addr) log_read_mmio(width, addr) +#endif /* CONFIG_DYNAMIC_DEBUG */ + #else #define __raw_writeb(v, a) arch_raw_writeb(v, a) @@ -64,6 +85,10 @@ static inline void log_write_mmio(const char *width, u64 val, volatile void __iomem *addr) {} static inline void log_read_mmio(const char *width, const volatile void __iomem *addr) {} +static inline void dynamic_log_write_mmio(const char *width, u64 val, + volatile void __iomem *addr) {} +static inline void dynamic_log_read_mmio(const char *width, + const volatile void __iomem *addr) {} #endif /* CONFIG_TRACE_MMIO_ACCESS */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dd7f56af9aed..a852073089d9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -87,6 +87,7 @@ static inline const char *trim_prefix(const char *path) static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_EVENT, 'e' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, -- 2.29.0 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF325C433EF for ; Tue, 9 Nov 2021 12:12:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A154C6103D for ; Tue, 9 Nov 2021 12:12:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A154C6103D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KOzn6lqjzI8+0a4RoueEMKuJ7p2+5qMLhPaVx9repK4=; b=J2mldDWKngx86z EJIG/4ExfIvVpkls86jb5n89omAQSz2vcRX32UmlAZoYRuVQS3QWoxyrVA/OK5zykeM4kDQNCdZYn aReKxtv1rXAAUG8OC2hFJfKkdFRaF/QcOxxGdOXdd/TVAAghX+CVTGCMGklaRXMIEpbp50YfMBMvJ LNLgeMfReRvbg2KgP007owi8GDWGPcz9djUBf4K9HBXeYbFispQ6YOE2o37CluaxXbPbOO7Cu98lb 0pB9c6yjWodY2tNidPBrnrAnVvbsH28uMjgmNeBE9b39oSYNfIwXNqIqRg2H7G9fDPYo6q0c48e4O WWOCDJZlfkINCU5zJEcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkPxX-001vrx-5b; Tue, 09 Nov 2021 12:10:39 +0000 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkPwQ-001vPU-5M for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 12:09:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1636459770; x=1667995770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wibJ7XHVuZ+6iwinPjJS/TIrz46zXgv6aJtkV5FrU90=; b=PnBHDLc/05SPVbG23chrpYBsU9AVNc3is+uCD1CRImEKllg+v++JhN8V jcFPZaq8Ju5Rtvnk4srWxUzDF4Q7RCyp7ecHhRj/Og9myhJ0AQsCRRHJN 59lifatFX515/X1taHQz5WQ1PQOzeTND+xN42CUgAqzGWuFGTP+u554k8 M=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 09 Nov 2021 04:09:30 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 04:09:29 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Tue, 9 Nov 2021 04:09:29 -0800 Received: from blr-ubuntu-253.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Tue, 9 Nov 2021 04:09:24 -0800 From: Sai Prakash Ranjan To: Will Deacon , , Catalin Marinas , CC: Marc Zyngier , , , , , , , , , "Sai Prakash Ranjan" Subject: [PATCHv3 3/3] dynamic_debug: Add a flag for dynamic event tracing Date: Tue, 9 Nov 2021 17:38:21 +0530 Message-ID: <3706af20bc64a320ff8f3ff8950738b988f4bdf5.1636452784.git.quic_saipraka@quicinc.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_040930_310261_6A58643F X-CRM114-Status: GOOD ( 16.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Debugging a specific driver or subsystem can be a lot easier if we can trace events specific to that driver or subsystem. This type of filtering can be achieved using existing dynamic debug library which provides a way to filter based on files, functions and modules. Using this, provide an additional flag 'e' to filter event tracing to specified input. For example, tracing all MMIO read/write can be overwhelming and of no use when debugging a specific driver or a subsystem. So switch to dynamic event tracing for register accesses. Example: Tracing register accesses for all drivers in drivers/soc/qcom/* and the trace output is given below: # dyndbg="file drivers/soc/qcom/* +e" trace_event=rwmmio or # echo "file drivers/soc/qcom/* +e" > /sys/kernel/debug/dynamic_debug/control # cat /sys/kernel/debug/tracing/trace rwmmio_read: rpmh_rsc_probe+0x35c/0x410 readl addr=0xffff80001071000c rwmmio_read: rpmh_rsc_probe+0x3d0/0x410 readl addr=0xffff800010710004 rwmmio_write: rpmh_rsc_probe+0x3b0/0x410 writel addr=0xffff800010710d00 val=0x3 rwmmio_write: write_tcs_cmd+0x6c/0x78 writel addr=0xffff800010710d30 val=0x10108 Cc: Jason Baron Signed-off-by: Sai Prakash Ranjan --- include/linux/dynamic_debug.h | 1 + include/linux/mmio-instrumented.h | 29 +++++++++++++++++++++++++++-- lib/dynamic_debug.c | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..80a1ae234a3b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,6 +32,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) +#define _DPRINTK_FLAGS_EVENT (1<<5) #define _DPRINTK_FLAGS_INCL_ANY \ (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ diff --git a/include/linux/mmio-instrumented.h b/include/linux/mmio-instrumented.h index 4304224f3be4..4ff5af4bbee8 100644 --- a/include/linux/mmio-instrumented.h +++ b/include/linux/mmio-instrumented.h @@ -6,6 +6,7 @@ #ifndef _LINUX_MMIO_INSTRUMENTED_H #define _LINUX_MMIO_INSTRUMENTED_H +#include #include /* @@ -25,7 +26,7 @@ void log_read_mmio(const char *width, const volatile void __iomem *addr); #define __raw_write(v, a, _l) ({ \ volatile void __iomem *_a = (a); \ if (tracepoint_enabled(rwmmio_write)) \ - log_write_mmio(__stringify(write##_l), v, _a); \ + dynamic_log_write_mmio(__stringify(write##_l), v, _a);\ arch_raw_write##_l((v), _a); \ }) @@ -38,7 +39,7 @@ void log_read_mmio(const char *width, const volatile void __iomem *addr); _t __a; \ const volatile void __iomem *_a = (a); \ if (tracepoint_enabled(rwmmio_read)) \ - log_read_mmio(__stringify(read##_l), _a); \ + dynamic_log_read_mmio(__stringify(read##_l), _a);\ __a = arch_raw_read##_l(_a); \ __a; \ }) @@ -48,6 +49,26 @@ void log_read_mmio(const char *width, const volatile void __iomem *addr); #define __raw_readl(a) __raw_read((a), l, u32) #define __raw_readq(a) __raw_read((a), q, u64) +#if defined(CONFIG_DYNAMIC_DEBUG) +#define dynamic_log_write_mmio(width, value, addr) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, width); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_EVENT)) \ + log_write_mmio(width, value, addr); \ +} while (0) + +#define dynamic_log_read_mmio(width, addr) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, width); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_EVENT)) \ + log_read_mmio(width, addr); \ +} while (0) + +#else +#define dynamic_log_write_mmio(width, val, addr) log_write_mmio(width, val, addr) +#define dynamic_log_read_mmio(width, addr) log_read_mmio(width, addr) +#endif /* CONFIG_DYNAMIC_DEBUG */ + #else #define __raw_writeb(v, a) arch_raw_writeb(v, a) @@ -64,6 +85,10 @@ static inline void log_write_mmio(const char *width, u64 val, volatile void __iomem *addr) {} static inline void log_read_mmio(const char *width, const volatile void __iomem *addr) {} +static inline void dynamic_log_write_mmio(const char *width, u64 val, + volatile void __iomem *addr) {} +static inline void dynamic_log_read_mmio(const char *width, + const volatile void __iomem *addr) {} #endif /* CONFIG_TRACE_MMIO_ACCESS */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dd7f56af9aed..a852073089d9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -87,6 +87,7 @@ static inline const char *trim_prefix(const char *path) static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_EVENT, 'e' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, -- 2.29.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel