All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Namhyung Kim <namhyung@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: cleanup gfp_zone()
Date: Tue, 28 Sep 2010 14:45:18 -0700	[thread overview]
Message-ID: <20100928144518.0eaf1099.akpm@linux-foundation.org> (raw)
In-Reply-To: <20100928214141.GG19804@ZenIV.linux.org.uk>

On Tue, 28 Sep 2010 22:41:42 +0100
Al Viro <viro@ZenIV.linux.org.uk> wrote:

> On Tue, Sep 28, 2010 at 02:32:39PM -0700, Andrew Morton wrote:
> > > +#define ZT_SHIFT(gfp) ((__force int) (gfp) * ZONES_SHIFT)
> > >  #define GFP_ZONE_TABLE ( \
> > > -	(ZONE_NORMAL << 0 * ZONES_SHIFT)				\
> > > -	| (OPT_ZONE_DMA << __GFP_DMA * ZONES_SHIFT)			\
> > > -	| (OPT_ZONE_HIGHMEM << __GFP_HIGHMEM * ZONES_SHIFT)		\
> > > -	| (OPT_ZONE_DMA32 << __GFP_DMA32 * ZONES_SHIFT)			\
> > > -	| (ZONE_NORMAL << __GFP_MOVABLE * ZONES_SHIFT)			\
> > > -	| (OPT_ZONE_DMA << (__GFP_MOVABLE | __GFP_DMA) * ZONES_SHIFT)	\
> > > -	| (ZONE_MOVABLE << (__GFP_MOVABLE | __GFP_HIGHMEM) * ZONES_SHIFT)\
> > > -	| (OPT_ZONE_DMA32 << (__GFP_MOVABLE | __GFP_DMA32) * ZONES_SHIFT)\
> > > +	(ZONE_NORMAL        << ZT_SHIFT(0))				\
> > > +	| (OPT_ZONE_DMA     << ZT_SHIFT(__GFP_DMA))			\
> > > +	| (OPT_ZONE_HIGHMEM << ZT_SHIFT(__GFP_HIGHMEM))			\
> > > +	| (OPT_ZONE_DMA32   << ZT_SHIFT(__GFP_DMA32))			\
> > > +	| (ZONE_NORMAL      << ZT_SHIFT(__GFP_MOVABLE))			\
> > > +	| (OPT_ZONE_DMA     << ZT_SHIFT(__GFP_MOVABLE | __GFP_DMA))	\
> > > +	| (ZONE_MOVABLE     << ZT_SHIFT(__GFP_MOVABLE | __GFP_HIGHMEM)) \
> > > +	| (OPT_ZONE_DMA32   << ZT_SHIFT(__GFP_MOVABLE | __GFP_DMA32))	\
> > >  )
> > 
> > hm.  I hope these sparse warnings are sufficiently useful to justify
> > all the gunk we're adding to support them.
> > 
> > Is it actually finding any bugs?
> 
> FWIW, bitwise or done in the right-hand argumet of shift looks ugly as hell;
> what the hell is that code _doing_?

There's a nice fat comment a few lines up...

/*
 * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
 * zone to use given the lowest 4 bits of gfp_t. Entries are ZONE_SHIFT long
 * and there are 16 of them to cover all possible combinations of
 * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
 *
 * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
 * But GFP_MOVABLE is not only a zone specifier but also an allocation
 * policy. Therefore __GFP_MOVABLE plus another zone selector is valid.
 * Only 1 bit of the lowest 3 bits (DMA,DMA32,HIGHMEM) can be set to "1".
 *
 *       bit       result
 *       =================
 *       0x0    => NORMAL
 *       0x1    => DMA or NORMAL
 *       0x2    => HIGHMEM or NORMAL
 *       0x3    => BAD (DMA+HIGHMEM)
 *       0x4    => DMA32 or DMA or NORMAL
 *       0x5    => BAD (DMA+DMA32)
 *       0x6    => BAD (HIGHMEM+DMA32)
 *       0x7    => BAD (HIGHMEM+DMA32+DMA)
 *       0x8    => NORMAL (MOVABLE+0)
 *       0x9    => DMA or NORMAL (MOVABLE+DMA)
 *       0xa    => MOVABLE (Movable is valid only if HIGHMEM is set too)
 *       0xb    => BAD (MOVABLE+HIGHMEM+DMA)
 *       0xc    => DMA32 (MOVABLE+HIGHMEM+DMA32)
 *       0xd    => BAD (MOVABLE+DMA32+DMA)
 *       0xe    => BAD (MOVABLE+DMA32+HIGHMEM)
 *       0xf    => BAD (MOVABLE+DMA32+HIGHMEM+DMA)
 *
 * ZONES_SHIFT must be <= 2 on 32 bit platforms.
 */


WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Namhyung Kim <namhyung@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: cleanup gfp_zone()
Date: Tue, 28 Sep 2010 14:45:18 -0700	[thread overview]
Message-ID: <20100928144518.0eaf1099.akpm@linux-foundation.org> (raw)
In-Reply-To: <20100928214141.GG19804@ZenIV.linux.org.uk>

On Tue, 28 Sep 2010 22:41:42 +0100
Al Viro <viro@ZenIV.linux.org.uk> wrote:

