All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	lethal@linux-sh.org, mingo@elte.hu, laijs@cn.fujitsu.com,
	peterz@infradead.org, mathieu.desnoyers@polymtl.ca,
	jiayingz@google.com, mbligh@google.com, lizf@cn.fujitsu.com,
	jistone@redhat.com, tglx@linutronix.de, hpa@zytor.com
Subject: Re: [PATCH 2/4] Add NR_syscalls for x86_64
Date: Wed, 26 Aug 2009 09:58:54 -0400	[thread overview]
Message-ID: <20090826135854.GA2658@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.00.0908252223310.28127@gandalf.stny.rr.com>

On Tue, Aug 25, 2009 at 10:25:52PM -0400, Steven Rostedt wrote:
> On Tue, 25 Aug 2009, Jason Baron wrote:
> 
> > On Tue, Aug 25, 2009 at 09:40:05AM -0400, Jason Baron wrote:
> > > 
> > > 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
> > 
> > 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
> 
> Why not? A define is not a problem until it is used. Is something in 
> asm-offsets.c using NR_syscalls?
> 
> > 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?
> > 
> > Signed-off-by: Jason Baron <jbaron@redhat.com>
> > 
> > ---
> > 
> >  Kbuild                           |    2 +-
> >  arch/x86/include/asm/unistd_64.h |    6 ++++++
> >  scripts/Makefile.build           |    4 ++++
> >  3 files changed, 11 insertions(+), 1 deletions(-)
> > 
> > 
> > diff --git a/Kbuild b/Kbuild
> > index f056b4f..5f43d4d 100644
> > --- a/Kbuild
> > +++ b/Kbuild
> > @@ -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)
> > diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h
> > index 900e161..70c0c3d 100644
> > --- a/arch/x86/include/asm/unistd_64.h
> > +++ b/arch/x86/include/asm/unistd_64.h
> > @@ -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
> >   *
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 5c4b7a4..4177858 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -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
> 
> 

ok, so using the above patch gives me:

  CC      arch/x86/kernel/ftrace.o
arch/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 once
arch/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


  reply	other threads:[~2009-08-26 14:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24 21:40 [PATCH 0/4] use NR_syscalls instead of FTRACE_SYSCALL_MAX Jason Baron
2009-08-24 21:40 ` [PATCH 1/4] add NR_syscalls define for x86 Jason Baron
2009-08-24 22:05   ` Paul Mundt
2009-08-25 13:37     ` Jason Baron
2009-08-28 12:28   ` [tip:tracing/core] tracing: Define NR_syscalls for x86 (32) tip-bot for Jason Baron
2009-08-24 21:40 ` [PATCH 2/4] Add NR_syscalls for x86_64 Jason Baron
2009-08-24 22:14   ` Frederic Weisbecker
2009-08-24 22:44     ` Steven Rostedt
2009-08-25 13:40       ` Jason Baron
2009-08-25 18:47         ` Jason Baron
2009-08-25 19:04           ` Mathieu Desnoyers
2009-08-25 20:58             ` Jason Baron
2009-08-25 23:28               ` Mathieu Desnoyers
2009-08-25 23:38               ` Frederic Weisbecker
2009-08-26  2:25           ` Steven Rostedt
2009-08-26 13:58             ` Jason Baron [this message]
2009-08-26 14:39               ` Steven Rostedt
2009-08-26 16:09                 ` Jason Baron
2009-08-26 16:21                   ` Steven Rostedt
2009-08-26 16:29                     ` Frederic Weisbecker
2009-08-26 16:24                   ` Frederic Weisbecker
2009-08-28 12:28                   ` [tip:tracing/core] tracing: Define " tip-bot for Jason Baron
2009-08-24 21:40 ` [PATCH 3/4] Convert event tracing code to NR_syscalls Jason Baron
2009-08-28 12:28   ` [tip:tracing/core] tracing: Convert event tracing code to use NR_syscalls tip-bot for Jason Baron
2009-08-24 21:40 ` [PATCH 4/4] remove FTRACE_SYSCALL_MAX definitions Jason Baron
2009-08-28 12:28   ` [tip:tracing/core] tracing: Remove " tip-bot for Jason Baron

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=20090826135854.GA2658@redhat.com \
    --to=jbaron@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jiayingz@google.com \
    --cc=jistone@redhat.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mbligh@google.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.