linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Igor Stoppa <igor.stoppa@huawei.com>
Cc: namhyung@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] Remove hardcoding of ___GFP_xxx bitmasks
Date: Wed, 26 Apr 2017 16:47:50 +0200	[thread overview]
Message-ID: <20170426144750.GH12504@dhcp22.suse.cz> (raw)
In-Reply-To: <20170426133549.22603-2-igor.stoppa@huawei.com>

On Wed 26-04-17 16:35:49, Igor Stoppa wrote:
> The bitmasks used for ___GFP_xxx can be defined in terms of an enum,
> which doesn't require manual updates to its values.

GFP masks are rarely updated so why is this worth doing?

> As bonus, __GFP_BITS_SHIFT is automatically kept consistent.

this alone doesn't sound like a huge win to me, to be honest. We already
have ___GFP_$FOO and __GFP_FOO you are adding __GFP_$FOO_SHIFT. This is
too much IMHO.

Also the current mm tree has ___GFP_NOLOCKDEP which is not addressed
here so I suspect you have based your change on the Linus tree.

> Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
> ---
>  include/linux/gfp.h | 82 +++++++++++++++++++++++++++++++++++------------------
>  1 file changed, 55 insertions(+), 27 deletions(-)
> 
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 0fe0b62..2f894c5 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -14,33 +14,62 @@ struct vm_area_struct;
>   * include/trace/events/mmflags.h and tools/perf/builtin-kmem.c
>   */
>  
> +enum gfp_bitmask_shift {
> +	__GFP_DMA_SHIFT = 0,
> +	__GFP_HIGHMEM_SHIFT,
> +	__GFP_DMA32_SHIFT,
> +	__GFP_MOVABLE_SHIFT,
> +	__GFP_RECLAIMABLE_SHIFT,
> +	__GFP_HIGH_SHIFT,
> +	__GFP_IO_SHIFT,
> +	__GFP_FS_SHIFT,
> +	__GFP_COLD_SHIFT,
> +	__GFP_NOWARN_SHIFT,
> +	__GFP_REPEAT_SHIFT,
> +	__GFP_NOFAIL_SHIFT,
> +	__GFP_NORETRY_SHIFT,
> +	__GFP_MEMALLOC_SHIFT,
> +	__GFP_COMP_SHIFT,
> +	__GFP_ZERO_SHIFT,
> +	__GFP_NOMEMALLOC_SHIFT,
> +	__GFP_HARDWALL_SHIFT,
> +	__GFP_THISNODE_SHIFT,
> +	__GFP_ATOMIC_SHIFT,
> +	__GFP_ACCOUNT_SHIFT,
> +	__GFP_NOTRACK_SHIFT,
> +	__GFP_DIRECT_RECLAIM_SHIFT,
> +	__GFP_WRITE_SHIFT,
> +	__GFP_KSWAPD_RECLAIM_SHIFT,
> +	__GFP_BITS_SHIFT
> +};
> +
> +
>  /* Plain integer GFP bitmasks. Do not use this directly. */
> -#define ___GFP_DMA		0x01u
> -#define ___GFP_HIGHMEM		0x02u
> -#define ___GFP_DMA32		0x04u
> -#define ___GFP_MOVABLE		0x08u
> -#define ___GFP_RECLAIMABLE	0x10u
> -#define ___GFP_HIGH		0x20u
> -#define ___GFP_IO		0x40u
> -#define ___GFP_FS		0x80u
> -#define ___GFP_COLD		0x100u
> -#define ___GFP_NOWARN		0x200u
> -#define ___GFP_REPEAT		0x400u
> -#define ___GFP_NOFAIL		0x800u
> -#define ___GFP_NORETRY		0x1000u
> -#define ___GFP_MEMALLOC		0x2000u
> -#define ___GFP_COMP		0x4000u
> -#define ___GFP_ZERO		0x8000u
> -#define ___GFP_NOMEMALLOC	0x10000u
> -#define ___GFP_HARDWALL		0x20000u
> -#define ___GFP_THISNODE		0x40000u
> -#define ___GFP_ATOMIC		0x80000u
> -#define ___GFP_ACCOUNT		0x100000u
> -#define ___GFP_NOTRACK		0x200000u
> -#define ___GFP_DIRECT_RECLAIM	0x400000u
> -#define ___GFP_WRITE		0x800000u
> -#define ___GFP_KSWAPD_RECLAIM	0x1000000u
> -/* If the above are modified, __GFP_BITS_SHIFT may need updating */
> +#define ___GFP_DMA		(1u << __GFP_DMA_SHIFT)
> +#define ___GFP_HIGHMEM		(1u << __GFP_HIGHMEM_SHIFT)
> +#define ___GFP_DMA32		(1u << __GFP_DMA32_SHIFT)
> +#define ___GFP_MOVABLE		(1u << __GFP_MOVABLE_SHIFT)
> +#define ___GFP_RECLAIMABLE	(1u << __GFP_RECLAIMABLE_SHIFT)
> +#define ___GFP_HIGH		(1u << __GFP_HIGH_SHIFT)
> +#define ___GFP_IO		(1u << __GFP_IO_SHIFT)
> +#define ___GFP_FS		(1u << __GFP_FS_SHIFT)
> +#define ___GFP_COLD		(1u << __GFP_COLD_SHIFT)
> +#define ___GFP_NOWARN		(1u << __GFP_NOWARN_SHIFT)
> +#define ___GFP_REPEAT		(1u << __GFP_REPEAT_SHIFT)
> +#define ___GFP_NOFAIL		(1u << __GFP_NOFAIL_SHIFT)
> +#define ___GFP_NORETRY		(1u << __GFP_NORETRY_SHIFT)
> +#define ___GFP_MEMALLOC		(1u << __GFP_MEMALLOC_SHIFT)
> +#define ___GFP_COMP		(1u << __GFP_COMP_SHIFT)
> +#define ___GFP_ZERO		(1u << __GFP_ZERO_SHIFT)
> +#define ___GFP_NOMEMALLOC	(1u << __GFP_NOMEMALLOC_SHIFT)
> +#define ___GFP_HARDWALL		(1u << __GFP_HARDWALL_SHIFT)
> +#define ___GFP_THISNODE		(1u << __GFP_THISNODE_SHIFT)
> +#define ___GFP_ATOMIC		(1u << __GFP_ATOMIC_SHIFT)
> +#define ___GFP_ACCOUNT		(1u << __GFP_ACCOUNT_SHIFT)
> +#define ___GFP_NOTRACK		(1u << __GFP_NOTRACK_SHIFT)
> +#define ___GFP_DIRECT_RECLAIM	(1u << __GFP_DIRECT_RECLAIM_SHIFT)
> +#define ___GFP_WRITE		(1u << __GFP_WRITE_SHIFT)
> +#define ___GFP_KSWAPD_RECLAIM	(1u << __GFP_KSWAPD_RECLAIM_SHIFT)
>  
>  /*
>   * Physical address zone modifiers (see linux/mmzone.h - low four bits)
> @@ -180,7 +209,6 @@ struct vm_area_struct;
>  #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
>  
>  /* Room for N __GFP_FOO bits */
> -#define __GFP_BITS_SHIFT 25
>  #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
>  
>  /*
> -- 
> 2.9.3
> 

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2017-04-26 14:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 13:35 [PATCH 0/1] mm: Improve consistency of ___GFP_xxx masks Igor Stoppa
2017-04-26 13:35 ` [PATCH 1/1] Remove hardcoding of ___GFP_xxx bitmasks Igor Stoppa
2017-04-26 14:47   ` Michal Hocko [this message]
2017-04-26 15:29     ` Igor Stoppa
2017-04-27 12:16       ` Question on ___GFP_NOLOCKDEP - Was: " Igor Stoppa
2017-04-27 13:35         ` Michal Hocko
2017-05-10 15:24           ` Vlastimil Babka
2017-04-27 12:18       ` Igor Stoppa
2017-04-27 13:41       ` Michal Hocko
2017-04-27 14:06         ` Igor Stoppa
2017-04-28  7:40           ` Michal Hocko
2017-04-28  7:43             ` Igor Stoppa
2017-04-28  8:13               ` Igor Stoppa

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=20170426144750.GH12504@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=igor.stoppa@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=namhyung@kernel.org \
    /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).