[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240807194512.GA1828817@cmpxchg.org>
Date: Wed, 7 Aug 2024 15:45:12 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Usama Arif <usamaarif642@...il.com>
Cc: akpm@...ux-foundation.org, linux-mm@...ck.org, riel@...riel.com,
shakeel.butt@...ux.dev, roman.gushchin@...ux.dev, yuzhao@...gle.com,
david@...hat.com, baohua@...nel.org, ryan.roberts@....com,
rppt@...nel.org, willy@...radead.org, cerasuolodomenico@...il.com,
corbet@....net, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, kernel-team@...a.com,
Shuang Zhai <zhais@...gle.com>
Subject: Re: [PATCH v2 1/4] mm: free zapped tail pages when splitting
isolated thp
On Wed, Aug 07, 2024 at 02:46:46PM +0100, Usama Arif wrote:
> From: Yu Zhao <yuzhao@...gle.com>
>
> If a tail page has only two references left, one inherited from the
> isolation of its head and the other from lru_add_page_tail() which we
> are about to drop, it means this tail page was concurrently zapped.
> Then we can safely free it and save page reclaim or migration the
> trouble of trying it.
>
> Signed-off-by: Yu Zhao <yuzhao@...gle.com>
> Tested-by: Shuang Zhai <zhais@...gle.com>
> Signed-off-by: Usama Arif <usamaarif642@...il.com>
> ---
> mm/huge_memory.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 0167dc27e365..35c1089d8d61 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2923,7 +2923,9 @@ static void __split_huge_page(struct page *page, struct list_head *list,
> unsigned int new_nr = 1 << new_order;
> int order = folio_order(folio);
> unsigned int nr = 1 << order;
> + struct folio_batch free_folios;
>
> + folio_batch_init(&free_folios);
> /* complete memcg works before add pages to LRU */
> split_page_memcg(head, order, new_order);
>
> @@ -3007,6 +3009,26 @@ static void __split_huge_page(struct page *page, struct list_head *list,
> if (subpage == page)
> continue;
> folio_unlock(new_folio);
> + /*
> + * If a folio has only two references left, one inherited
> + * from the isolation of its head and the other from
> + * lru_add_page_tail() which we are about to drop, it means this
> + * folio was concurrently zapped. Then we can safely free it
> + * and save page reclaim or migration the trouble of trying it.
> + */
> + if (list && page_ref_freeze(subpage, 2)) {
folio_ref_freeze(new_folio, 2)?
Otherwise looks good to me
Acked-by: Johannes Weiner <hannes@...xchg.org>
Powered by blists - more mailing lists