> On Tue, Sep 28, 2010 at 02:32:39PM -0700, Andrew Morton wrote:
> > > +#define ZT_SHIFT(gfp) ((__force int) (gfp) * ZONES_SHIFT)
> > >  #define GFP_ZONE_TABLE ( \
> > > -	(ZONE_NORMAL << 0 * ZONES_SHIFT)				\
> > > -	| (OPT_ZONE_DMA << __GFP_DMA * ZONES_SHIFT)			\
> > > -	| (OPT_ZONE_HIGHMEM << __GFP_HIGHMEM * ZONES_SHIFT)		\
> > > -	| (OPT_ZONE_DMA32 << __GFP_DMA32 * ZONES_SHIFT)			\
> > > -	| (ZONE_NORMAL << __GFP_MOVABLE * ZONES_SHIFT)			\
> > > -	| (OPT_ZONE_DMA << (__GFP_MOVABLE | __GFP_DMA) * ZONES_SHIFT)	\
> > > -	| (ZONE_MOVABLE << (__GFP_MOVABLE | __GFP_HIGHMEM) * ZONES_SHIFT)\
> > > -	| (OPT_ZONE_DMA32 << (__GFP_MOVABLE | __GFP_DMA32) * ZONES_SHIFT)\
> > > +	(ZONE_NORMAL        << ZT_SHIFT(0))				\
> > > +	| (OPT_ZONE_DMA     << ZT_SHIFT(__GFP_DMA))			\
> > > +	| (OPT_ZONE_HIGHMEM << ZT_SHIFT(__GFP_HIGHMEM))			\
> > > +	| (OPT_ZONE_DMA32   << ZT_SHIFT(__GFP_DMA32))			\
> > > +	| (ZONE_NORMAL      << ZT_SHIFT(__GFP_MOVABLE))			\
> > > +	| (OPT_ZONE_DMA     << ZT_SHIFT(__GFP_MOVABLE | __GFP_DMA))	\
> > > +	| (ZONE_MOVABLE     << ZT_SHIFT(__GFP_MOVABLE | __GFP_HIGHMEM)) \
> > > +	| (OPT_ZONE_DMA32   << ZT_SHIFT(__GFP_MOVABLE | __GFP_DMA32))	\
> > >  )
> > 
> > hm.  I hope these sparse warnings are sufficiently useful to justify
> > all the gunk we're adding to support them.
> > 
> > Is it actually finding any bugs?
> 
> FWIW, bitwise or done in the right-hand argumet of shift looks ugly as hell;
> what the hell is that code _doing_?

There's a nice fat comment a few lines up...

/*
 * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
 * zone to use given the lowest 4 bits of gfp_t. Entries are ZONE_SHIFT long
 * and there are 16 of them to cover all possible combinations of
 * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
 *
 * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
 * But GFP_MOVABLE is not only a zone specifier but also an allocation
 * policy. Therefore __GFP_MOVABLE plus another zone selector is valid.
 * Only 1 bit of the lowest 3 bits (DMA,DMA32,HIGHMEM) can be set to "1".
 *
 *       bit       result
 *       =================
 *       0x0    => NORMAL
 *       0x1    => DMA or NORMAL
 *       0x2    => HIGHMEM or NORMAL
 *       0x3    => BAD (DMA+HIGHMEM)
 *       0x4    => DMA32 or DMA or NORMAL
 *       0x5    => BAD (DMA+DMA32)
 *       0x6    => BAD (HIGHMEM+DMA32)
 *       0x7    => BAD (HIGHMEM+DMA32+DMA)
 *       0x8    => NORMAL (MOVABLE+0)
 *       0x9    => DMA or NORMAL (MOVABLE+DMA)
 *       0xa    => MOVABLE (Movable is valid only if HIGHMEM is set too)
 *       0xb    => BAD (MOVABLE+HIGHMEM+DMA)
 *       0xc    => DMA32 (MOVABLE+HIGHMEM+DMA32)
 *       0xd    => BAD (MOVABLE+DMA32+DMA)
 *       0xe    => BAD (MOVABLE+DMA32+HIGHMEM)
 *       0xf    => BAD (MOVABLE+DMA32+HIGHMEM+DMA)
 *
 * ZONES_SHIFT must be <= 2 on 32 bit platforms.
 */

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2010-09-28 21:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28 12:23 [PATCH] mm: cleanup gfp_zone() Namhyung Kim
2010-09-28 12:23 ` Namhyung Kim
2010-09-28 21:32 ` Andrew Morton
2010-09-28 21:32   ` Andrew Morton
2010-09-28 21:41   ` Al Viro
2010-09-28 21:41     ` Al Viro
2010-09-28 21:45     ` Andrew Morton [this message]
2010-09-28 21:45       ` Andrew Morton
2010-09-28 22:15       ` Al Viro
2010-09-28 22:15         ` Al Viro
2010-09-29  7:06         ` [PATCH v2] mm: fix sparse warnings on GFP_ZONE_TABLE/BAD Namhyung Kim
2010-09-29  7:06           ` Namhyung Kim

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=20100928144518.0eaf1099.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=namhyung@gmail.com \
    --cc=viro@ZenIV.linux.org.uk \
    /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.