Re: [PATCH] mm/zsmalloc: include sparsemem.h for MAX_PHYSMEM_BITS
From: Mike Rapoport
Date: Tue Nov 10 2020 - 04:58:15 EST
On Tue, Nov 10, 2020 at 10:29:54AM +0100, Stefan Agner wrote:
> On 2020-11-08 07:46, Mike Rapoport wrote:
> > On Sat, Nov 07, 2020 at 04:22:06PM +0100, Stefan Agner wrote:
> >> Most architectures define MAX_PHYSMEM_BITS in asm/sparsemem.h and don't
> >> include it in asm/pgtable.h. Include asm/sparsemem.h directly to get
> >> the MAX_PHYSMEM_BITS define on all architectures.
...
> >> Fixes: 61989a80fb3a ("staging: zsmalloc: zsmalloc memory allocation library")
> >> Signed-off-by: Stefan Agner <stefan@xxxxxxxx>
> >> ---
> >> mm/zsmalloc.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >>
> >> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> >> index c36fdff9a371..260bd48aacd0 100644
> >> --- a/mm/zsmalloc.c
> >> +++ b/mm/zsmalloc.c
> >> @@ -40,6 +40,7 @@
> >> #include <linux/string.h>
> >> #include <linux/slab.h>
> >> #include <linux/pgtable.h>
> >> +#include <asm/sparsemem.h>
> >
> > asm/sparsemem.h is not available on some architectures.
> > It's better to use linux/mmzone.h instead.
> >
>
> Hm, linux/mmzone.h only includes asm/sparsemem.h when CONFIG_SPARSEMEM
> is enabled. However, on ARM at least I can have configurations without
> CONFIG_SPARSEMEM and physical address extension on (e.g.
> multi_v7_defconfig + CONFIG_LPAE + CONFIG_ZSMALLOC).
>
> While sparsemem seems to be a good idea with LPAE it really seems not
> required (see also https://lore.kernel.org/patchwork/patch/567589/).
>
> There seem to be also other architectures which define MAX_PHYSMEM_BITS
> only when SPARSEMEM is enabled, e.g.
> arch/riscv/include/asm/sparsemem.h...
>
> Not sure how to get out of this.. Maybe make ZSMALLOC dependent on
> SPARSEMEM? It feels a bit silly restricting ZSMALLOC selection only due
> to a compile time define...
I think we can define MAX_POSSIBLE_PHYSMEM_BITS in one of
arch/arm/inclide/asm/pgtable-{2,3}level-*.h headers to values supported
by !LPAE and LPAE.
That's what x86 does:
$ git grep -w MAX_POSSIBLE_PHYSMEM_BITS arch/
arch/x86/include/asm/pgtable-3level_types.h:#define MAX_POSSIBLE_PHYSMEM_BITS 36
arch/x86/include/asm/pgtable_64_types.h:#define MAX_POSSIBLE_PHYSMEM_BITS 52
It seems that actual numbers would be 36 for !LPAE and 40 for LPAE, but
I'm not sure about that.
> --
> Stefan
>
> >> #include <asm/tlbflush.h>
> >> #include <linux/cpumask.h>
> >> #include <linux/cpu.h>
> >> --
> >> 2.29.1
> >>
> >>
--
Sincerely yours,
Mike.