public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jeremy Linton <jeremy.linton@arm.com>
Subject: [for-next][PATCH 10/12] tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeofs to their values
Date: Thu, 15 Jun 2017 06:52:33 -0400	[thread overview]
Message-ID: <20170615105254.144480148@goodmis.org> (raw)
In-Reply-To: 20170615105223.551999981@goodmis.org

[-- Attachment #1: 0010-tracing-define-TRACE_DEFINE_SIZEOF-macro-to-map-size.patch --]
[-- Type: text/plain, Size: 2078 bytes --]

From: Jeremy Linton <jeremy.linton@arm.com>

Perf has a problem that if sizeof() macros are used within TRACE_EVENT()
macro's they end up in userspace as "sizeof(kernel structure)" which
cannot properly be parsed. Add a macro which can forward this data
through the eval_map for userspace utilization.

Link: http://lkml.kernel.org/r/20170531215653.3240-10-jeremy.linton@arm.com

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/linux/tracepoint.h   |  1 +
 include/trace/trace_events.h | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index f7b0f5525e46..a26ffbe09e71 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -88,6 +88,7 @@ extern void syscall_unregfunc(void);
 #define PARAMS(args...) args
 
 #define TRACE_DEFINE_ENUM(x)
+#define TRACE_DEFINE_SIZEOF(x)
 
 #endif /* _LINUX_TRACEPOINT_H */
 
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 49cce5fb54ee..3976fa1f6e42 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -46,6 +46,19 @@ TRACE_MAKE_SYSTEM_STR();
 	__attribute__((section("_ftrace_eval_map")))	\
 	*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
 
+#undef TRACE_DEFINE_SIZEOF
+#define TRACE_DEFINE_SIZEOF(a)				\
+	static struct trace_eval_map __used __initdata	\
+	__##TRACE_SYSTEM##_##a =			\
+	{						\
+		.system = TRACE_SYSTEM_STRING,		\
+		.eval_string = "sizeof(" #a ")",	\
+		.eval_value = sizeof(a)			\
+	};						\
+	static struct trace_eval_map __used		\
+	__attribute__((section("_ftrace_eval_map")))	\
+	*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
+
 /*
  * DECLARE_EVENT_CLASS can be used to add a generic function
  * handlers for events. That is, if all events have the same
@@ -158,6 +171,9 @@ TRACE_MAKE_SYSTEM_STR();
 #undef TRACE_DEFINE_ENUM
 #define TRACE_DEFINE_ENUM(a)
 
+#undef TRACE_DEFINE_SIZEOF
+#define TRACE_DEFINE_SIZEOF(a)
+
 #undef __field
 #define __field(type, item)
 
-- 
2.10.2

  parent reply	other threads:[~2017-06-15 10:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 10:52 [for-next][PATCH 00/12] tracing: Updates for 4.13 Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 01/12] tracing: Remove unused declaration of trace_stop_cmdline_recording Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 02/12] trace: rename kernel enum section to eval Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 03/12] trace: rename trace_enum_map to trace_eval_map Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 04/12] trace: rename struct module entry for trace enums Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 05/12] trace: rename trace enum data structures in trace.c Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 06/12] trace: rename trace_enum_mutex to trace_eval_mutex Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 07/12] trace: rename trace.c enum functions Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 08/12] trace: rename enum_map functions Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 09/12] tracing: Rename enum_replace to eval_replace Steven Rostedt
2017-06-15 10:52 ` Steven Rostedt [this message]
2017-06-15 10:52 ` [for-next][PATCH 11/12] tracing: Add TRACE_DEFINE_SIZEOF() macros Steven Rostedt
2017-06-15 10:52 ` [for-next][PATCH 12/12] tracing: Rename update the enum_map file Steven Rostedt

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=20170615105254.144480148@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=jeremy.linton@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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