Re: [PATCH] mm, vmalloc: use __GFP_HIGHMEM implicitly

From: Michal Hocko
Date: Wed Mar 08 2017 - 08:04:12 EST


On Tue 07-03-17 10:57:48, Matthew Wilcox wrote:
> On Tue, Mar 07, 2017 at 10:28:41AM -0800, Matthew Wilcox wrote:
> > On Tue, Mar 07, 2017 at 03:10:20PM +0100, Michal Hocko wrote:
> > > This patch simply uses __GFP_HIGHMEM implicitly when allocating pages to
> > > be mapped to the vmalloc space. Current users which add __GFP_HIGHMEM
> > > are simplified and drop the flag.
>
> btw, I had another idea for GFP_HIGHMEM -- remove it when CONFIG_HIGHMEM
> isn't enabled. Saves 26 bytes of .text and 64 bytes of .data on my
> laptop's kernel build. What do you think?

I wouldn't be opposed. The downside would be a slight confusion when
printing gfp flags but we already have this for ___GFP_NOLOCKDEP ;)

> Also, I suspect the layout of bits is suboptimal from an assembly
> language perspective. I still mostly care about x86 which doesn't
> benefit, so I'm not inclined to do the work, but certainly ARM, PA-RISC,
> SPARC and Itanium would all benefit from having frequently-used bits
> (ie those used in GFP_KERNEL and GFP_ATOMIC) placed in the low 8 bits.

be careful that there is some elaborate logic around low gfp bits to map
to proper zones and ALLOC_ constants.

> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 0fe0b6295ab5..d88cb532d7c8 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -16,7 +16,11 @@ struct vm_area_struct;
>
> /* Plain integer GFP bitmasks. Do not use this directly. */
> #define ___GFP_DMA 0x01u
> +#ifdef CONFIG_HIGHMEM
> #define ___GFP_HIGHMEM 0x02u
> +#else
> +#define ___GFP_HIGHMEM 0x0u
> +#endif
> #define ___GFP_DMA32 0x04u
> #define ___GFP_MOVABLE 0x08u
> #define ___GFP_RECLAIMABLE 0x10u

Anyway, thanks for your review!
--
Michal Hocko
SUSE Labs