mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/2] trace: Move data to new section _ftrace_data
Date: Tue, 18 Feb 2020 18:03:17 -0800	[thread overview]
Message-ID: <45725c93cb9bc3cf78e2c6304a9d04ee92eda2b4.1582077699.git.joe@perches.com> (raw)
In-Reply-To: <cover.1582077698.git.joe@perches.com>

Move the data used by tracing to a separate section to
help identify and perhaps control access to tracing data.

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/trace/trace_events.h | 31 ++++++++++++++++++++++---------
 kernel/trace/trace_export.c  | 10 +++++++---
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 502c7b..361999f 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -369,7 +369,9 @@ trace_raw_output_##call(struct trace_iterator *iter, int flags,		\
 									\
 	return trace_handle_return(s);					\
 }									\
-static struct trace_event_functions trace_event_type_funcs_##call = {	\
+static struct trace_event_functions					\
+__attribute__((section("_ftrace_data")))				\
+trace_event_type_funcs_##call = {					\
 	.trace			= trace_raw_output_##call,		\
 };
 
@@ -439,9 +441,12 @@ 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 trace_event_fields_##call[] = {	\
+static struct trace_event_fields					\
+__attribute__((section("_ftrace_data")))				\
+trace_event_fields_##call[] = {						\
 	tstruct								\
-	{} };
+	{}								\
+};
 
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(template, name, proto, args)
@@ -746,7 +751,8 @@ 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 print_fmt_##call[] = print;					\
+static char __attribute__((section("_ftrace_data")))			\
+print_fmt_##call[] = print;						\
 static struct trace_event_class __used __refdata event_class_##call = { \
 	.system			= TRACE_SYSTEM_STRING,			\
 	.fields_array		= trace_event_fields_##call,		\
@@ -760,7 +766,9 @@ 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 event_##call = {			\
+static struct trace_event_call __used					\
+__attribute__((section("_ftrace_data")))				\
+event_##call = {							\
 	.class			= &event_class_##template,		\
 	{								\
 		.tp			= &__tracepoint_##call,		\
@@ -770,14 +778,18 @@ static struct trace_event_call __used event_##call = {			\
 	.flags			= TRACE_EVENT_FL_TRACEPOINT,		\
 };									\
 static struct trace_event_call __used					\
-__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
+__attribute__((section("_ftrace_events")))				\
+*__event_##call = &event_##call
 
 #undef DEFINE_EVENT_PRINT
 #define DEFINE_EVENT_PRINT(template, call, proto, args, print)		\
 									\
-static char print_fmt_##call[] = print;					\
+static char __attribute__((section("_ftrace_data")))			\
+print_fmt_##call[] = print;						\
 									\
-static struct trace_event_call __used event_##call = {			\
+static struct trace_event_call __used					\
+__attribute__((section("_ftrace_data")))				\
+event_##call = {							\
 	.class			= &event_class_##template,		\
 	{								\
 		.tp			= &__tracepoint_##call,		\
@@ -787,6 +799,7 @@ static struct trace_event_call __used event_##call = {			\
 	.flags			= TRACE_EVENT_FL_TRACEPOINT,		\
 };									\
 static struct trace_event_call __used					\
-__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
+__attribute__((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 77ce5a..90af7c9 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -111,9 +111,12 @@ 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 ftrace_event_fields_##name[] = {	\
+static struct trace_event_fields					\
+__attribute__((section("_ftrace_data")))				\
+ftrace_event_fields_##name[] = {					\
 	tstruct								\
-	{} };
+	{}								\
+};
 
 #include "trace_entries.h"
 
@@ -150,7 +153,8 @@ static struct trace_event_class __refdata event_class_ftrace_##call = {	\
 	.reg			= regfn,				\
 };									\
 									\
-struct trace_event_call __used event_##call = {				\
+struct trace_event_call __used __attribute((section("_ftrace_data")))	\
+event_##call = {							\
 	.class			= &event_class_ftrace_##call,		\
 	{								\
 		.name			= #call,			\
-- 
2.24.0


  reply	other threads:[~2020-02-19  2:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19  2:03 [RFC PATCH 0/2] trace: Move trace " Joe Perches
2020-02-19  2:03 ` Joe Perches [this message]
2020-02-19  2:03 ` [RFC PATCH 2/2] trace_events/trace_export: Use __section Joe Perches
2020-02-19  2:53 ` [RFC PATCH 0/2] trace: Move trace data to new section _ftrace_data Steven Rostedt
2020-02-19  3:09   ` Joe Perches
2020-02-19  3:26     ` Steven Rostedt
2020-02-19  3:33       ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45725c93cb9bc3cf78e2c6304a9d04ee92eda2b4.1582077699.git.joe@perches.com \
    --to=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®