mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vaibhav Nagarnaik <vnagarnaik@google.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>
Cc: David Sharp <dhsharp@google.com>,
	Justin Teravest <teravest@google.com>,
	Laurent Chavey <chavey@google.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Michael Davidson <md@google.com>,
	Vaibhav Nagarnaik <vnagarnaik@google.com>
Subject: [PATCH 1/6] trace: syscalls.h - cleanup and simplify SYSCALL_METADATA()
Date: Mon, 26 Mar 2012 11:39:23 -0700	[thread overview]
Message-ID: <1332787168-20457-2-git-send-email-vnagarnaik@google.com> (raw)
In-Reply-To: <1332787168-20457-1-git-send-email-vnagarnaik@google.com>

From: Michael Davidson <md@google.com>

Add 0 argument versions of the __SC_* macros so that system calls
with 0 arguments are no longer a special case.

Change SYSCALL_DEFINE0() to use SYSCALL_DEFINEx() like everything else.

Move the declarations of types_##sname and args_##sname into the
SYSCALL_METADATA() macro so that the changes to SYSCALL_DEFINEx()
when CONFIG_FTRACE_SYSCALLS is defined are all hidden inside of
SYSCALL_METADATA().

Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
---
 include/linux/syscalls.h |   51 ++++++++++++++++-----------------------------
 1 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 8ec1153..ed0003c 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -76,6 +76,7 @@ struct file_handle;
 #include <linux/key.h>
 #include <trace/syscall.h>
 
+#define __SC_DECL0()
 #define __SC_DECL1(t1, a1)	t1 a1
 #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__)
 #define __SC_DECL3(t3, a3, ...) t3 a3, __SC_DECL2(__VA_ARGS__)
@@ -83,6 +84,7 @@ struct file_handle;
 #define __SC_DECL5(t5, a5, ...) t5 a5, __SC_DECL4(__VA_ARGS__)
 #define __SC_DECL6(t6, a6, ...) t6 a6, __SC_DECL5(__VA_ARGS__)
 
+#define __SC_LONG0()
 #define __SC_LONG1(t1, a1) 	long a1
 #define __SC_LONG2(t2, a2, ...) long a2, __SC_LONG1(__VA_ARGS__)
 #define __SC_LONG3(t3, a3, ...) long a3, __SC_LONG2(__VA_ARGS__)
@@ -90,6 +92,7 @@ struct file_handle;
 #define __SC_LONG5(t5, a5, ...) long a5, __SC_LONG4(__VA_ARGS__)
 #define __SC_LONG6(t6, a6, ...) long a6, __SC_LONG5(__VA_ARGS__)
 
+#define __SC_CAST0()
 #define __SC_CAST1(t1, a1)	(t1) a1
 #define __SC_CAST2(t2, a2, ...) (t2) a2, __SC_CAST1(__VA_ARGS__)
 #define __SC_CAST3(t3, a3, ...) (t3) a3, __SC_CAST2(__VA_ARGS__)
@@ -98,6 +101,7 @@ struct file_handle;
 #define __SC_CAST6(t6, a6, ...) (t6) a6, __SC_CAST5(__VA_ARGS__)
 
 #define __SC_TEST(type)		BUILD_BUG_ON(sizeof(type) > sizeof(long))
+#define __SC_TEST0()
 #define __SC_TEST1(t1, a1)	__SC_TEST(t1)
 #define __SC_TEST2(t2, a2, ...)	__SC_TEST(t2); __SC_TEST1(__VA_ARGS__)
 #define __SC_TEST3(t3, a3, ...)	__SC_TEST(t3); __SC_TEST2(__VA_ARGS__)
@@ -106,6 +110,7 @@ struct file_handle;
 #define __SC_TEST6(t6, a6, ...)	__SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
 
 #ifdef CONFIG_FTRACE_SYSCALLS
+#define __SC_STR_ADECL0()		(0)
 #define __SC_STR_ADECL1(t, a)		#a
 #define __SC_STR_ADECL2(t, a, ...)	#a, __SC_STR_ADECL1(__VA_ARGS__)
 #define __SC_STR_ADECL3(t, a, ...)	#a, __SC_STR_ADECL2(__VA_ARGS__)
@@ -113,6 +118,7 @@ struct file_handle;
 #define __SC_STR_ADECL5(t, a, ...)	#a, __SC_STR_ADECL4(__VA_ARGS__)
 #define __SC_STR_ADECL6(t, a, ...)	#a, __SC_STR_ADECL5(__VA_ARGS__)
 
+#define __SC_STR_TDECL0()		(0)
 #define __SC_STR_TDECL1(t, a)		#t
 #define __SC_STR_TDECL2(t, a, ...)	#t, __SC_STR_TDECL1(__VA_ARGS__)
 #define __SC_STR_TDECL3(t, a, ...)	#t, __SC_STR_TDECL2(__VA_ARGS__)
@@ -153,14 +159,20 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("_ftrace_events")))			\
 	*__event_exit_##sname = &event_exit_##sname;
 
