[PATCH v4 02/14] memblock: add MEMBLOCK_RSRV_KERN flag

Mike Rapoport rppt at kernel.org
Mon Mar 10 01:28:02 PDT 2025


Hi Wei,

On Mon, Mar 10, 2025 at 07:56:27AM +0000, Wei Yang wrote:
> On Wed, Feb 26, 2025 at 02:09:15AM +0000, Wei Yang wrote:
> >>> 
> >>> From the above call flow and background, there are three cases when
> >>> memblock_alloc_range_nid() would be called:
> >>> 
> >>>   * If it is called before (1), memblock.reserved's nid would be adjusted correctly.
> >>>   * If it is called after (2), we don't touch memblock.reserved.
> >>>   * If it happens between (1) and (2), it looks would break the consistency of
> >>>     nid information in memblock.reserved. Because when we use
> >>>     memblock_reserve_kern(), NUMA_NO_NODE would be stored in region.
> >>> 
> >>> So my question is if the third case happens, would it introduce a bug? If it
> >>> won't happen, seems we don't need to specify the nid here?
> >>
> >>We don't really care about proper assignment of nodes between (1) and (2)
> >>from one side and the third case does not happen on the other side. Nothing
> >>should call membloc_alloc() after memblock_free_all(). 
> >>
> >
> >My point is if no one would call memblock_alloc() after memblock_free_all(),
> >which set nid in memblock.reserved properly, it seems not necessary to do
> >__memblock_reserve() with exact nid during memblock_alloc()? 
> >
> >As you did __memblock_reserve(found, size, nid, MEMBLOCK_RSRV_KERN) in this
> >patch.
> >
> 
> Hi, Mike
> 
> Do you think my understanding is reasonable?

Without KHO it is indeed not strictly necessary to set nid during memblock_alloc().
But since we anyway have nid parameter in memblock_alloc_range_nid() and it
anyway propagates to memblock_add_range(), I think it's easier and cleaner
to pass nid to __memblock_reserve() there.

And for KHO estimation of scratch size it is important to have nid assigned to
the reserved areas before memblock_free_all(), at least for the allocations
that request particular nid explicitly.
 
> -- 
> Wei Yang
> Help you, Help me

-- 
Sincerely yours,
Mike.



More information about the kexec mailing list