Re: [PATCH 4/4] mm/page_alloc: no need to ClearPageReserved on giving page to buddy system

Wei Yang
2024-06-29T08:48:37Z

On Sat, Jun 29, 2024 at 08:28:30AM +0200, David Hildenbrand wrote:
>On 29.06.24 08:25, David Hildenbrand wrote:
>> On 29.06.24 03:33, Wei Yang wrote:
>> > Function __free_pages_core() is only used in the following two cases to
>> > put page to buddy system:
>> >
>> > * free bootmem
>> > * free hot-add memory
>> >
>> > After the above cleanup, there is no case to free page with PG_reserved
>> > set. Let's remove the clear operation.
>> >
>> > The page initialization time shows 6.5% faster with a 6G qemu virtual
>> > machine.
>> >
>> > Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> > CC: David Hildenbrand <david@redhat.com>
>> > CC: Mike Rapoport (IBM) <rppt@kernel.org>
>> > ---
>> > mm/page_alloc.c | 2 --
>> > 1 file changed, 2 deletions(-)
>> >
>> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> > index 51a47db375b6..bc7316744a34 100644
>> > --- a/mm/page_alloc.c
>> > +++ b/mm/page_alloc.c
>> > @@ -1232,10 +1232,8 @@ void __meminit __free_pages_core(struct page *page, unsigned int order)
>> > prefetchw(p);
>> > for (loop = 0; loop < (nr_pages - 1); loop++, p++) {
>> > prefetchw(p + 1);
>> > - __ClearPageReserved(p);
>> > set_page_count(p, 0);
>> > }
>> > - __ClearPageReserved(p);
>> > set_page_count(p, 0);
>> > atomic_long_add(nr_pages, &page_zone(page)->managed_pages);
>>
>> Again see mm/mm-stable where that code changed.
>>
>> I think we can still get reserved pages here, for example via
>> kmsan_memblock_free_pages().
>>

You mean ZONDE_DEVICE pages?

If yes, I think the normal memblock_free_pages() still could get reserved pages.
Am I right?

>
>Sorry, I meant kmsan_memblock_discard().

Yep.

>--
>Cheers,
>
>David / dhildenb

--
Wei Yang
Help you, Help me