-#define SYSCALL_METADATA(sname, nb)				\
+#define SYSCALL_METADATAx(x, sname, ...)			\
+	static const char *types_##sname[] = {			\
+		__SC_STR_TDECL##x(__VA_ARGS__)			\
+	};							\
+	static const char *args_##sname[] = {			\
+		__SC_STR_ADECL##x(__VA_ARGS__)			\
+	};							\
 	SYSCALL_TRACE_ENTER_EVENT(sname);			\
 	SYSCALL_TRACE_EXIT_EVENT(sname);			\
 	static struct syscall_metadata __used			\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
 		.syscall_nr	= -1,	/* Filled in at boot */	\
-		.nb_args 	= nb,				\
+		.nb_args 	= x,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
 		.enter_event	= &event_enter_##sname,		\
@@ -170,27 +182,11 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	static struct syscall_metadata __used			\
 	  __attribute__((section("__syscalls_metadata")))	\
 	 *__p_syscall_meta_##sname = &__syscall_meta_##sname;
-
-#define SYSCALL_DEFINE0(sname)					\
-	SYSCALL_TRACE_ENTER_EVENT(_##sname);			\
-	SYSCALL_TRACE_EXIT_EVENT(_##sname);			\
-	static struct syscall_metadata __used			\
-	  __syscall_meta__##sname = {				\
-		.name 		= "sys_"#sname,			\
-		.syscall_nr	= -1,	/* Filled in at boot */	\
-		.nb_args 	= 0,				\
-		.enter_event	= &event_enter__##sname,	\
-		.exit_event	= &event_exit__##sname,		\
-		.enter_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
-	};							\
-	static struct syscall_metadata __used			\
-	  __attribute__((section("__syscalls_metadata")))	\
-	 *__p_syscall_meta_##sname = &__syscall_meta__##sname;	\
-	asmlinkage long sys_##sname(void)
 #else
-#define SYSCALL_DEFINE0(name)	   asmlinkage long sys_##name(void)
-#endif
+#define SYSCALL_METADATAx(x, name, ...)
+#endif /* CONFIG_FTRACE_SYSCALLS */
 
+#define SYSCALL_DEFINE0(name, ...) SYSCALL_DEFINEx(0, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
@@ -212,20 +208,9 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #endif
 #endif
 
-#ifdef CONFIG_FTRACE_SYSCALLS
-#define SYSCALL_DEFINEx(x, sname, ...)				\
-	static const char *types_##sname[] = {			\
-		__SC_STR_TDECL##x(__VA_ARGS__)			\
-	};							\
-	static const char *args_##sname[] = {			\
-		__SC_STR_ADECL##x(__VA_ARGS__)			\
-	};							\
-	SYSCALL_METADATA(sname, x);				\
-	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
-#else
 #define SYSCALL_DEFINEx(x, sname, ...)				\
+	SYSCALL_METADATAx(x, sname, __VA_ARGS__)			\
 	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
-#endif
 
 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
 
-- 
1.7.7.3


  reply	other threads:[~2012-03-26 18:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 18:39 [PATCH 0/6] Enhance and speed up syscall tracing Vaibhav Nagarnaik
2012-03-26 18:39 ` Vaibhav Nagarnaik [this message]
2012-03-26 18:39 ` [PATCH 2/6] trace: add support for 32 bit compat syscalls on x86_64 Vaibhav Nagarnaik
2012-03-27  4:49   ` H. Peter Anvin
2012-03-28 21:10     ` Vaibhav Nagarnaik
2012-03-28 21:11       ` Vaibhav Nagarnaik
2012-03-28 23:00         ` Vaibhav Nagarnaik
2012-03-26 18:39 ` [PATCH 3/6] trace: Refactor ftrace syscall macros to make them more readable Vaibhav Nagarnaik
2012-03-26 18:39 ` [PATCH 4/6] trace: trace syscall in its handler not from ptrace handler Vaibhav Nagarnaik
2012-03-27  5:00   ` H. Peter Anvin
2012-03-28 18:23     ` Vaibhav Nagarnaik
2012-03-29  2:43       ` H. Peter Anvin
2012-03-29  2:59         ` Steven Rostedt
2012-03-29  3:15           ` H. Peter Anvin
2012-03-29  3:02         ` Vaibhav Nagarnaik
2012-03-29  3:16           ` H. Peter Anvin
2012-03-29  6:20           ` Ingo Molnar
2012-03-29 19:02             ` Vaibhav Nagarnaik
2012-03-29 19:12               ` H. Peter Anvin
2012-03-29 19:43                 ` Vaibhav Nagarnaik
2012-03-29 20:06                   ` H. Peter Anvin
2012-03-29 22:40                     ` David Sharp
2012-03-29 22:44                       ` H. Peter Anvin
2012-03-30 12:06                       ` Frederic Weisbecker
2012-03-30 11:57                     ` Frederic Weisbecker
2012-03-29 22:44                 ` David Sharp
2012-03-29 22:48                   ` H. Peter Anvin
2012-03-26 18:39 ` [PATCH 5/6] trace: raw_syscalls: Mark compat syscalls in the MSB of the syscall number Vaibhav Nagarnaik
2012-03-26 18:39 ` [PATCH 6/6] trace: get rid of the enabled_*_syscalls bitmaps Vaibhav Nagarnaik

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=1332787168-20457-2-git-send-email-vnagarnaik@google.com \
    --to=vnagarnaik@google.com \
    --cc=chavey@google.com \
    --cc=dhsharp@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=md@google.com \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=teravest@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®