From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: "Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
"Cenk Yılmaz" <cenk@deepfinresearch.com>,
"Zhang Peng" <zippermonkey@icloud.com>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Zi Yan" <ziy@nvidia.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Byungchul Park" <byungchul@sk.com>,
"Gregory Price" <gourry@gourry.net>,
"Ying Huang" <ying.huang@linux.alibaba.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Chris Li" <chrisl@kernel.org>,
"Kairui Song" <kasong@tencent.com>,
"Kemeng Shi" <shikemeng@huaweicloud.com>,
"Nhat Pham" <nphamcs@gmail.com>,
"Baoquan He" <baoquan.he@linux.dev>,
"Barry Song" <baohua@kernel.org>,
"Youngjun Park" <youngjun.park@lge.com>,
"Mel Gorman" <mgorman@suse.de>,
"Sasha Levin" <sasha.levin@oracle.com>,
"Ingo Molnar" <mingo@kernel.org>, "Peter Xu" <peterx@redhat.com>,
"Hugh Dickins" <hughd@google.com>,
"Axel Rasmussen" <axelrasmussen@google.com>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Hocko" <mhocko@kernel.org>,
"Qi Zheng" <qi.zheng@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Yuanchu Xie" <yuanchu@google.com>, "Wei Xu" <weixugc@google.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Thomas Gleixner" <tglx@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mm/rmap: don't defer TLB flushes when unmapping lazyfree folios
Date: Wed, 2 Dec 2026 20:39:07 +0000 [thread overview]
Message-ID: <axCBuII361qxl_b0@gremlin> (raw)
In-Reply-To: <5169e528-41fc-4c15-b34a-4ea037f47909@kernel.org>
On Wed, Dec 02, 2026 at 09:36:56PM +0100, David Hildenbrand (Arm) wrote:
> On 12/2/26 20:49, Lorenzo Stoakes (ARM) wrote:
> > Lazyfree seems like yet another silly edge case thing we shouldn't have done (or
> > maybe should have done better :)
> >
> > But anyway, LGTM so:
> >
> > Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
>
> Thanks.
NP.
> >> ---
> >> mm/rmap.c | 14 ++++++++++++--
> >> 1 file changed, 12 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/mm/rmap.c b/mm/rmap.c
> >> index 038435994b99a..7459722d22d9f 100644
> >> --- a/mm/rmap.c
> >> +++ b/mm/rmap.c
[ ... ]
> >> @@ -2329,11 +2331,17 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
> >> * architecture must guarantee that a clear->dirty
> >> * transition on a cached TLB entry is written through
> >> * and traps if the PTE is unmapped.
> >> + *
> >> + * If we don't defer the flush, we flush only once we
> >> + * know that we won't restore the PTEs below. We never
> >> + * defer the flush for lazyfree folios: if we discard
> >> + * them, the PTE will be none, and a page fault could
> >> + * map a new folio while stale TLB entries still exist.
> >> */
> >> - if (should_defer_flush(mm, flags))
> >> + if (!folio_test_lazyfree(folio) && should_defer_flush(mm, flags))
> >> set_tlb_ubc_flush_pending(mm, pteval, address, end_addr);
> >> else
> >> - flush_tlb_range(vma, address, end_addr);
> >> + flush = true;
> >
> > Hmm it's like 'should defer' or 'should defer a little bit' :)
> >
> > But I can't see how the 'slight' delay does any harm and as the commit msg says
> > you avoid unnecessary flushes.
> >
> > Claude mentioned something though it says this exit case the 'not restore PTEs'
> > one can make contpte_set_ptes() restore a previously non-cont block as cont,
> > leaving non-cont TLB entries overlapping new cont ones.
>
> That's arch code problems, and would be pre-existing. I'll ping some people to
> understand if something in arch code might need fixing.
Great thanks! Will leave with you :)
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-12-02 20:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 16:25 [PATCH v2 0/2] mm: fixes for stale TLB entries due to delayed/batched TLB flushes David Hildenbrand (Arm)
2026-12-01 16:25 ` [PATCH v2 1/2] mm/rmap: don't defer TLB flushes when unmapping lazyfree folios David Hildenbrand (Arm)
2026-12-02 19:49 ` Lorenzo Stoakes (ARM)
2026-12-02 20:36 ` David Hildenbrand (Arm)
2026-12-02 20:39 ` Lorenzo Stoakes (ARM) [this message]
2026-12-02 20:40 ` David Hildenbrand (Arm)
2026-12-02 20:52 ` Lorenzo Stoakes (ARM)
2026-12-01 16:25 ` [PATCH v2 2/2] mm/vmscan: unlock unmapped folios only after the deferred TLB flush David Hildenbrand (Arm)
2026-12-02 20:37 ` Lorenzo Stoakes (ARM)
2026-12-02 13:47 ` [PATCH v2 0/2] mm: fixes for stale TLB entries due to delayed/batched TLB flushes David Hildenbrand (Arm)
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=axCBuII361qxl_b0@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=bp@alien8.de \
--cc=byungchul@sk.com \
--cc=cenk@deepfinresearch.com \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=nphamcs@gmail.com \
--cc=peterx@redhat.com \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=sasha.levin@oracle.com \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=ying.huang@linux.alibaba.com \
--cc=youngjun.park@lge.com \
--cc=yuanchu@google.com \
--cc=zippermonkey@icloud.com \
--cc=ziy@nvidia.com \
/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