[PATCH 0/2] tracepoint bugfix and cleanup

5 views
Skip to first unread message

Nick Desaulniers

unread,
Jul 23, 2020, 4:58:16 PM7/23/20
to Steven Rostedt, Ingo Molnar, Miguel Ojeda, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers
The first patch fixes a reported bug in iterating the
tracing/printk_formats sysfs node, and is tagged for stable.

The second patch is a small cleanup and is less important than the
first.

Nick Desaulniers (2):
tracepoint: mark __tracepoint_string's __used
tracepoint: used attribute definitions from compiler_attributes.h

include/linux/tracepoint.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

--
2.28.0.rc0.105.gf9edc3c819-goog

Sedat Dilek

unread,
Jul 23, 2020, 8:58:27 PM7/23/20
to Nick Desaulniers, Steven Rostedt, Ingo Molnar, Miguel Ojeda, linux-...@vger.kernel.org, Clang-Built-Linux ML
On Thu, Jul 23, 2020 at 10:58 PM 'Nick Desaulniers' via Clang Built
Linux <clang-bu...@googlegroups.com> wrote:
>
> The first patch fixes a reported bug in iterating the
> tracing/printk_formats sysfs node, and is tagged for stable.
>
> The second patch is a small cleanup and is less important than the
> first.
>
> Nick Desaulniers (2):
> tracepoint: mark __tracepoint_string's __used
> tracepoint: used attribute definitions from compiler_attributes.h
>

Forgot to CC CBL-ML on...?

2/2 tracepoint: used attribute definitions from compiler_attributes.h

I didn't see it in my inbox.

- Sedat -

> include/linux/tracepoint.h | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> --
> 2.28.0.rc0.105.gf9edc3c819-goog
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-li...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200723205811.1104520-1-ndesaulniers%40google.com.

Nick Desaulniers

unread,
Jul 30, 2020, 6:46:11 PM7/30/20
to Steven Rostedt, Ingo Molnar, clang-bu...@googlegroups.com, linux-...@vger.kernel.org, Miguel Ojeda, Nick Desaulniers
The first patch fixes a reported bug in iterating the
tracing/printk_formats sysfs node, and is tagged for stable.

The second patch is a small cleanup and is less important than the
first.

Resending since I messed up the list of cc's on the cover letter last
week; picked up Miguel's Ack on 0002.

Nick Desaulniers (2):
tracepoint: mark __tracepoint_string's __used
tracepoint: used attribute definitions from compiler_attributes.h

include/linux/tracepoint.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

--
2.28.0.163.g6104cc2f0b6-goog

Nick Desaulniers

unread,
Jul 30, 2020, 6:46:16 PM7/30/20
to Steven Rostedt, Ingo Molnar, clang-bu...@googlegroups.com, linux-...@vger.kernel.org, Miguel Ojeda, Nick Desaulniers, sta...@vger.kernel.org, Tim Murray, Simon MacMullen, Greg Hackmann
__tracepoint_string's have their string data stored in .rodata, and an
address to that data stored in the "__tracepoint_str" section. Functions
that refer to those strings refer to the symbol of the address. Compiler
optimization can replace those address references with references
directly to the string data. If the address doesn't appear to have other
uses, then it appears dead to the compiler and is removed. This can
break the /tracing/printk_formats sysfs node which iterates the
addresses stored in the "__tracepoint_str" section.

Like other strings stored in custom sections in this header, mark these
__used to inform the compiler that there are other non-obvious users of
the address, so they should still be emitted.

Cc: sta...@vger.kernel.org
Reported-by: Tim Murray <timm...@google.com>
Reported-by: Simon MacMullen <simo...@google.com>
Suggested-by: Greg Hackmann <ghac...@google.com>
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
No change V1 -> V2.

include/linux/tracepoint.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a1fecf311621..3a5b717d92e8 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -361,7 +361,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
static const char *___tp_str __tracepoint_string = str; \
___tp_str; \
})
-#define __tracepoint_string __attribute__((section("__tracepoint_str")))
+#define __tracepoint_string __attribute__((section("__tracepoint_str"), used))
#else
/*
* tracepoint_string() is used to save the string address for userspace
--
2.28.0.163.g6104cc2f0b6-goog

Nick Desaulniers

unread,
Jul 30, 2020, 6:46:19 PM7/30/20
to Steven Rostedt, Ingo Molnar, clang-bu...@googlegroups.com, linux-...@vger.kernel.org, Miguel Ojeda, Nick Desaulniers
Just a small cleanup while I was touching this header.
compiler_attributes.h does feature detection of these __attributes__(())
and provides more concise ways to invoke them.

Acked-by: Miguel Ojeda <miguel.oje...@gmail.com>
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
Changes V1 -> V2:
* Add Miguel's Ack.


include/linux/tracepoint.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 3a5b717d92e8..598fec9f9dbf 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -116,8 +116,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)

#define __TRACEPOINT_ENTRY(name) \
static tracepoint_ptr_t __tracepoint_ptr_##name __used \
- __attribute__((section("__tracepoints_ptrs"))) = \
- &__tracepoint_##name
+ __section(__tracepoints_ptrs) = &__tracepoint_##name
#endif

#endif /* _LINUX_TRACEPOINT_H */
@@ -280,9 +279,9 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
*/
#define DEFINE_TRACE_FN(name, reg, unreg) \
static const char __tpstrtab_##name[] \
- __attribute__((section("__tracepoints_strings"))) = #name; \
- struct tracepoint __tracepoint_##name \
- __attribute__((section("__tracepoints"), used)) = \
+ __section(__tracepoints_strings) = #name; \
+ struct tracepoint __tracepoint_##name __used \
+ __section(__tracepoints) = \
{ __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\
__TRACEPOINT_ENTRY(name);

@@ -361,7 +360,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
static const char *___tp_str __tracepoint_string = str; \
___tp_str; \
})
-#define __tracepoint_string __attribute__((section("__tracepoint_str"), used))
+#define __tracepoint_string __used __section(__tracepoint_str)
Reply all
Reply to author
Forward
0 new messages