[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <F1AB428D-73B3-4E40-939C-2A7BAEA1E73A@nvidia.com>
Date: Tue, 30 Sep 2025 10:28:29 -0400
From: Zi Yan <ziy@...dia.com>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: zhongjinji <zhongjinji@...or.com>, akpm@...ux-foundation.org,
surenb@...gle.com, mhocko@...e.com, jackmanb@...gle.com, hannes@...xchg.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org, liulu.liu@...or.com,
feng.han@...or.com
Subject: Re: [PATCH v0] mm/page_alloc: Cleanup for __del_page_from_free_list()
On 30 Sep 2025, at 9:55, Vlastimil Babka wrote:
> On 9/25/25 10:50, zhongjinji wrote:
>> It is unnecessary to set page->private in __del_page_from_free_list().
>>
>> If the page is about to be allocated, page->private will be cleared by
>> post_alloc_hook() before the page is handed out. If the page is expanded
>> or merged, page->private will be reset by set_buddy_order, and no one
>> will retrieve the page's buddy_order without the PageBuddy flag being set.
>> If the page is isolated, it will also reset page->private when it
>> succeeds.
>
> Seems correct.
This means high order free pages will have head[2N].private set to a non-zero
value, where head[N*2].private is 1, head[N*(2^2)].private is 2, ...
head[N*(2^M)].private is M and head[0].private is the actual free page order.
If such a high order free page is used as high order folio, it should be fine.
But if user allocates a non-compound high order page and uses split_page()
to get a list of order-0 pages from this high order page, some pages will
have non zero private. I wonder if these users are prepared for that.
For example, kernel/events/ring_buffer.c does it. In its comment, it says
“set its first page's private to this order; !PagePrivate(page) means it's
just a normal page.”
(see https://elixir.bootlin.com/linux/v6.17/source/kernel/events/ring_buffer.c#L634)
I wonder if non zero page->private would cause any issue there.
Maybe split_page() should set all page->private to 0.
Let me know if I get anything wrong.
>
>> Since __del_page_from_free_list() is a hot path in the kernel, it would be
>> better to remove the unnecessary set_page_private().
>>
>> Signed-off-by: zhongjinji <zhongjinji@...or.com>
>
> Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
>
>> ---
>> mm/page_alloc.c | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index d1d037f97c5f..1999eb7e7c14 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -868,7 +868,6 @@ static inline void __del_page_from_free_list(struct page *page, struct zone *zon
>>
>> list_del(&page->buddy_list);
>> __ClearPageBuddy(page);
>> - set_page_private(page, 0);
>> zone->free_area[order].nr_free--;
>>
>> if (order >= pageblock_order && !is_migrate_isolate(migratetype))
Best Regards,
Yan, Zi
Powered by blists - more mailing lists