From: Zi Yan <ziy@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: nifan.cxl@gmail.com, mcgrof@kernel.org, a.manzanares@samsung.com,
dave@stgolabs.net, akpm@linux-foundation.org, david@redhat.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
will@kernel.org, aneesh.kumar@kernel.org, hca@linux.ibm.com,
gor@linux.ibm.com, linux-s390@vger.kernel.org,
Fan Ni <fan.ni@samsung.com>
Subject: Re: [PATCH] mm: Introduce free_folio_and_swap_cache() to replace free_page_and_swap_cache()
Date: Thu, 10 Apr 2025 14:55:42 -0400 [thread overview]
Message-ID: <A171AEEB-13A8-4A9A-A461-2B8CA098EF0F@nvidia.com> (raw)
In-Reply-To: <Z_gNBRY_1UVe2-ax@casper.infradead.org>
On 10 Apr 2025, at 14:25, Matthew Wilcox wrote:
> On Thu, Apr 10, 2025 at 02:16:09PM -0400, Zi Yan wrote:
>>> @@ -49,7 +49,7 @@ static inline bool __tlb_remove_page_size(struct mmu_gather *tlb,
>>> {
>>> VM_WARN_ON_ONCE(delay_rmap);
>>>
>>> - free_page_and_swap_cache(page);
>>> + free_folio_and_swap_cache(page_folio(page));
>>> return false;
>>> }
>>
>> __tlb_remove_page_size() is ruining the fun of the conversion. But it will be
>> converted to use folio eventually.
>
> Well, hm, I'm not sure. I haven't looked into this in detail.
> We have a __tlb_remove_folio_pages() which removes N pages but they must
> all be within the same folio:
>
> VM_WARN_ON_ONCE(page_folio(page) != page_folio(page + nr_pages - 1));
>
> but would we be better off just passing in the folio which contains the
> page and always flush all pages in the folio? It'd certainly simplify
> the "encoded pages" stuff since we'd no longer need to pass (page,
> length) tuples. But then, what happens if the folio is split between
> being added to the batch and the flush actually happening?
Apparently I did not read enough context before made the comment.
__tlb_remove_page_size() is used to check if tlb flush is need by
tlb_remove_page_size(), which is used for zap PMDs and PUDs,
whereas __tlb_remove_folio_pages() is used to check tlb flush needs for
zap PTEs, including single page folio and multiple pages in a folio.
On x86, __tlb_remove_page_size() and __tlb_remove_folio_pages()
use the same backend __tlb_remove_folio_pages_size(), but on s390
they are different.
Like you said, if a folio is split between it is added and flushed,
a flush-folio-as-a-whole function would miss part of the original
folio. Unless a pin is added to avoid that, but that sounds stupid.
Probably we will have to live with this per-page flush thing.
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2025-04-10 18:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 18:00 nifan.cxl
2025-04-10 18:11 ` Matthew Wilcox
2025-04-10 18:16 ` Zi Yan
2025-04-10 18:25 ` Matthew Wilcox
2025-04-10 18:36 ` David Hildenbrand
2025-04-10 18:51 ` Matthew Wilcox
2025-04-10 18:55 ` Zi Yan [this message]
2025-04-10 20:31 ` Davidlohr Bueso
2025-04-11 19:15 ` Vishal Moola (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A171AEEB-13A8-4A9A-A461-2B8CA098EF0F@nvidia.com \
--to=ziy@nvidia.com \
--cc=a.manzanares@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@kernel.org \
--cc=dave@stgolabs.net \
--cc=david@redhat.com \
--cc=fan.ni@samsung.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nifan.cxl@gmail.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox