Re: [PATCH] mm: memblock: avoid to create memmap for memblock nomap regions

From: Mike Rapoport
Date: Mon May 09 2022 - 07:43:15 EST


On Mon, May 09, 2022 at 04:37:30PM +0530, Faiyaz Mohammed wrote:
>
> On 5/5/2022 10:24 PM, Mike Rapoport wrote:
> > On Thu, May 05, 2022 at 08:46:15PM +0530, Faiyaz Mohammed wrote:
> >> On 4/12/2022 10:56 PM, Mike Rapoport wrote:
> >>> On Tue, Apr 12, 2022 at 12:39:32AM +0530, Faiyaz Mohammed wrote:
> >>>> This 'commit 86588296acbf ("fdt: Properly handle "no-map" field in the
> >>>> memory region")' is keeping the no-map regions in memblock.memory with
> >>>> MEMBLOCK_NOMAP flag set to use no-map memory for EFI using memblock api's,
> >>>> but during the initialization sparse_init mark all memblock.memory as
> >>>> present using for_each_mem_pfn_range, which is creating the memmap for
> >>>> no-map memblock regions. To avoid it skiping the memblock.memory regions
> >>>> set with MEMBLOCK_NOMAP set and with this change we will be able to save
> >>>> ~11MB memory for ~612MB carve out.
> >>> The MEMBLOCK_NOMAP is very fragile and caused a lot of issues already. I
> >>> really don't like the idea if adding more implicit assumptions about how
> >>> NOMAP memory may or may not be used in a generic iterator function.
> >> Sorry for delayed response.
> >> Yes, it is possible that implicit assumption can create
> >> misunderstanding. How about adding command line option and control the
> >> no-map region in fdt.c driver, to decide whether to keep "no-map" region
> >> with NOMAP flag or remove?. Something like below
> > I really don't like memblock_remove() for such cases.
> > Pretending there is a hole when there is an actual DRAM makes things really
> > hairy when it comes to memory map and page allocator initialization.
> > You wouldn't want to trade system stability and random memory corruptions
> > for 11M of "saved" memory.
>
> Creating memory map for holes memory is adding 11MB overhead which is
> huge on low memory target and same time 11MB memory saving is good enough
> on low memory target.
>
> Or we can have separate list of NOMAP like reserved?.
>
> Any other suggestion to address this issue?.

Make your firmware to report the memory that Linux cannot use as a hole,
i.e. _not_ report it as memory.

> Thanks and regards,
> Mohammed Faiyaz

--
Sincerely yours,
Mike.