Re: [PATCHv2] mm: No need to check pcp page when free it to buddy

From: Andrew Morton
Date: Thu Sep 15 2022 - 18:06:22 EST


On Thu, 15 Sep 2022 10:40:54 +0800 "zhaoyang.huang" <zhaoyang.huang@xxxxxxxxxx> wrote:

> From: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>
>
> The pages on pcp list have been checked the validity via bellowing call chain.
> It is no need to check it again when free them back to buddy by free_pcppages_bulk.
>
> free_unref_page\free_unref_page_list
> {
> ...
> //page's validity is checked here
> if (!free_unref_page_prepare(page, pfn, order))
> return;
> ...
> //page added to pcp->lists and status is ready for moving to buddy
> list_add(&page->lru, &pcp->lists[pindex]);
>

The comment over free_pcp_prepare():

/*
* With DEBUG_VM enabled, order-0 pages are checked immediately when being freed
* to pcp lists. With debug_pagealloc also enabled, they are also rechecked when
* moved from pcp lists to free lists.
*/

Which seems sensible - a page's state may have been messed up while
it's in the pcp lists.