Re: [PATCH v2] memblock: add no-map alloc functions

From: DaeRo Lee
Date: Thu Apr 18 2024 - 10:54:37 EST


2024년 4월 17일 (수) 오후 3:03, Mike Rapoport <rppt@xxxxxxxxxx>님이 작성:
>
> On Tue, Apr 16, 2024 at 09:06:35PM +0900, skseofh@xxxxxxxxx wrote:
> > From: Daero Lee <daero_le.lee@xxxxxxxxxxx>
> >
> > Like reserved-memory with the 'no-map' property and only 'size' property
> > (w/o 'reg' property), there are memory regions need to be allocated in
> > memblock.memory marked with the MEMBLOCK_NOMAP flag, but should not be
> > allocated in memblock.reserved.
>
> This still does not explain why you need such regions.
>
> As Wei Yang explained, memblock does not allocate memory from
> memblock.reserved. The memblock.reserved array represents memory that is in
> use by firmware or by early kernel allocations and cannot be freed to page
> allocator.
Thank you for your comments. I used the wrong word.
When I use 'allocate', I mean that the region 'adds' to the memblock.reserved.

>
> If you have a region that's _NOMAP in memblock.memory and is absent in
> memblock.reserved it will not be mapped by the kernel page tables, but it
> will be considered as free memory by the core mm.
>
> Is this really what you want?
If my understanding is right, before freeing (memory && !reserved)
area, we marked the memblock.reserved regions and memblock.memory
regions with no-map flag. And when we free (memory && !reserved) area,
we skip the memblock.memory regions with no-map(see
should_skip_region). So, I think that the memory regions with no-map
flag will not be considered as free memory.

If there is anything I think is wrong, feel free to correct me.

Regards,
DaeRo Lee