[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZO+x8Wfz0BxgVpS6@casper.infradead.org>
Date: Wed, 30 Aug 2023 22:17:37 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Ryan Roberts <ryan.roberts@....com>
Cc: Will Deacon <will@...nel.org>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Nick Piggin <npiggin@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Arnd Bergmann <arnd@...db.de>,
David Hildenbrand <david@...hat.com>,
Yu Zhao <yuzhao@...gle.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Yin Fengwei <fengwei.yin@...el.com>,
Yang Shi <shy828301@...il.com>,
"Huang, Ying" <ying.huang@...el.com>, Zi Yan <ziy@...dia.com>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/5] mm: Refector release_pages()
On Wed, Aug 30, 2023 at 08:11:07PM +0100, Matthew Wilcox wrote:
> I'm thinking about doing ...
>
> void release_unref_folios(struct folio_batch *folios)
> {
> struct lruvec *lruvec = NULL;
> unsigned long flags = 0;
> int i;
>
> for (i = 0; i < folios->nr; i++) {
> struct folio *folio = folios->folios[i];
> free_swap_cache(folio);
No, can't do that here. Swap cache has refs on the folio, so it'll
never trigger.
> __page_cache_release(folio, &lruvec, &flags);
> }
> mem_cgroup_uncharge_folios(folios);
> free_unref_folios(folios);
> }
>
> then this becomes:
>
> void folios_put(struct folio_batch *folios)
> {
> int i, j;
>
> for (i = 0, j = 0; i < folios->nr; i++) {
> struct folio *folio = folios->folios[i];
>
> if (is_huge_zero_page(&folio->page))
> continue;
> if (folio_is_zone_device(folio)) {
> if (put_devmap_managed_page(&folio->page))
> continue;
> if (folio_put_testzero(folio))
> free_zone_device_page(&folio->page);
> continue;
> }
Must go at least here, maybe earlier.
> if (!folio_put_testzero(folio))
> continue;
> if (folio_test_hugetlb(folio)) {
> free_huge_folio(folio);
> continue;
> }
>
> if (j != i)
> folios->folios[j] = folio;
> j++;
> }
>
> folios->nr = j;
> if (!j)
> return;
> release_unref_folios(folios);
> }
>
> and pfn_range_put() also becomes shorter and loses all the lruvec work.
>
> Thoughts?
>
Powered by blists - more mailing lists