[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <77feea14-0eff-433d-a3af-b1eb973efce8@default>
Date: Tue, 9 Aug 2011 08:03:52 -0700 (PDT)
From: Dan Magenheimer <dan.magenheimer@...cle.com>
To: Jan Beulich <JBeulich@...ell.com>
Cc: hannes@...xchg.org, jackdachef@...il.com, hughd@...gle.com,
jeremy@...p.org, npiggin@...nel.dk, linux-mm@...ck.org,
akpm@...ux-foundation.org, sjenning@...ux.vnet.ibm.com,
Chris Mason <chris.mason@...cle.com>,
Konrad Wilk <konrad.wilk@...cle.com>,
Kurt Hackel <kurt.hackel@...cle.com>, riel@...hat.com,
ngupta@...are.org, linux-kernel@...r.kernel.org, matthew@....cx
Subject: RE: Subject: [PATCH V6 2/4] mm: frontswap: core code
> > +#ifndef CONFIG_FRONTSWAP
> > +/* all inline routines become no-ops and all externs are ignored */
> > +#define frontswap_enabled (0)
> > +#endif
> > +
> > +static inline int frontswap_test(struct swap_info_struct *sis, pgoff_t
> > offset)
> > +{
> > + int ret = 0;
> > +
> > + if (frontswap_enabled && sis->frontswap_map)
> > + ret = test_bit(offset % BITS_PER_LONG,
> > + &sis->frontswap_map[offset/BITS_PER_LONG]);
>
> if (sis->frontswap_map)
> ret = test_bit(offset, sis->frontswap_map);
>
> (since sis->frontswap_map can't be non-NULL without
> frontswap_enabled being true, and since test_bit() itself already
> does what you open-coded here.
Hi Jan --
Thanks for the review!
> since test_bit() itself already does what you open-coded here
Good catch. Will change. Either is correct and I suspect the
compiler may end up generating the same code, but your code
is much more succinct.
> (since sis->frontswap_map can't be non-NULL without
> frontswap_enabled being true
As noted in the comment immediately preceding, the frontswap_enabled
check serves a second purpose: When CONFIG_FRONTSWAP is
disabled, this entire inline function devolves to a compile-time
constant (0), which avoids a handful of ifdef's in the
core swap subsystem. (This approach was originally suggested
for cleancache by Jeremy Fitzhardinge.)
Also, though this patch never unsets frontswap_enabled, it is
a global and some future tmem backend might unset it, so
it's probably best to leave the extra test anyway.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists