FAILED: patch "[PATCH] asm-generic/io.h: Skip trace helpers if rwmmio events are" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 8327bd4fcb6c1dab01ce5c6ff00b42496836dcd2
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025101544-snoring-unseemly-47ff@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8327bd4fcb6c1dab01ce5c6ff00b42496836dcd2 Mon Sep 17 00:00:00 2001
From: Varad Gautam <[email protected]>
Date: Sun, 30 Mar 2025 16:42:29 +0000
Subject: [PATCH] asm-generic/io.h: Skip trace helpers if rwmmio events are
disabled
With CONFIG_TRACE_MMIO_ACCESS=y, the {read,write}{b,w,l,q}{_relaxed}() mmio accessors unconditionally call log_{post_}{read,write}_mmio() helpers, which in turn call the ftrace ops for rwmmio trace events
This adds a performance penalty per mmio accessor call, even when rwmmio events are disabled at runtime (~80% overhead on local measurement).
Guard these with tracepoint_enabled().
include/asm-generic/io.h +66 -32
@@ -75,6 +75,7 @@#if IS_ENABLED (CONFIG_TRACE_MMIO_ACCESS ) && !(defined(__DISABLE_TRACE_MMIO__))#include <linux/tracepoint-defs.h> +#define rwmmio_tracepoint_enabled (tracepoint) tracepoint_enabled(tracepoint)DECLARE_TRACEPOINT (rwmmio_write);DECLARE_TRACEPOINT (rwmmio_post_write);DECLARE_TRACEPOINT (rwmmio_read);
@@ -91,6 +92,7 @@ void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,#else +#define rwmmio_tracepoint_enabled (tracepoint) falsestatic inline void log_write_mmio (u64 val,u8 width,volatile void __iomem *addr,unsigned long caller_addr,unsigned long caller_addr0) {} static inline void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
@@ -189,11 +191,13 @@ static inline u8 readb(const volatile void __iomem *addr) {u8 val; -log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__raw_readb (addr);__io_ar (val); -log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -204,11 +208,13 @@ static inline u16 readw(const volatile void __iomem *addr) {u16 val; -log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le16_to_cpu ((__le16 __force )__raw_readw (addr));__io_ar (val); -log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -219,11 +225,13 @@ static inline u32 readl(const volatile void __iomem *addr) {u32 val; -log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le32_to_cpu ((__le32 __force )__raw_readl (addr));__io_ar (val); -log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -235,11 +243,13 @@ static inline u64 readq(const volatile void __iomem *addr) {u64 val; -log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le64_to_cpu ((__le64 __force )__raw_readq (addr));__io_ar (val); -log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -249,11 +259,13 @@ static inline u64 readq(const volatile void __iomem *addr)#define writeb writebstatic inline void writeb (u8 value,volatile void __iomem *addr) { -log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writeb (value, addr);__io_aw (); -log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -261,11 +273,13 @@ static inline void writeb(u8 value, volatile void __iomem *addr)#define writew writewstatic inline void writew (u16 value,volatile void __iomem *addr) { -log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writew ((u16 __force )cpu_to_le16 (value), addr);__io_aw (); -log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -273,11 +287,13 @@ static inline void writew(u16 value, volatile void __iomem *addr)#define writel writelstatic inline void writel (u32 value,volatile void __iomem *addr) { -log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writel ((u32 __force )__cpu_to_le32 (value), addr);__io_aw (); -log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -286,11 +302,13 @@ static inline void writel(u32 value, volatile void __iomem *addr)#define writeq writeqstatic inline void writeq (u64 value,volatile void __iomem *addr) { -log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writeq ((u64 __force )__cpu_to_le64 (value), addr);__io_aw (); -log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif #endif /* CONFIG_64BIT */
@@ -306,9 +324,11 @@ static inline u8 readb_relaxed(const volatile void __iomem *addr) {u8 val; -log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); val =__raw_readb (addr); -log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -319,9 +339,11 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr) {u16 val; -log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); val =__le16_to_cpu ((__le16 __force )__raw_readw (addr)); -log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -332,9 +354,11 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr) {u32 val; -log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); val =__le32_to_cpu ((__le32 __force )__raw_readl (addr)); -log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -345,9 +369,11 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr) {u64 val; -log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); val =__le64_to_cpu ((__le64 __force )__raw_readq (addr)); -log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -356,9 +382,11 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)#define writeb_relaxed writeb_relaxedstatic inline void writeb_relaxed (u8 value,volatile void __iomem *addr) { -log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_);__raw_writeb (value, addr); -log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -366,9 +394,11 @@ static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)#define writew_relaxed writew_relaxedstatic inline void writew_relaxed (u16 value,volatile void __iomem *addr) { -log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_);__raw_writew ((u16 __force )cpu_to_le16 (value), addr); -log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -376,9 +406,11 @@ static inline void writew_relaxed(u16 value, volatile void __iomem *addr)#define writel_relaxed writel_relaxedstatic inline void writel_relaxed (u32 value,volatile void __iomem *addr) { -log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_);__raw_writel ((u32 __force )__cpu_to_le32 (value), addr); -log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -386,9 +418,11 @@ static inline void writel_relaxed(u32 value, volatile void __iomem *addr)#define writeq_relaxed writeq_relaxedstatic inline void writeq_relaxed (u64 value,volatile void __iomem *addr) { -log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_);__raw_writeq ((u64 __force )__cpu_to_le64 (value), addr); -log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif
Sasha Levin
maintainerPATCH 1/3 asm-generic/io: Add _RET_IP_ to MMIO trace for more accurate debug info
From: Sai Prakash Ranjan <[email protected]>
[ Upstream commit 5e5ff73c2e5863f93fc5fd78d178cd8f2af12464 ]
Due to compiler optimizations like inlining, there are cases where MMIO traces using _THIS_IP_ for caller information might not be sufficient to provide accurate debug traces.
1) With optimizations (Seen with GCC):
In this case, _THIS_IP_ works fine and prints the caller information since it will be inlined into the caller and we get the debug traces on who made the MMIO access, for ex:
rwmmio_read: qcom_smmu_tlb_sync+0xe0/0x1b0 width=32 addr=0xffff8000087447f4rwmmio_post_read: qcom_smmu_tlb_sync+0xe0/0x1b0 width=32 val=0x0 addr=0xffff8000087447f4
2) Without optimizations (Seen with Clang):
_THIS_IP_ will not be sufficient in this case as it will print only the MMIO accessors itself which is of not much use since it is not inlined as below for example:
rwmmio_read: readl+0x4/0x80 width=32 addr=0xffff8000087447f4rwmmio_post_read: readl+0x48/0x80 width=32 val=0x4 addr=0xffff8000087447f4
So in order to handle this second case as well irrespective of the compiler optimizations, add _RET_IP_ to MMIO trace to make it provide more accurate debug information in all these scenarios.
Before:
rwmmio_read: readl+0x4/0x80 width=32 addr=0xffff8000087447f4rwmmio_post_read: readl+0x48/0x80 width=32 val=0x4 addr=0xffff8000087447f4
After:
rwmmio_read: qcom_smmu_tlb_sync+0xe0/0x1b0 -> readl+0x4/0x80 width=32 addr=0xffff8000087447f4rwmmio_post_read: qcom_smmu_tlb_sync+0xe0/0x1b0 -> readl+0x4/0x80 width=32 val=0x0 addr=0xffff8000087447f4
Stable-dep-of: 8327bd4fcb6c ("asm-generic/io.h: Skip trace helpers if rwmmio events are disabled")
--- include/asm-generic/io.h | 80 +++++++++++++++++------------------ include/trace/events/rwmmio.h | 43 ++++++++++++------- lib/trace_readwrite.c | 16 +++---- 3 files changed, 75 insertions(+), 64 deletions(-)
include/asm-generic/io.h +40 -40
@@ -80,24 +80,24 @@ DECLARE_TRACEPOINT(rwmmio_read);DECLARE_TRACEPOINT (rwmmio_post_read);void log_write_mmio (u64 val,u8 width,volatile void __iomem *addr, -unsigned long caller_addr); +unsigned long caller_addr,unsigned long caller_addr0);void log_post_write_mmio (u64 val,u8 width,volatile void __iomem *addr, -unsigned long caller_addr); +unsigned long caller_addr,unsigned long caller_addr0);void log_read_mmio (u8 width,const volatile void __iomem *addr, -unsigned long caller_addr); +unsigned long caller_addr,unsigned long caller_addr0);void log_post_read_mmio (u64 val,u8 width,const volatile void __iomem *addr, -unsigned long caller_addr); +unsigned long caller_addr,unsigned long caller_addr0);#else static inline void log_write_mmio (u64 val,u8 width,volatile void __iomem *addr, -unsigned long caller_addr) {} +unsigned long caller_addr,unsigned long caller_addr0) {}static inline void log_post_write_mmio (u64 val,u8 width,volatile void __iomem *addr, -unsigned long caller_addr) {} +unsigned long caller_addr,unsigned long caller_addr0) {}static inline void log_read_mmio (u8 width,const volatile void __iomem *addr, -unsigned long caller_addr) {} +unsigned long caller_addr,unsigned long caller_addr0) {}static inline void log_post_read_mmio (u64 val,u8 width,const volatile void __iomem *addr, -unsigned long caller_addr) {} +unsigned long caller_addr,unsigned long caller_addr0) {}#endif /* CONFIG_TRACE_MMIO_ACCESS */
@@ -188,11 +188,11 @@ static inline u8 readb(const volatile void __iomem *addr) {u8 val; -log_read_mmio (8 , addr, _THIS_IP_); +log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__raw_readb (addr);__io_ar (val); -log_post_read_mmio (val,8 , addr, _THIS_IP_); +log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -203,11 +203,11 @@ static inline u16 readw(const volatile void __iomem *addr) {u16 val; -log_read_mmio (16 , addr, _THIS_IP_); +log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le16_to_cpu ((__le16 __force )__raw_readw (addr));__io_ar (val); -log_post_read_mmio (val,16 , addr, _THIS_IP_); +log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -218,11 +218,11 @@ static inline u32 readl(const volatile void __iomem *addr) {u32 val; -log_read_mmio (32 , addr, _THIS_IP_); +log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le32_to_cpu ((__le32 __force )__raw_readl (addr));__io_ar (val); -log_post_read_mmio (val,32 , addr, _THIS_IP_); +log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -234,11 +234,11 @@ static inline u64 readq(const volatile void __iomem *addr) {u64 val; -log_read_mmio (64 , addr, _THIS_IP_); +log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le64_to_cpu ((__le64 __force )__raw_readq (addr));__io_ar (val); -log_post_read_mmio (val,64 , addr, _THIS_IP_); +log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -248,11 +248,11 @@ static inline u64 readq(const volatile void __iomem *addr)#define writeb writebstatic inline void writeb (u8 value,volatile void __iomem *addr) { -log_write_mmio (value,8 , addr, _THIS_IP_); +log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writeb (value, addr);__io_aw (); -log_post_write_mmio (value,8 , addr, _THIS_IP_); +log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -260,11 +260,11 @@ static inline void writeb(u8 value, volatile void __iomem *addr)#define writew writewstatic inline void writew (u16 value,volatile void __iomem *addr) { -log_write_mmio (value,16 , addr, _THIS_IP_); +log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writew ((u16 __force )cpu_to_le16 (value), addr);__io_aw (); -log_post_write_mmio (value,16 , addr, _THIS_IP_); +log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -272,11 +272,11 @@ static inline void writew(u16 value, volatile void __iomem *addr)#define writel writelstatic inline void writel (u32 value,volatile void __iomem *addr) { -log_write_mmio (value,32 , addr, _THIS_IP_); +log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writel ((u32 __force )__cpu_to_le32 (value), addr);__io_aw (); -log_post_write_mmio (value,32 , addr, _THIS_IP_); +log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -285,11 +285,11 @@ static inline void writel(u32 value, volatile void __iomem *addr)#define writeq writeqstatic inline void writeq (u64 value,volatile void __iomem *addr) { -log_write_mmio (value,64 , addr, _THIS_IP_); +log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writeq ((u64 __force )__cpu_to_le64 (value), addr);__io_aw (); -log_post_write_mmio (value,64 , addr, _THIS_IP_); +log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif #endif /* CONFIG_64BIT */
@@ -305,9 +305,9 @@ static inline u8 readb_relaxed(const volatile void __iomem *addr) {u8 val; -log_read_mmio (8 , addr, _THIS_IP_); +log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); val =__raw_readb (addr); -log_post_read_mmio (val,8 , addr, _THIS_IP_); +log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -318,9 +318,9 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr) {u16 val; -log_read_mmio (16 , addr, _THIS_IP_); +log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); val =__le16_to_cpu (__raw_readw (addr)); -log_post_read_mmio (val,16 , addr, _THIS_IP_); +log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -331,9 +331,9 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr) {u32 val; -log_read_mmio (32 , addr, _THIS_IP_); +log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); val =__le32_to_cpu (__raw_readl (addr)); -log_post_read_mmio (val,32 , addr, _THIS_IP_); +log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -344,9 +344,9 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr) {u64 val; -log_read_mmio (64 , addr, _THIS_IP_); +log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); val =__le64_to_cpu (__raw_readq (addr)); -log_post_read_mmio (val,64 , addr, _THIS_IP_); +log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -355,9 +355,9 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)#define writeb_relaxed writeb_relaxedstatic inline void writeb_relaxed (u8 value,volatile void __iomem *addr) { -log_write_mmio (value,8 , addr, _THIS_IP_); +log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_);__raw_writeb (value, addr); -log_post_write_mmio (value,8 , addr, _THIS_IP_); +log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -365,9 +365,9 @@ static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)#define writew_relaxed writew_relaxedstatic inline void writew_relaxed (u16 value,volatile void __iomem *addr) { -log_write_mmio (value,16 , addr, _THIS_IP_); +log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_);__raw_writew (cpu_to_le16 (value), addr); -log_post_write_mmio (value,16 , addr, _THIS_IP_); +log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -375,9 +375,9 @@ static inline void writew_relaxed(u16 value, volatile void __iomem *addr)#define writel_relaxed writel_relaxedstatic inline void writel_relaxed (u32 value,volatile void __iomem *addr) { -log_write_mmio (value,32 , addr, _THIS_IP_); +log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_);__raw_writel (__cpu_to_le32 (value), addr); -log_post_write_mmio (value,32 , addr, _THIS_IP_); +log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -385,9 +385,9 @@ static inline void writel_relaxed(u32 value, volatile void __iomem *addr)#define writeq_relaxed writeq_relaxedstatic inline void writeq_relaxed (u64 value,volatile void __iomem *addr) { -log_write_mmio (value,64 , addr, _THIS_IP_); +log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_);__raw_writeq (__cpu_to_le64 (value), addr); -log_post_write_mmio (value,64 , addr, _THIS_IP_); +log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif
include/trace/events/rwmmio.h +27 -16
108 lines not on this page · raw message
lib/trace_readwrite.c +8 -8
@@ -14,33 +14,33 @@#ifdef CONFIG_TRACE_MMIO_ACCESS void log_write_mmio (u64 val,u8 width,volatile void __iomem *addr, -unsigned long caller_addr) +unsigned long caller_addr,unsigned long caller_addr0) { -trace_rwmmio_write (caller_addr, val, width, addr); +trace_rwmmio_write (caller_addr, caller_addr0, val, width, addr); }EXPORT_SYMBOL_GPL (log_write_mmio);EXPORT_TRACEPOINT_SYMBOL_GPL (rwmmio_write);void log_post_write_mmio (u64 val,u8 width,volatile void __iomem *addr, -unsigned long caller_addr) +unsigned long caller_addr,unsigned long caller_addr0) { -trace_rwmmio_post_write (caller_addr, val, width, addr); +trace_rwmmio_post_write (caller_addr, caller_addr0, val, width, addr); }EXPORT_SYMBOL_GPL (log_post_write_mmio);EXPORT_TRACEPOINT_SYMBOL_GPL (rwmmio_post_write);void log_read_mmio (u8 width,const volatile void __iomem *addr, -unsigned long caller_addr) +unsigned long caller_addr,unsigned long caller_addr0) { -trace_rwmmio_read (caller_addr, width, addr); +trace_rwmmio_read (caller_addr, caller_addr0, width, addr); }EXPORT_SYMBOL_GPL (log_read_mmio);EXPORT_TRACEPOINT_SYMBOL_GPL (rwmmio_read);void log_post_read_mmio (u64 val,u8 width,const volatile void __iomem *addr, -unsigned long caller_addr) +unsigned long caller_addr,unsigned long caller_addr0) { -trace_rwmmio_post_read (caller_addr, val, width, addr); +trace_rwmmio_post_read (caller_addr, caller_addr0, val, width, addr); }EXPORT_SYMBOL_GPL (log_post_read_mmio);EXPORT_TRACEPOINT_SYMBOL_GPL (rwmmio_post_read);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/3 asm-generic/io.h: suppress endianness warnings for relaxed accessors
From: Vladimir Oltean <[email protected]>
[ Upstream commit 05d3855b4d21ef3c2df26be1cbba9d2c68915fcb ]
Copy the forced type casts from the normal MMIO accessors to suppress the sparse warnings that point out __raw_readl() returns a native endian word (just like readl()).
Stable-dep-of: 8327bd4fcb6c ("asm-generic/io.h: Skip trace helpers if rwmmio events are disabled")
--- include/asm-generic/io.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/asm-generic/io.h +6 -6
@@ -319,7 +319,7 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr)u16 val;log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); - val =__le16_to_cpu (__raw_readw (addr)); + val =__le16_to_cpu ((__le16 __force )__raw_readw (addr));log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }
@@ -332,7 +332,7 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr)u32 val;log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); - val =__le32_to_cpu (__raw_readl (addr)); + val =__le32_to_cpu ((__le32 __force )__raw_readl (addr));log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }
@@ -345,7 +345,7 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)u64 val;log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); - val =__le64_to_cpu (__raw_readq (addr)); + val =__le64_to_cpu ((__le64 __force )__raw_readq (addr));log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }
@@ -366,7 +366,7 @@ static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)static inline void writew_relaxed (u16 value,volatile void __iomem *addr) {log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); -__raw_writew (cpu_to_le16 (value), addr); +__raw_writew ((u16 __force )cpu_to_le16 (value), addr);log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -376,7 +376,7 @@ static inline void writew_relaxed(u16 value, volatile void __iomem *addr)static inline void writel_relaxed (u32 value,volatile void __iomem *addr) {log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); -__raw_writel (__cpu_to_le32 (value), addr); +__raw_writel ((u32 __force )__cpu_to_le32 (value), addr);log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -386,7 +386,7 @@ static inline void writel_relaxed(u32 value, volatile void __iomem *addr)static inline void writeq_relaxed (u64 value,volatile void __iomem *addr) {log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); -__raw_writeq (__cpu_to_le64 (value), addr); +__raw_writeq ((u64 __force )__cpu_to_le64 (value), addr);log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 3/3 asm-generic/io.h: Skip trace helpers if rwmmio events are disabled
In reply to Sasha LevinFrom: Varad Gautam <[email protected]>
[ Upstream commit 8327bd4fcb6c1dab01ce5c6ff00b42496836dcd2 ]
With CONFIG_TRACE_MMIO_ACCESS=y, the {read,write}{b,w,l,q}{_relaxed}() mmio accessors unconditionally call log_{post_}{read,write}_mmio() helpers, which in turn call the ftrace ops for rwmmio trace events
This adds a performance penalty per mmio accessor call, even when rwmmio events are disabled at runtime (~80% overhead on local measurement).
Guard these with tracepoint_enabled().
--- include/asm-generic/io.h | 98 +++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 32 deletions(-)
include/asm-generic/io.h +66 -32
@@ -74,6 +74,7 @@#if IS_ENABLED (CONFIG_TRACE_MMIO_ACCESS ) && !(defined(__DISABLE_TRACE_MMIO__))#include <linux/tracepoint-defs.h> +#define rwmmio_tracepoint_enabled (tracepoint) tracepoint_enabled(tracepoint)DECLARE_TRACEPOINT (rwmmio_write);DECLARE_TRACEPOINT (rwmmio_post_write);DECLARE_TRACEPOINT (rwmmio_read);
@@ -90,6 +91,7 @@ void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,#else +#define rwmmio_tracepoint_enabled (tracepoint) falsestatic inline void log_write_mmio (u64 val,u8 width,volatile void __iomem *addr,unsigned long caller_addr,unsigned long caller_addr0) {} static inline void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
@@ -188,11 +190,13 @@ static inline u8 readb(const volatile void __iomem *addr) {u8 val; -log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__raw_readb (addr);__io_ar (val); -log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -203,11 +207,13 @@ static inline u16 readw(const volatile void __iomem *addr) {u16 val; -log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le16_to_cpu ((__le16 __force )__raw_readw (addr));__io_ar (val); -log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -218,11 +224,13 @@ static inline u32 readl(const volatile void __iomem *addr) {u32 val; -log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le32_to_cpu ((__le32 __force )__raw_readl (addr));__io_ar (val); -log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -234,11 +242,13 @@ static inline u64 readq(const volatile void __iomem *addr) {u64 val; -log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_);__io_br (); val =__le64_to_cpu ((__le64 __force )__raw_readq (addr));__io_ar (val); -log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -248,11 +258,13 @@ static inline u64 readq(const volatile void __iomem *addr)#define writeb writebstatic inline void writeb (u8 value,volatile void __iomem *addr) { -log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writeb (value, addr);__io_aw (); -log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -260,11 +272,13 @@ static inline void writeb(u8 value, volatile void __iomem *addr)#define writew writewstatic inline void writew (u16 value,volatile void __iomem *addr) { -log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writew ((u16 __force )cpu_to_le16 (value), addr);__io_aw (); -log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -272,11 +286,13 @@ static inline void writew(u16 value, volatile void __iomem *addr)#define writel writelstatic inline void writel (u32 value,volatile void __iomem *addr) { -log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writel ((u32 __force )__cpu_to_le32 (value), addr);__io_aw (); -log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -285,11 +301,13 @@ static inline void writel(u32 value, volatile void __iomem *addr)#define writeq writeqstatic inline void writeq (u64 value,volatile void __iomem *addr) { -log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_);__io_bw ();__raw_writeq ((u64 __force )__cpu_to_le64 (value), addr);__io_aw (); -log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif #endif /* CONFIG_64BIT */
@@ -305,9 +323,11 @@ static inline u8 readb_relaxed(const volatile void __iomem *addr) {u8 val; -log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (8 , addr, _THIS_IP_, _RET_IP_); val =__raw_readb (addr); -log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,8 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -318,9 +338,11 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr) {u16 val; -log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (16 , addr, _THIS_IP_, _RET_IP_); val =__le16_to_cpu ((__le16 __force )__raw_readw (addr)); -log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,16 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -331,9 +353,11 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr) {u32 val; -log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (32 , addr, _THIS_IP_, _RET_IP_); val =__le32_to_cpu ((__le32 __force )__raw_readl (addr)); -log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,32 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -344,9 +368,11 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr) {u64 val; -log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_read)) +log_read_mmio (64 , addr, _THIS_IP_, _RET_IP_); val =__le64_to_cpu ((__le64 __force )__raw_readq (addr)); -log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_read)) +log_post_read_mmio (val,64 , addr, _THIS_IP_, _RET_IP_);return val; }#endif
@@ -355,9 +381,11 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)#define writeb_relaxed writeb_relaxedstatic inline void writeb_relaxed (u8 value,volatile void __iomem *addr) { -log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_);__raw_writeb (value, addr); -log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,8 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -365,9 +393,11 @@ static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)#define writew_relaxed writew_relaxedstatic inline void writew_relaxed (u16 value,volatile void __iomem *addr) { -log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_);__raw_writew ((u16 __force )cpu_to_le16 (value), addr); -log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,16 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -375,9 +405,11 @@ static inline void writew_relaxed(u16 value, volatile void __iomem *addr)#define writel_relaxed writel_relaxedstatic inline void writel_relaxed (u32 value,volatile void __iomem *addr) { -log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_);__raw_writel ((u32 __force )__cpu_to_le32 (value), addr); -log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,32 , addr, _THIS_IP_, _RET_IP_); }#endif
@@ -385,9 +417,11 @@ static inline void writel_relaxed(u32 value, volatile void __iomem *addr)#define writeq_relaxed writeq_relaxedstatic inline void writeq_relaxed (u64 value,volatile void __iomem *addr) { -log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_write)) +log_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_);__raw_writeq ((u64 __force )__cpu_to_le64 (value), addr); -log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); +if (rwmmio_tracepoint_enabled (rwmmio_post_write)) +log_post_write_mmio (value,64 , addr, _THIS_IP_, _RET_IP_); }#endif
Signature · 1 line
2.51.0