Re: [PATCH] mm,hugetlb: compute page_size_log properly

From: Matthew Wilcox
Date: Thu Apr 13 2017 - 08:46:40 EST


On Thu, Apr 13, 2017 at 11:32:09AM +0530, Aneesh Kumar K.V wrote:
> > +#define SHM_HUGE_SHIFT 26
> > +#define SHM_HUGE_MASK 0x3f
> > +#define SHM_HUGE_2MB (21 << SHM_HUGE_SHIFT)
> > +#define SHM_HUGE_8MB (23 << SHM_HUGE_SHIFT)
> > +#define SHM_HUGE_1GB (30 << SHM_HUGE_SHIFT)
> > +#define SHM_HUGE_16GB (34 << SHM_HUGE_SHIFT)
>
> This should be in arch/uapi like MAP_HUGE_2M ? That will let arch add
> #defines based on the hugepae size supported by them.

Well, what do we want to happen if source code contains SHM_HUGE_2MB?
Do we want it to fail to compile on ppc, or do we want it to request 2MB
pages and get ... hmm, looks like it fails at runtime (size_to_hstate
ends up returning NULL). So, yeah, looks like a compile-time failure
would be better.

But speaking of MAP_HUGE_, the only definitions so far are in arch/x86.
Are you going to add the ppc versions?

Also, which header file? I'm reluctant to add a new header, but
asm/shmbuf.h doesn't seem like a great place to put it.