Re: [PATCH] arm64: limit MAX_PHYSMEM_BITS based on vmemmap

From: D Scott Phillips
Date: Mon Jul 08 2024 - 20:06:48 EST


Catalin Marinas <catalin.marinas@xxxxxxx> writes:

> On Thu, Jul 04, 2024 at 08:42:52AM +0530, Anshuman Khandual wrote:
> > On 7/4/24 02:37, D Scott Phillips wrote:
> > > diff --git a/arch/arm64/include/asm/sparsemem.h b/arch/arm64/include/asm/sparsemem.h
> > > index 8a8acc220371c..8387301f2e206 100644
> > > --- a/arch/arm64/include/asm/sparsemem.h
> > > +++ b/arch/arm64/include/asm/sparsemem.h
> > > @@ -5,7 +5,7 @@
> > > #ifndef __ASM_SPARSEMEM_H
> > > #define __ASM_SPARSEMEM_H
> > >
> > > -#define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS
> > > +#define MAX_PHYSMEM_BITS ilog2(VMEMMAP_RANGE)
> >
> > Just wondering if there is another method, which avoids selecting
> > physical memory ranges not backed with vmemmap. Also will reducing
> > MAX_PHYSMEM_BITS below ARM64_PA_BITS have other side effects ? Do
> > other platforms have this exact same co-relation between
> > MAX_PHYSMEM_BITS and vmemmap range ?
>
> That's indeed a pretty weird workaround. MAX_PHYSMEM_BITS, as the name
> implies, is about the physical bits supported for memory while
> VMEMMAP_RANGE tells us the virtual address range. There is a
> correlation between them but they are different things conceptually.
>
> The memory hotplug code uses arch_get_mappable_range(). This should be
> called from the amdgpu code rather than changing MAX_PHYSMEM_BITS.

OK, thanks I'll pursue that approach.