Re: [PATCH 1/2] ftrace: nmi safe code modification
[Posted November 5, 2008 by corbet]
From: |
| Andrew Morton <akpm-AT-linux-foundation.org> |
To: |
| Steven Rostedt <rostedt-AT-goodmis.org> |
Subject: |
| Re: [PATCH 1/2] ftrace: nmi safe code modification |
Date: |
| Thu, 30 Oct 2008 14:10:48 -0700 |
Message-ID: |
| <20081030141048.904c82e1.akpm@linux-foundation.org> |
Cc: |
| linux-kernel-AT-vger.kernel.org, mingo-AT-elte.hu, tglx-AT-linutronix.de,
peterz-AT-infradead.org, torvalds-AT-linux-foundation.org,
srostedt-AT-redhat.com |
Archive‑link: | |
Article |
On Thu, 30 Oct 2008 16:58:55 -0400 (EDT)
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 30 Oct 2008, Andrew Morton wrote:
> >
> > > +#ifndef __ASSEMBLY__
> > > +#define ftrace_nmi_enter() do { } while (0)
> > > +#define ftrace_nmi_exit() do { } while (0)
> > > +#endif
> > > ...
> > > +#ifndef __ASSEMBLY__
> > > +#define ftrace_nmi_enter() do { } while (0)
> > > +#define ftrace_nmi_exit() do { } while (0)
> > > +#endif
> >
> > These could all be written in C. If there's a reson to write them in
> > cpp then the `#ifndef __ASSEMBLY__' isn't really needed.
>
> I could do the C macro, and you are right, I did not need the __ASSEMBLY__
> part. I guess that was me just being over-protective :-/
>
> Which would you prefer? Changing to C or removing the __ASSEMBLY__?
From a general perspective, C is better. Has typechecking, adds a ref
to the arguments which can prevent unused-var warnings, easier to read
and maintain, more likely to be commented, known about by debug info,
doesn't all get clumped into a single line in debug info, easier/safer
to uninline, blah, blah.
Also it seems a bit weird to do
#ifdef SOMETHING
#define foo(...) ...
#else
extern void foo(...);
#endif
Doing it in C has the downside that more things need to be visible at
the definition site, so more includes might be needed. Often fixable
by uninlining.
I dunno. People seem to instinctively reach for a macro without
thinking, because that's how grandpa did it or something.