use NR_syscalls instead of FTRACE_SYSCALL_MAX
PATCH 4/4 remove FTRACE_SYSCALL_MAX definitions
In reply to Jason BaronRemove the FTRACE_SYSCALL_MAX definitions now that we have converted the syscall event tracing code to use NR_syscalls.
--- arch/x86/include/asm/ftrace.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
arch/x86/include/asm/ftrace.h +0 -7
@@ -28,13 +28,6 @@#endif -/* FIXME: I don't want to stay hardcoded */ -#ifdef CONFIG_X86_64 -# define FTRACE_SYSCALL_MAX 299 -#else -# define FTRACE_SYSCALL_MAX 337 -#endif -#ifdef CONFIG_FUNCTION_TRACER #define MCOUNT_ADDR ((long)(mcount))#define MCOUNT_INSN_SIZE 5/* sizeof mcount call */
Signature · 1 line
1.6.2.5
PATCH 1/4 add NR_syscalls define for x86
In reply to Jason BaronAdd a NR_syscalls #define for x86. This is used in the syscall events tracing code. Todo: make it dynamic like x86_64
--- arch/x86/include/asm/unistd_32.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/include/asm/unistd_32.h +2 -0
@@ -345,6 +345,8 @@#ifdef __KERNEL__ +#define NR_syscalls 337 +#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR#define __ARCH_WANT_OLD_STAT
Signature · 1 line
1.6.2.5
cover use NR_syscalls instead of FTRACE_SYSCALL_MAX
hi,
This series adds definitions for NR_syscalls for x86 and x86_64 and converts syscall events tracing to use NR_syscalls instead of FTRACE_SYSCALL_MAX. Note, the x86_64 NR_syscalls is defined in terms of __NR_syscall_max, and thus is dynamic (we don't need to update it when new syscalls are added). However, the x86 implementation adds a static define in unistd.h, at least for now.
Patches are against the current -tip tree. So the x86 static define will need to be updated with a patch when integrated in the -next tree (which has additional syscalls). Also, Paul Mundt has said he will update sh architecture (to remove the FTRACE_SYSCALL_MAX definition).
thanks,
-Jason
-add-nrsyscalls-32
-add-nrsyscalls-x8664
-convert-ftrace-nrsyscalls
remove-ftrace-syscall-max
arch/x86/include/asm/ftrace.h | 7 ------- arch/x86/include/asm/unistd_32.h | 2 ++ arch/x86/kernel/ftrace.c | 8 ++++---- include/linux/ftrace.h | 5 +++++ kernel/trace/trace_syscalls.c | 24 ++++++++++++------------ 5 files changed, 23 insertions(+), 23 deletions(-)
PATCH 2/4 Add NR_syscalls for x86_64
Add a dynamic definition of NR_syscalls for x86_64. This is used in the syscall events tracing code.
--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/ftrace.h +5 -0
@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +#ifdef CONFIG_FUNCTION_TRACER extern int ftrace_enabled;
Signature · 1 line
1.6.2.5
PATCH 3/4 Convert event tracing code to NR_syscalls
In reply to Jason BaronConvert the syscalls event tracing code to use NR_syscalls, instead of FTRACE_SYSCALL_MAX. NR_syscalls is standard accross most arches, and reduces code confustion/complexity.
--- arch/x86/kernel/ftrace.c | 8 ++++---- kernel/trace/trace_syscalls.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/kernel/ftrace.c +4 -4
@@ -494,7 +494,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)struct syscall_metadata *syscall_nr_to_meta (int nr) { -if (!syscalls_metadata || nr >=FTRACE_SYSCALL_MAX || nr <0 ) +if (!syscalls_metadata || nr >= NR_syscalls || nr <0 )return NULL ;return syscalls_metadata[nr];
@@ -507,7 +507,7 @@ int syscall_name_to_nr(char *name)if (!syscalls_metadata)return -1 ; -for (i =0 ; i <FTRACE_SYSCALL_MAX ; i++) { +for (i =0 ; i < NR_syscalls; i++) {if (syscalls_metadata[i]) {if (!strcmp (syscalls_metadata[i]->name, name))return i;
@@ -533,13 +533,13 @@ static int __init arch_init_ftrace_syscalls(void)unsigned long **psys_syscall_table = &sys_call_table; syscalls_metadata =kzalloc (sizeof (*syscalls_metadata) * -FTRACE_SYSCALL_MAX ,GFP_KERNEL ); + NR_syscalls,GFP_KERNEL );if (!syscalls_metadata) {WARN_ON (1 );return -ENOMEM ; } -for (i =0 ; i <FTRACE_SYSCALL_MAX ; i++) { +for (i =0 ; i < NR_syscalls; i++) { meta =find_syscall_meta (psys_syscall_table[i]); syscalls_metadata[i] = meta; }
kernel/trace/trace_syscalls.c +12 -12
@@ -10,8 +10,8 @@static DEFINE_MUTEX (syscall_trace_lock);static int sys_refcount_enter;static int sys_refcount_exit; -static DECLARE_BITMAP(enabled_enter_syscalls, FTRACE_SYSCALL_MAX); -static DECLARE_BITMAP(enabled_exit_syscalls, FTRACE_SYSCALL_MAX); +static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls); +static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);enum print_line_t print_syscall_enter (struct trace_iterator *iter,int flags)
@@ -282,7 +282,7 @@ int reg_event_syscall_enter(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);if (!sys_refcount_enter)
@@ -305,7 +305,7 @@ void unreg_event_syscall_enter(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock); sys_refcount_enter--;
@@ -323,7 +323,7 @@ int reg_event_syscall_exit(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);if (!sys_refcount_exit)
@@ -346,7 +346,7 @@ void unreg_event_syscall_exit(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock); sys_refcount_exit--;
@@ -366,8 +366,8 @@ struct trace_event event_syscall_exit = {#ifdef CONFIG_EVENT_PROFILE -static DECLARE_BITMAP(enabled_prof_enter_syscalls, FTRACE_SYSCALL_MAX); -static DECLARE_BITMAP(enabled_prof_exit_syscalls, FTRACE_SYSCALL_MAX); +static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls); +static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls);static int sys_prof_refcount_enter;static int sys_prof_refcount_exit;
@@ -413,7 +413,7 @@ int reg_prof_syscall_enter(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);
@@ -435,7 +435,7 @@ void unreg_prof_syscall_enter(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock);
@@ -474,7 +474,7 @@ int reg_prof_syscall_exit(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);
@@ -496,7 +496,7 @@ void unreg_prof_syscall_exit(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock);
Signature · 1 line
1.6.2.5
Re: [PATCH 1/4] add NR_syscalls define for x86
In reply to Jason BaronQuoted 15 lines · Jason Baron
Add a
NR_syscalls#define for x86. This is used in the syscall events tracing code. Todo: make it dynamic likex86_64Signed-off-by Jason Baron <[email protected]>--- arch/x86/include/asm/unistd_32.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)arch/x86/include/asm/unistd_32.h +0
-0
arch/x86/include/asm/unistd_32.h line 349
Quoted 5 lines
arch/x86/include/asm/unistd_32.h +2
-0@@ -345,6 +345,8 @@#ifdef __KERNEL__ +#define NR_syscalls 337 +
Syscalls start at 0 and end at 337, there are 338 syscalls, not 337. Hence the off-by-1 that I initially reported. NR_syscalls is always the last syscall + 1.
Re: [PATCH 2/4] Add NR_syscalls for x86_64
In reply to Jason BaronQuoted 14 lines · Jason Baron
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0
include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +
I'd rather see this in arch/x86/include/unistd_64.h, since NR_syscalls seems to be the defined in unistd.h in all archs.
That also makes a unified way to retrieve this number for other users.
Quoted 6 lines
include/linux/ftrace.h +0
-0#ifdef CONFIG_FUNCTION_TRACER extern int ftrace_enabled;Signature · 1 line
1.6.2.5
Steven Rostedt
maintainerRe: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 28 lines · Frederic Weisbecker
Quoted 14 lines · Jason Baron
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +I'd rather see this in
arch/x86/include/unistd_64.h, sinceNR_syscallsseems to be the defined inunistd.hin all archs.
Quoted 3 lines
That also makes a unified way to retrieve this number for other users.
Yes, NR_syscalls should be included there.
-- Steve
Re: [PATCH 1/4] add NR_syscalls define for x86
In reply to Paul MundtQuoted 17 lines · Paul Mundt
Quoted 16 lines · Jason Baron
Add a
NR_syscalls#define for x86. This is used in the syscall events tracing code. Todo: make it dynamic likex86_64Signed-off-by Jason Baron <[email protected]>--- arch/x86/include/asm/unistd_32.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)arch/x86/include/asm/unistd_32.h +0
-0@@ -345,6 +345,8 @@
Quoted 7 lines
arch/x86/include/asm/unistd_32.h line 349
Quoted 4 lines
arch/x86/include/asm/unistd_32.h +2
-0#ifdef __KERNEL__ +#define NR_syscalls 337 +Syscalls start at 0 and end at 337, there are 338 syscalls, not 337. Hence the off-by-1 that I initially reported.
NR_syscallsis always the last syscall + 1.
right, as I explained in my 0/4 message, this patch is for the -tip tree, where 337 is correct, and needs to be adjusted for the -next tree to 338.
thanks,
-Jason
Re: [PATCH 2/4] Add NR_syscalls for x86_64
In reply to Steven RostedtQuoted 30 lines · Steven Rostedt
Quoted 28 lines · Frederic Weisbecker
Quoted 14 lines · Jason Baron
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +I'd rather see this in
arch/x86/include/unistd_64.h, sinceNR_syscallsseems to be the defined inunistd.hin all archs.
Quoted 7 lines
Quoted 3 lines
That also makes a unified way to retrieve this number for other users.
Yes,
NR_syscallsshould be included there.-- Steve
right, for x86_64, unistd.h is included to generate __NR_syscall_max which is then used for NR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...
thanks,
-Jason
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 36 lines · Jason Baron
Quoted 28 lines
Quoted 28 lines · Jason Baron
Quoted 14 lines
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +I'd rather see this in
arch/x86/include/unistd_64.h, sinceNR_syscallsseems to be the defined inunistd.hin all archs.Quoted 7 lines
Quoted 3 lines
That also makes a unified way to retrieve this number for other users.
Yes,
NR_syscallsshould be included there.-- Steve
Quoted 7 lines
right, for
x86_64,unistd.his included to generate__NR_syscall_maxwhich is then used forNR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...thanks,
-Jason
ok, since unistd_64.h is used to generate offsets.c, which eventually generates, asm/asm-offsets.h, which defines, __NR_syscall_max, we can't just put #define of NR_syscalls in unistd_64.h. However, it seems the only point in time that unistd_64.h can not depend upon __NR_syscall_max, is before asm/asm-offsets.h is defined. Thus, the patch below passes in a '-DCREATE_OFFSETS' during the creation of asm/asm-offsets.h, so that we do not include it before it exists. The patch is hacky but works. thoughts?
---
Kbuild | 2 +- arch/x86/include/asm/unistd_64.h | 6 ++++++ scripts/Makefile.build | 4 ++++ 3 files changed, 11 insertions(+), 1 deletions(-)
Kbuild +1 -1
@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)
arch/x86/include/asm/unistd_64.h +6 -0
@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls *
scripts/Makefile.build +4 -0
@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 45 lines · * Jason Baron ([email protected]) wrote:
Quoted 36 lines · Jason Baron
Quoted 28 lines
Quoted 28 lines · Jason Baron
Quoted 14 lines
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +I'd rather see this in
arch/x86/include/unistd_64.h, sinceNR_syscallsseems to be the defined inunistd.hin all archs.Quoted 7 lines
Quoted 3 lines
That also makes a unified way to retrieve this number for other users.
Yes,
NR_syscallsshould be included there.-- Steve
Quoted 7 lines
right, for
x86_64,unistd.his included to generate__NR_syscall_maxwhich is then used forNR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...thanks,
-Jason
Quoted 8 lines
ok, since
unistd_64.his used to generateoffsets.c, which eventually generates,asm/asm-offsets.h, which defines,__NR_syscall_max, we can't just put #define ofNR_syscallsinunistd_64.h. However, it seems the only point in time thatunistd_64.hcan not depend upon__NR_syscall_max, is beforeasm/asm-offsets.his defined. Thus, the patch below passes in a '-DCREATE_OFFSETS' during the creation ofasm/asm-offsets.h, so that we do not include it before it exists. The patch is hacky but works. thoughts?
Ugh! My eyes hurt!
What you are doing here is to basically put back the hardcoded NR_syscalls rather that using the build infrastructure already in place.
If my memory serves me well, unistd_64.h generates __NR_syscall_max automatically by being included multiples times. Can we generalize this and make the information generated available in an automaticaly generated header instead ? It is saved in ams-offsets.h currently as "__NR_syscall_max". We could also save it somewhere else meant to be included by C code.
Mathieu
Quoted 60 lines
Signed-off-by Jason Baron <[email protected]>---
Kbuild | 2 +- arch/x86/include/asm/unistd_64.h | 6 ++++++ scripts/Makefile.build | 4 ++++ 3 files changed, 11 insertions(+), 1 deletions(-)Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 55 lines · Mathieu Desnoyers
Quoted 45 lines · * Jason Baron ([email protected]) wrote:
Quoted 36 lines · Jason Baron
Quoted 28 lines
Quoted 28 lines · Jason Baron
Quoted 14 lines
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +I'd rather see this in
arch/x86/include/unistd_64.h, sinceNR_syscallsseems to be the defined inunistd.hin all archs.Quoted 7 lines
Quoted 3 lines
That also makes a unified way to retrieve this number for other users.
Yes,
NR_syscallsshould be included there.-- Steve
Quoted 7 lines
right, for
x86_64,unistd.his included to generate__NR_syscall_maxwhich is then used forNR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...thanks,
-Jason
Quoted 8 lines
ok, since
unistd_64.his used to generateoffsets.c, which eventually generates,asm/asm-offsets.h, which defines,__NR_syscall_max, we can't just put #define ofNR_syscallsinunistd_64.h. However, it seems the only point in time thatunistd_64.hcan not depend upon__NR_syscall_max, is beforeasm/asm-offsets.his defined. Thus, the patch below passes in a '-DCREATE_OFFSETS' during the creation ofasm/asm-offsets.h, so that we do not include it before it exists. The patch is hacky but works. thoughts?
Quoted 2 lines
Ugh! My eyes hurt!
sorry :)
Quoted 3 lines
What you are doing here is to basically put back the hardcoded
NR_syscallsrather that using the build infrastructure already in place.
no. NR_syscalls is not hardcoded by this patch. Its defined in terms of __NR_syscall_max which is dynamically generated by the kernel build.
Quoted 9 lines
If my memory serves me well,
unistd_64.hgenerates__NR_syscall_maxautomatically by being included multiples times. Can we generalize this and make the information generated available in an automaticaly generated header instead ? It is saved inams-offsets.hcurrently as "__NR_syscall_max". We could also save it somewhere else meant to be included by C code.Mathieu
The request was to define NR_syscalls in unistd.h, since that is the historical Linux location for it. Adding another automatically generated header does not accomplish that. Even if I include that new file in unistd.h, I'm still going to have a circular dependency, and require a solution similar to what I've proposed.
thanks,
-Jason
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 75 lines · * Jason Baron ([email protected]) wrote:
Quoted 55 lines · Mathieu Desnoyers
Quoted 45 lines · * Jason Baron ([email protected]) wrote:
Quoted 36 lines · Jason Baron
Quoted 28 lines
Quoted 28 lines · Jason Baron
Quoted 14 lines
Add a dynamic definition of
NR_syscallsforx86_64. This is used in the syscall events tracing code.Signed-off-by Jason Baron <[email protected]>--- include/linux/ftrace.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/ftrace.h +0
-0include/linux/ftrace.h line 21
Quoted 8 lines
include/linux/ftrace.h +5
-0@@ -14,6 +14,11 @@#include <asm/ftrace.h> +#ifdef CONFIG_X86_64 +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +I'd rather see this in
arch/x86/include/unistd_64.h, sinceNR_syscallsseems to be the defined inunistd.hin all archs.Quoted 7 lines
Quoted 3 lines
That also makes a unified way to retrieve this number for other users.
Yes,
NR_syscallsshould be included there.-- Steve
Quoted 7 lines
right, for
x86_64,unistd.his included to generate__NR_syscall_maxwhich is then used forNR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...thanks,
-Jason
Quoted 8 lines
ok, since
unistd_64.his used to generateoffsets.c, which eventually generates,asm/asm-offsets.h, which defines,__NR_syscall_max, we can't just put #define ofNR_syscallsinunistd_64.h. However, it seems the only point in time thatunistd_64.hcan not depend upon__NR_syscall_max, is beforeasm/asm-offsets.his defined. Thus, the patch below passes in a '-DCREATE_OFFSETS' during the creation ofasm/asm-offsets.h, so that we do not include it before it exists. The patch is hacky but works. thoughts?Quoted 2 lines
Ugh! My eyes hurt!
sorry :)
Quoted 3 lines
What you are doing here is to basically put back the hardcoded
NR_syscallsrather that using the build infrastructure already in place.no.
NR_syscallsis not hardcoded by this patch. Its defined in terms of__NR_syscall_maxwhich is dynamically generated by the kernel build.Quoted 7 lines
If my memory serves me well,
unistd_64.hgenerates__NR_syscall_maxautomatically by being included multiples times. Can we generalize this and make the information generated available in an automaticaly generated header instead ? It is saved inams-offsets.hcurrently as "__NR_syscall_max". We could also save it somewhere else meant to be included by C code.
Quoted 9 lines
Quoted 2 lines
Mathieu
The request was to define
NR_syscallsinunistd.h, since that is the historical Linux location for it. Adding another automatically generated header does not accomplish that. Even if I include that new file inunistd.h, I'm still going to have a circular dependency, and require a solution similar to what I've proposed.
OK, it may not be pretty, but it makes sense. :)
Thanks,
Mathieu
Quoted 4 lines
thanks,
-Jason
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [PATCH 2/4] Add NR_syscalls for x86_64
In reply to Jason BaronQuoted 27 lines · Jason Baron
Quoted 1 line
Ugh! My eyes hurt!
sorry :)
Quoted 3 lines
What you are doing here is to basically put back the hardcoded
NR_syscallsrather that using the build infrastructure already in place.no.
NR_syscallsis not hardcoded by this patch. Its defined in terms of__NR_syscall_maxwhich is dynamically generated by the kernel build.Quoted 9 lines
If my memory serves me well,
unistd_64.hgenerates__NR_syscall_maxautomatically by being included multiples times. Can we generalize this and make the information generated available in an automaticaly generated header instead ? It is saved inams-offsets.hcurrently as "__NR_syscall_max". We could also save it somewhere else meant to be included by C code.Mathieu
The request was to define
NR_syscallsinunistd.h, since that is the historical Linux location for it. Adding another automatically generated header does not accomplish that. Even if I include that new file inunistd.h, I'm still going to have a circular dependency, and require a solution similar to what I've proposed.
Quoted 3 lines
thanks,
-Jason
Hmm, yeah that's not easy to deal with.
May be, to lower a bit the hacky impact of this patch, __NR_syscall_max should be at least replaced by NR_syscall in every x86-64 uses (also in asm-offsets.h), to standardize this variable name.
Also, may be we could have an empty asm-offsets.h stub in the very beginning that can be filled later so that we could include it unconditionnaly from unistd_64.h ?
It would be nice to have the opinion of an x86 maintainer about what to do.
Steven Rostedt
maintainerRe: [PATCH 2/4] Add NR_syscalls for x86_64
In reply to Jason BaronQuoted 6 lines · Jason Baron
Quoted 5 lines · Jason Baron
right, for
x86_64,unistd.his included to generate__NR_syscall_maxwhich is then used forNR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...
Quoted 7 lines
Quoted 3 lines
thanks,
-Jason
ok, since
unistd_64.his used to generateoffsets.c, which eventually generates,asm/asm-offsets.h, which defines,__NR_syscall_max, we can't just put #define ofNR_syscallsinunistd_64.h. However, it seems the
Why not? A define is not a problem until it is used. Is something in asm-offsets.c using NR_syscalls?
Quoted 51 lines
only point in time that
unistd_64.hcan not depend upon__NR_syscall_max, is beforeasm/asm-offsets.his defined. Thus, the patch below passes in a '-DCREATE_OFFSETS' during the creation ofasm/asm-offsets.h, so that we do not include it before it exists. The patch is hacky but works. thoughts?Signed-off-by Jason Baron <[email protected]>---
Kbuild | 2 +- arch/x86/include/asm/unistd_64.h | 6 ++++++ scripts/Makefile.build | 4 ++++ 3 files changed, 11 insertions(+), 1 deletions(-)Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +0
-0
scripts/Makefile.build $(multi-objs-y:.o=.lst) : modname = $(modname-multi) · line 153
Quoted 9 lines
scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)
Ug, yuck yuck yuck. Sometimes "it works" is not good enough ;-)
How about just adding in asm/unistd.h
#ifdef __KERNEL__
# ifdef CONFIG_X86_32 # include "unistd_32.h" # else # include "unistd_64.h" +# define NR_syscalls (__NR_syscall_max + 1) # endif #else # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # endif #endif
And if this is a problem because asm-offset_64.c includes asm/unistd.h, then make it just include unistd_64.h.
Or am I missing something?
-- Steve
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 100 lines · Steven Rostedt
Quoted 6 lines · Jason Baron
Quoted 5 lines · Jason Baron
right, for
x86_64,unistd.his included to generate__NR_syscall_maxwhich is then used forNR_syscalls. So I did initially try it there, but there were dependency problems. I'll see what I can come up with...Quoted 7 lines
Quoted 3 lines
thanks,
-Jason
ok, since
unistd_64.his used to generateoffsets.c, which eventually generates,asm/asm-offsets.h, which defines,__NR_syscall_max, we can't just put #define ofNR_syscallsinunistd_64.h. However, it seems theWhy not? A define is not a problem until it is used. Is something in
asm-offsets.cusingNR_syscalls?Quoted 51 lines
only point in time that
unistd_64.hcan not depend upon__NR_syscall_max, is beforeasm/asm-offsets.his defined. Thus, the patch below passes in a '-DCREATE_OFFSETS' during the creation ofasm/asm-offsets.h, so that we do not include it before it exists. The patch is hacky but works. thoughts?Signed-off-by Jason Baron <[email protected]>---
Kbuild | 2 +- arch/x86/include/asm/unistd_64.h | 6 ++++++ scripts/Makefile.build | 4 ++++ 3 files changed, 11 insertions(+), 1 deletions(-)Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +0
-0scripts/Makefile.build $(multi-objs-y:.o=.lst) : modname = $(modname-multi) · line 153
Quoted 9 lines
scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)Ug, yuck yuck yuck. Sometimes "it works" is not good enough ;-)
How about just adding in
asm/unistd.h#ifdef
__KERNEL__# ifdef CONFIG_X86_32 # include "unistd_32.h" # else # include "unistd_64.h" +# define NR_syscalls (__NR_syscall_max + 1) # endif #else # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # endif #endif
Quoted 8 lines
And if this is a problem because
asm-offset_64.cincludesasm/unistd.h, then make it just includeunistd_64.h.Or am I missing something?
-- Steve
ok, so using the above patch gives me:
CC arch/x86/kernel/ftrace.oarch/x86/kernel/ftrace.c: In function ‘syscall_nr_to_meta’:arch/x86/kernel/ftrace.c:497:35: error: ‘__NR_syscall_max’ undeclared (first use in this function) arch/x86/kernel/ftrace.c:497:35: error: (Each undeclared identifier is reported only oncearch/x86/kernel/ftrace.c:497:35: error: for each function it appears in.)arch/x86/kernel/ftrace.c: In function ‘syscall_name_to_nr’:arch/x86/kernel/ftrace.c:510:19: error: ‘__NR_syscall_max’ undeclared (first use in this function)arch/x86/kernel/ftrace.c: In function ‘arch_init_ftrace_syscalls’:arch/x86/kernel/ftrace.c:536:7: error: ‘__NR_syscall_max’ undeclared (first use in this function)
make[2]: *** [arch/x86/kernel/ftrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2
That is the the first time, I encounter a 'NR_syscalls' usage, we error, b/c unistd.h does not include 'asm/asm-offsets.h'. If I add an #include of 'asm/asm-offsets.h' to ftrace.c the compile is fine. But the point of this was to the 'NR_syscalls' definition just from the unistd.h file... I'll see if I can come up with a simpler patch.
thanks,
-Jason
Steven Rostedt
maintainerRe: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 95 lines · Jason Baron
Quoted 65 lines
Quoted 35 lines
Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +0
-0scripts/Makefile.build $(multi-objs-y:.o=.lst) : modname = $(modname-multi) · line 153
Quoted 9 lines
scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)Ug, yuck yuck yuck. Sometimes "it works" is not good enough ;-)
How about just adding in
asm/unistd.h#ifdef
__KERNEL__# ifdef CONFIG_X86_32 # include "unistd_32.h" # else # include "unistd_64.h" +# define NR_syscalls (__NR_syscall_max + 1) # endif #else # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # endif #endifQuoted 8 lines
And if this is a problem because
asm-offset_64.cincludesasm/unistd.h, then make it just includeunistd_64.h.Or am I missing something?
-- Steve
ok, so using the above patch gives me:
CC
arch/x86/kernel/ftrace.oarch/x86/kernel/ftrace.c: In function ?syscall_nr_to_meta?:arch/x86/kernel/ftrace.c:497:35: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c:497:35: error: (Each undeclared identifier is reported only oncearch/x86/kernel/ftrace.c:497:35: error: for each function it appears in.)arch/x86/kernel/ftrace.c: In function ?syscall_name_to_nr?:arch/x86/kernel/ftrace.c:510:19: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c: In function ?arch_init_ftrace_syscalls?:arch/x86/kernel/ftrace.c:536:7: error: ?__NR_syscall_max? undeclared (first use in this function)
make[2]: *** [arch/x86/kernel/ftrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2
Quoted 5 lines
That is the the first time, I encounter a '
NR_syscalls' usage, we error, b/cunistd.hdoes not include 'asm/asm-offsets.h'. If I add an #include of 'asm/asm-offsets.h' toftrace.cthe compile is fine. But the point of this was to the 'NR_syscalls' definition just from theunistd.hfile... I'll see if I can come up with a simpler patch.
Then add the asm/asm-offests.h to the x86_64 define in unistd.h and have the asm-offset_64.c only include the unistd_64.h file. Would that work?
-- Steve
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 102 lines · Steven Rostedt
Quoted 95 lines · Jason Baron
Quoted 65 lines
Quoted 35 lines
Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +0
-0scripts/Makefile.build $(multi-objs-y:.o=.lst) : modname = $(modname-multi) · line 153
Quoted 9 lines
scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)Ug, yuck yuck yuck. Sometimes "it works" is not good enough ;-)
How about just adding in
asm/unistd.h#ifdef
__KERNEL__# ifdef CONFIG_X86_32 # include "unistd_32.h" # else # include "unistd_64.h" +# define NR_syscalls (__NR_syscall_max + 1) # endif #else # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # endif #endifQuoted 8 lines
And if this is a problem because
asm-offset_64.cincludesasm/unistd.h, then make it just includeunistd_64.h.Or am I missing something?
-- Steve
ok, so using the above patch gives me:
CC
arch/x86/kernel/ftrace.oarch/x86/kernel/ftrace.c: In function ?syscall_nr_to_meta?:arch/x86/kernel/ftrace.c:497:35: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c:497:35: error: (Each undeclared identifier is reported only oncearch/x86/kernel/ftrace.c:497:35: error: for each function it appears in.)arch/x86/kernel/ftrace.c: In function ?syscall_name_to_nr?:arch/x86/kernel/ftrace.c:510:19: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c: In function ?arch_init_ftrace_syscalls?:arch/x86/kernel/ftrace.c:536:7: error: ?__NR_syscall_max? undeclared (first use in this function)
make[2]: *** [arch/x86/kernel/ftrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2Quoted 5 lines
That is the the first time, I encounter a '
NR_syscalls' usage, we error, b/cunistd.hdoes not include 'asm/asm-offsets.h'. If I add an #include of 'asm/asm-offsets.h' toftrace.cthe compile is fine. But the point of this was to the 'NR_syscalls' definition just from theunistd.hfile... I'll see if I can come up with a simpler patch.
Quoted 5 lines
Then add the
asm/asm-offests.hto thex86_64define inunistd.hand have theasm-offset_64.conly include theunistd_64.hfile. Would that work?-- Steve
doesn't quite work, b/c the top of asm-offsets_64.c has a bunch of includes, such as: <linux/sched.h>, which in turn include unistd.h at a point in time where asm/asm-offests.h does not exist.
However, a much simpler version of the previous patch I posted does do the trick, below. I hope this version is more palatable?
thanks,
-Jason
arch/x86/include/asm/unistd_64.h +6 -0
@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef COMPILE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls *
arch/x86/kernel/asm-offsets_64.c +1 -0
@@ -3,6 +3,7 @@* This code generates raw asm output which is post-processed to extract * and format the required data. */ +#define COMPILE_OFFSETS #include <linux/crypto.h> #include <linux/sched.h>
Re: [PATCH 2/4] Add NR_syscalls for x86_64
Quoted 144 lines · Jason Baron
Quoted 102 lines · Steven Rostedt
Quoted 95 lines · Jason Baron
Quoted 65 lines
Quoted 35 lines
Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +0
-0scripts/Makefile.build $(multi-objs-y:.o=.lst) : modname = $(modname-multi) · line 153
Quoted 9 lines
scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)Ug, yuck yuck yuck. Sometimes "it works" is not good enough ;-)
How about just adding in
asm/unistd.h#ifdef
__KERNEL__# ifdef CONFIG_X86_32 # include "unistd_32.h" # else # include "unistd_64.h" +# define NR_syscalls (__NR_syscall_max + 1) # endif #else # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # endif #endifQuoted 8 lines
And if this is a problem because
asm-offset_64.cincludesasm/unistd.h, then make it just includeunistd_64.h.Or am I missing something?
-- Steve
ok, so using the above patch gives me:
CC
arch/x86/kernel/ftrace.oarch/x86/kernel/ftrace.c: In function ?syscall_nr_to_meta?:arch/x86/kernel/ftrace.c:497:35: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c:497:35: error: (Each undeclared identifier is reported only oncearch/x86/kernel/ftrace.c:497:35: error: for each function it appears in.)arch/x86/kernel/ftrace.c: In function ?syscall_name_to_nr?:arch/x86/kernel/ftrace.c:510:19: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c: In function ?arch_init_ftrace_syscalls?:arch/x86/kernel/ftrace.c:536:7: error: ?__NR_syscall_max? undeclared (first use in this function)
make[2]: *** [arch/x86/kernel/ftrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2Quoted 5 lines
That is the the first time, I encounter a '
NR_syscalls' usage, we error, b/cunistd.hdoes not include 'asm/asm-offsets.h'. If I add an #include of 'asm/asm-offsets.h' toftrace.cthe compile is fine. But the point of this was to the 'NR_syscalls' definition just from theunistd.hfile... I'll see if I can come up with a simpler patch.Quoted 5 lines
Then add the
asm/asm-offests.hto thex86_64define inunistd.hand have theasm-offset_64.conly include theunistd_64.hfile. Would that work?-- Steve
doesn't quite work, b/c the top of
asm-offsets_64.chas a bunch of includes, such as: <linux/sched.h>, which in turn includeunistd.hat a point in time whereasm/asm-offests.hdoes not exist.However, a much simpler version of the previous patch I posted does do the trick, below. I hope this version is more palatable?
thanks,
-Jason
Signed-off-by Jason Baron <[email protected]>arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef COMPILE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * arch/x86/kernel/asm-offsets_64.c +0
-0
arch/x86/kernel/asm-offsets_64.c line 9
Quoted 7 lines
arch/x86/kernel/asm-offsets_64.c +1
-0@@ -3,6 +3,7 @@* This code generates raw asm output which is post-processed to extract * and format the required data. */ +#define COMPILE_OFFSETS #include <linux/crypto.h> #include <linux/sched.h>
This is MUCH more acceptable.
Thanks!
-- Steve
Re: [PATCH 2/4] Add NR_syscalls for x86_64
In reply to Jason BaronQuoted 4 lines · Jason Baron
doesn't quite work, b/c the top of
asm-offsets_64.chas a bunch of includes, such as: <linux/sched.h>, which in turn includeunistd.hat a point in time whereasm/asm-offests.hdoes not exist.
Quoted 8 lines
However, a much simpler version of the previous patch I posted does do the trick, below. I hope this version is more palatable?
thanks,
-Jason
Signed-off-by Jason Baron <[email protected]>
Ah yeah, looks good!
Quoted 30 lines
arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef COMPILE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * arch/x86/kernel/asm-offsets_64.c +1
-0@@ -3,6 +3,7 @@* This code generates raw asm output which is post-processed to extract * and format the required data. */ +#define COMPILE_OFFSETS #include <linux/crypto.h> #include <linux/sched.h>
Re: [PATCH 2/4] Add NR_syscalls for x86_64
In reply to Steven RostedtQuoted 152 lines · Steven Rostedt
Quoted 149 lines · Jason Baron
Quoted 102 lines · Steven Rostedt
Quoted 95 lines · Jason Baron
Quoted 65 lines
Quoted 35 lines
Kbuild +1
-1@@ -78,7 +78,7 @@ endef arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(obj)/$(bounds-file) FORCE $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) + $(call if_changed_dep,cc_s_c_define_offset) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(call cmd,offsets)arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef CREATE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * scripts/Makefile.build +0
-0scripts/Makefile.build $(multi-objs-y:.o=.lst) : modname = $(modname-multi) · line 153
Quoted 9 lines
scripts/Makefile.build +4
-0@@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag) $@ +cmd_cc_s_c_define_offset = $(CC) $(c_flags) -DCREATE_OFFSETS \ + -fverbose-asm -S -o $@ $< + $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c)Ug, yuck yuck yuck. Sometimes "it works" is not good enough ;-)
How about just adding in
asm/unistd.h#ifdef
__KERNEL__# ifdef CONFIG_X86_32 # include "unistd_32.h" # else # include "unistd_64.h" +# define NR_syscalls (__NR_syscall_max + 1) # endif #else # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # endif #endifQuoted 8 lines
And if this is a problem because
asm-offset_64.cincludesasm/unistd.h, then make it just includeunistd_64.h.Or am I missing something?
-- Steve
ok, so using the above patch gives me:
CC
arch/x86/kernel/ftrace.oarch/x86/kernel/ftrace.c: In function ?syscall_nr_to_meta?:arch/x86/kernel/ftrace.c:497:35: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c:497:35: error: (Each undeclared identifier is reported only oncearch/x86/kernel/ftrace.c:497:35: error: for each function it appears in.)arch/x86/kernel/ftrace.c: In function ?syscall_name_to_nr?:arch/x86/kernel/ftrace.c:510:19: error: ?__NR_syscall_max? undeclared (first use in this function)arch/x86/kernel/ftrace.c: In function ?arch_init_ftrace_syscalls?:arch/x86/kernel/ftrace.c:536:7: error: ?__NR_syscall_max? undeclared (first use in this function)
make[2]: *** [arch/x86/kernel/ftrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2Quoted 5 lines
That is the the first time, I encounter a '
NR_syscalls' usage, we error, b/cunistd.hdoes not include 'asm/asm-offsets.h'. If I add an #include of 'asm/asm-offsets.h' toftrace.cthe compile is fine. But the point of this was to the 'NR_syscalls' definition just from theunistd.hfile... I'll see if I can come up with a simpler patch.Quoted 5 lines
Then add the
asm/asm-offests.hto thex86_64define inunistd.hand have theasm-offset_64.conly include theunistd_64.hfile. Would that work?-- Steve
doesn't quite work, b/c the top of
asm-offsets_64.chas a bunch of includes, such as: <linux/sched.h>, which in turn includeunistd.hat a point in time whereasm/asm-offests.hdoes not exist.However, a much simpler version of the previous patch I posted does do the trick, below. I hope this version is more palatable?
thanks,
-Jason
Signed-off-by Jason Baron <[email protected]>arch/x86/include/asm/unistd_64.h +6
-0@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef COMPILE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls * arch/x86/kernel/asm-offsets_64.c +1
-0@@ -3,6 +3,7 @@* This code generates raw asm output which is post-processed to extract * and format the required data. */ +#define COMPILE_OFFSETS
Quoted 6 lines
arch/x86/kernel/asm-offsets_64.c line 9
Quoted 2 lines
arch/x86/kernel/asm-offsets_64.c +0
-0#include <linux/crypto.h> #include <linux/sched.h> This is MUCH more acceptable.
Acked-by Steven Rostedt <[email protected]>
Great, I'm applying the whole series then,
Thanks!
Quoted 4 lines
Thanks!
-- Steve
[tip:tracing/core] tracing: Define NR_syscalls for x86 (32)
In reply to Jason BaronCommit-ID: dd86dda24cc1dc70031a7d9250dc3c0c430a50e2 Gitweb: http://git.kernel.org/tip/dd86dda24cc1dc70031a7d9250dc3c0c430a50e2 Author: Jason Baron <[email protected]> AuthorDate: Mon, 24 Aug 2009 17:40:14 -0400 Committer: Frederic Weisbecker <[email protected]> CommitDate: Wed, 26 Aug 2009 21:29:55 +0200
tracing: Define NR_syscalls for x86 (32)
Add a NR_syscalls #define for x86. This is used in the syscall events tracing code. Todo: make it dynamic like x86_64.
NR_syscalls is the usual name used to determine the number of syscalls supported by the current arch. We want to unify the use of this number across archs that support the syscall tracing. This also prepare to move some of the arch code to core code in the syscall tracing area.
LKML-Reference: <0f33c0f96d198fccc3ddd9ff7f5334ff5cb42706.1251146513.git.jbaron@redhat.com>
--- arch/x86/include/asm/unistd_32.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/include/asm/unistd_32.h +2 -0
@@ -345,6 +345,8 @@#ifdef __KERNEL__ +#define NR_syscalls 337 +#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR#define __ARCH_WANT_OLD_STAT
[tip:tracing/core] tracing: Define NR_syscalls for x86_64
In reply to Jason BaronCommit-ID: a5a2f8e2acb991327952c45a13f5441fc09dffd6 Gitweb: http://git.kernel.org/tip/a5a2f8e2acb991327952c45a13f5441fc09dffd6 Author: Jason Baron <[email protected]> AuthorDate: Wed, 26 Aug 2009 12:09:10 -0400 Committer: Frederic Weisbecker <[email protected]> CommitDate: Wed, 26 Aug 2009 21:29:58 +0200
tracing: Define NR_syscalls for x86_64
Express the available number of syscalls in a standard way by defining NR_syscalls.
The common way to define it is to place its definition in asm/unistd.h However, the number of syscalls is defined using __NR_syscall_max in x86-64 after building a dynamic header file "asm-offsets.h"
The source file that generates this header, asm-offsets-64.c includes unistd.h, then if we want to express NR_syscalls from __NR_syscall_max in unistd.h only after generating the dynamic header file, we need a watchguard.
If unistd.h is included from asm-offsets-64.c, then we are generating asm-offset.h which defines __NR_syscall_max. At this time, we don't want to (we can't) define NR_syscalls, then we do nothing. Otherwise we define NR_syscalls because we know asm-offsets.h has been generated.
LKML-Reference: <[email protected]>
--- arch/x86/include/asm/unistd_64.h | 6 ++++++ arch/x86/kernel/asm-offsets_64.c | 1 + 2 files changed, 7 insertions(+), 0 deletions(-)
arch/x86/include/asm/unistd_64.h +6 -0
@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)#endif /* __NO_STUBS */ #ifdef __KERNEL__ + +#ifndef COMPILE_OFFSETS +#include <asm/asm-offsets.h> +#define NR_syscalls (__NR_syscall_max + 1) +#endif +/* * "Conditional" syscalls *
arch/x86/kernel/asm-offsets_64.c +1 -0
@@ -3,6 +3,7 @@* This code generates raw asm output which is post-processed to extract * and format the required data. */ +#define COMPILE_OFFSETS #include <linux/crypto.h> #include <linux/sched.h>
[tip:tracing/core] tracing: Convert event tracing code to use NR_syscalls
In reply to Jason BaronCommit-ID: 57421dbbdc932d65f0e6a41ebb027a2bfe3d0669 Gitweb: http://git.kernel.org/tip/57421dbbdc932d65f0e6a41ebb027a2bfe3d0669 Author: Jason Baron <[email protected]> AuthorDate: Mon, 24 Aug 2009 17:40:22 -0400 Committer: Frederic Weisbecker <[email protected]> CommitDate: Wed, 26 Aug 2009 21:30:02 +0200
tracing: Convert event tracing code to use NR_syscalls
Convert the syscalls event tracing code to use NR_syscalls, instead of FTRACE_SYSCALL_MAX. NR_syscalls is standard accross most arches, and reduces code confusion/complexity.
LKML-Reference: <9b4f1a84ecae57cc6599412772efa36f0d2b815b.1251146513.git.jbaron@redhat.com>
--- arch/x86/kernel/ftrace.c | 8 ++++---- kernel/trace/trace_syscalls.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/kernel/ftrace.c +4 -4
@@ -494,7 +494,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)struct syscall_metadata *syscall_nr_to_meta (int nr) { -if (!syscalls_metadata || nr >=FTRACE_SYSCALL_MAX || nr <0 ) +if (!syscalls_metadata || nr >= NR_syscalls || nr <0 )return NULL ;return syscalls_metadata[nr];
@@ -507,7 +507,7 @@ int syscall_name_to_nr(char *name)if (!syscalls_metadata)return -1 ; -for (i =0 ; i <FTRACE_SYSCALL_MAX ; i++) { +for (i =0 ; i < NR_syscalls; i++) {if (syscalls_metadata[i]) {if (!strcmp (syscalls_metadata[i]->name, name))return i;
@@ -533,13 +533,13 @@ static int __init arch_init_ftrace_syscalls(void)unsigned long **psys_syscall_table = &sys_call_table; syscalls_metadata =kzalloc (sizeof (*syscalls_metadata) * -FTRACE_SYSCALL_MAX ,GFP_KERNEL ); + NR_syscalls,GFP_KERNEL );if (!syscalls_metadata) {WARN_ON (1 );return -ENOMEM ; } -for (i =0 ; i <FTRACE_SYSCALL_MAX ; i++) { +for (i =0 ; i < NR_syscalls; i++) { meta =find_syscall_meta (psys_syscall_table[i]); syscalls_metadata[i] = meta; }
kernel/trace/trace_syscalls.c +12 -12
@@ -11,8 +11,8 @@static DEFINE_MUTEX (syscall_trace_lock);static int sys_refcount_enter;static int sys_refcount_exit; -static DECLARE_BITMAP(enabled_enter_syscalls, FTRACE_SYSCALL_MAX); -static DECLARE_BITMAP(enabled_exit_syscalls, FTRACE_SYSCALL_MAX); +static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls); +static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);enum print_line_t print_syscall_enter (struct trace_iterator *iter,int flags)
@@ -289,7 +289,7 @@ int reg_event_syscall_enter(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);if (!sys_refcount_enter)
@@ -312,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock); sys_refcount_enter--;
@@ -330,7 +330,7 @@ int reg_event_syscall_exit(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);if (!sys_refcount_exit)
@@ -353,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr) name = (char *)ptr; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock); sys_refcount_exit--;
@@ -373,8 +373,8 @@ struct trace_event event_syscall_exit = {#ifdef CONFIG_EVENT_PROFILE -static DECLARE_BITMAP(enabled_prof_enter_syscalls, FTRACE_SYSCALL_MAX); -static DECLARE_BITMAP(enabled_prof_exit_syscalls, FTRACE_SYSCALL_MAX); +static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls); +static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls);static int sys_prof_refcount_enter;static int sys_prof_refcount_exit;
@@ -420,7 +420,7 @@ int reg_prof_syscall_enter(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);
@@ -442,7 +442,7 @@ void unreg_prof_syscall_enter(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock);
@@ -481,7 +481,7 @@ int reg_prof_syscall_exit(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return -ENOSYS ;mutex_lock (&syscall_trace_lock);
@@ -503,7 +503,7 @@ void unreg_prof_syscall_exit(char *name)int num; num =syscall_name_to_nr (name); -if (num <0 || num >=FTRACE_SYSCALL_MAX ) +if (num <0 || num >= NR_syscalls)return ;mutex_lock (&syscall_trace_lock);
[tip:tracing/core] tracing: Remove FTRACE_SYSCALL_MAX definitions
In reply to Jason BaronCommit-ID: 117226d15850387b55fd01675917ee4fcb9699e8 Gitweb: http://git.kernel.org/tip/117226d15850387b55fd01675917ee4fcb9699e8 Author: Jason Baron <[email protected]> AuthorDate: Mon, 24 Aug 2009 17:40:26 -0400 Committer: Frederic Weisbecker <[email protected]> CommitDate: Wed, 26 Aug 2009 21:30:39 +0200
tracing: Remove FTRACE_SYSCALL_MAX definitions
Remove the FTRACE_SYSCALL_MAX definitions now that we have converted the syscall event tracing code to use NR_syscalls.
LKML-Reference: <f2240cdc8f0b1ca7617390c8f5ec90ba2bd348cf.1251146513.git.jbaron@redhat.com>
--- arch/x86/include/asm/ftrace.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
arch/x86/include/asm/ftrace.h +0 -7
@@ -28,13 +28,6 @@#endif -/* FIXME: I don't want to stay hardcoded */ -#ifdef CONFIG_X86_64 -# define FTRACE_SYSCALL_MAX 299 -#else -# define FTRACE_SYSCALL_MAX 337 -#endif -#ifdef CONFIG_FUNCTION_TRACER #define MCOUNT_ADDR ((long)(mcount))#define MCOUNT_INSN_SIZE 5/* sizeof mcount call */