[RFC PATCH 2/2] trace_events/trace_export: Use __section

From: Joe Perches
Date: Tue Feb 18 2020 - 21:04:48 EST


Convert __attribute__((section("foo"))) to __section(foo) to be a
bit more kernel style compliant and improve readability a tiny bit.

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
include/trace/trace_events.h | 29 +++++++++++------------------
kernel/trace/trace_export.c | 9 ++++-----
2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 361999f..a5b2eb 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -45,7 +45,7 @@ TRACE_MAKE_SYSTEM_STR();
.eval_value = a \
}; \
static struct trace_eval_map __used \
- __attribute__((section("_ftrace_eval_map"))) \
+ __section(_ftrace_eval_map) \
*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a

#undef TRACE_DEFINE_SIZEOF
@@ -58,7 +58,7 @@ TRACE_MAKE_SYSTEM_STR();
.eval_value = sizeof(a) \
}; \
static struct trace_eval_map __used \
- __attribute__((section("_ftrace_eval_map"))) \
+ __section(_ftrace_eval_map) \
*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a

/*
@@ -369,8 +369,7 @@ trace_raw_output_##call(struct trace_iterator *iter, int flags, \
\
return trace_handle_return(s); \
} \
-static struct trace_event_functions \
-__attribute__((section("_ftrace_data"))) \
+static struct trace_event_functions __section(_ftrace_data) \
trace_event_type_funcs_##call = { \
.trace = trace_raw_output_##call, \
};
@@ -441,8 +440,7 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \

#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
-static struct trace_event_fields \
-__attribute__((section("_ftrace_data"))) \
+static struct trace_event_fields __section(_ftrace_data) \
trace_event_fields_##call[] = { \
tstruct \
{} \
@@ -624,7 +622,7 @@ static inline notrace int trace_event_get_offsets_##call( \
* // its only safe to use pointers when doing linker tricks to
* // create an array.
* static struct trace_event_call __used
- * __attribute__((section("_ftrace_events"))) *__event_<call> = &event_<call>;
+ * __section(_ftrace_events) *__event_<call> = &event_<call>;
*
*/

@@ -751,7 +749,7 @@ static inline void ftrace_test_probe_##call(void) \
#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
_TRACE_PERF_PROTO(call, PARAMS(proto)); \
-static char __attribute__((section("_ftrace_data"))) \
+static char __section(_ftrace_data) \
print_fmt_##call[] = print; \
static struct trace_event_class __used __refdata event_class_##call = { \
.system = TRACE_SYSTEM_STRING, \
@@ -766,8 +764,7 @@ static struct trace_event_class __used __refdata event_class_##call = { \
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
\
-static struct trace_event_call __used \
-__attribute__((section("_ftrace_data"))) \
+static struct trace_event_call __used __section(_ftrace_data) \
event_##call = { \
.class = &event_class_##template, \
{ \
@@ -777,18 +774,15 @@ event_##call = { \
.print_fmt = print_fmt_##template, \
.flags = TRACE_EVENT_FL_TRACEPOINT, \
}; \
-static struct trace_event_call __used \
-__attribute__((section("_ftrace_events"))) \
+static struct trace_event_call __used __section(_ftrace_events) \
*__event_##call = &event_##call

#undef DEFINE_EVENT_PRINT
#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
- \
-static char __attribute__((section("_ftrace_data"))) \
+static char __section(_ftrace_data) \
print_fmt_##call[] = print; \
\
-static struct trace_event_call __used \
-__attribute__((section("_ftrace_data"))) \
+static struct trace_event_call __used __section(_ftrace_data) \
event_##call = { \
.class = &event_class_##template, \
{ \
@@ -798,8 +792,7 @@ event_##call = { \
.print_fmt = print_fmt_##call, \
.flags = TRACE_EVENT_FL_TRACEPOINT, \
}; \
-static struct trace_event_call __used \
-__attribute__((section("_ftrace_events"))) \
+static struct trace_event_call __used __section(_ftrace_events) \
*__event_##call = &event_##call

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 90af7c9..e38a672 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -111,8 +111,7 @@ static void __always_unused ____ftrace_check_##name(void) \

#undef FTRACE_ENTRY
#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
-static struct trace_event_fields \
-__attribute__((section("_ftrace_data"))) \
+static struct trace_event_fields __section(_ftrace_data) \
ftrace_event_fields_##name[] = { \
tstruct \
{} \
@@ -153,7 +152,7 @@ static struct trace_event_class __refdata event_class_ftrace_##call = { \
.reg = regfn, \
}; \
\
-struct trace_event_call __used __attribute((section("_ftrace_data"))) \
+struct trace_event_call __used __section(_ftrace_data) \
event_##call = { \
.class = &event_class_ftrace_##call, \
{ \
@@ -163,8 +162,8 @@ event_##call = { \
.print_fmt = print, \
.flags = TRACE_EVENT_FL_IGNORE_ENABLE, \
}; \
-static struct trace_event_call __used \
-__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;
+static struct trace_event_call * __used __section(_ftrace_events) \
+__event_##call = &event_##call;

#undef FTRACE_ENTRY
#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print) \
--
2.24.0