lkml.org 
[lkml]   [2009]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] proc: export more page flags in /proc/kpageflags
On Wed, 29 Apr 2009 10:38:42 +0800 Wu Fengguang <fengguang.wu@intel.com> wrote:

> > > +#define kpf_copy_bit(uflags, kflags, visible, ubit, kbit) \
> > > + do { \
> > > + if (visible || genuine_linus()) \
> > > + uflags |= ((kflags >> kbit) & 1) << ubit; \
> > > + } while (0);
> >
> > Did this have to be implemented as a macro?
> >
> > It's bad, because it might or might not reference its argument, so if
> > someone passes it an expression-with-side-effects, the end result is
> > unpredictable. A C function is almost always preferable if possible.
>
> Just tried inline function, the code size is increased slightly:
>
> text data bss dec hex filename
> macro 1804 128 0 1932 78c fs/proc/page.o
> inline 1828 128 0 1956 7a4 fs/proc/page.o
>

hm, I wonder why. Maybe it fixed a bug ;)

The code is effectively doing

if (expr1)
something();
if (expr1)
something_else();
if (expr1)
something_else2();

etc. Obviously we _hope_ that the compiler turns that into

if (expr1) {
something();
something_else();
something_else2();
}

for us, but it would be good to check...


\
 
 \ /
  Last update: 2009-04-29 05:05    [W:0.238 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site