linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Jan Beulich <JBeulich@novell.com>
Cc: hannes@cmpxchg.org, jackdachef@gmail.com, hughd@google.com,
	jeremy@goop.org, npiggin@kernel.dk, linux-mm@kvack.org,
	akpm@linux-foundation.org, sjenning@linux.vnet.ibm.com,
	Chris Mason <chris.mason@oracle.com>,
	Konrad Wilk <konrad.wilk@oracle.com>,
	Kurt Hackel <kurt.hackel@oracle.com>,
	riel@redhat.com, ngupta@vflare.org, linux-kernel@vger.kernel.org,
	matthew@wil.cx
Subject: RE: Subject: [PATCH V6 2/4] mm: frontswap: core code
Date: Tue, 9 Aug 2011 08:03:52 -0700 (PDT)	[thread overview]
Message-ID: <77feea14-0eff-433d-a3af-b1eb973efce8@default> (raw)
In-Reply-To: <4E41439D0200007800050581@nat28.tlf.novell.com>

> > +#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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2011-08-09 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08 20:46 Subject: [PATCH V6 2/4] mm: frontswap: core code Dan Magenheimer
2011-08-09 12:26 ` Jan Beulich
2011-08-09 15:03   ` Dan Magenheimer [this message]

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=77feea14-0eff-433d-a3af-b1eb973efce8@default \
    --to=dan.magenheimer@oracle.com \
    --cc=JBeulich@novell.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris.mason@oracle.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=jackdachef@gmail.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=kurt.hackel@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew@wil.cx \
    --cc=ngupta@vflare.org \
    --cc=npiggin@kernel.dk \
    --cc=riel@redhat.com \
    --cc=sjenning@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).