From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796243960; b=V9vZC0WWPI32yswvxfJSh9/xy2vxkjeEPbXhGjDI4OBHclmU7cq77GTwyoSKea7GztnK koGAMwIjkzZfSfWn3D0JOV6YJS0yVqt/9s2qr+/191yGN+4HDl2YBx0Q3Hjk6+/Y81tUx FjllXgByhCB0+AbufYeTCn3/lFipAspL4vQrkwWs3CFmf3HiNmZl56fCEU8sFehZuabyo MLL31SklRUUInOleGXfQGXoLDcs67aqPg96QyeqVloNEMGYedwHbBVQ4a4Jtc4NZ4Az8i IyXi1vpR5IVX6gREhnPaSgjWm5WVCTYlH8bQjsy9eSuHgGM/csmeQV11OOpPIijSTWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796243960; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=3ulTO9/8NUCHboPkw/gahpj5DqgOZSZ877/rbm2XJkk=; b=V90sSGWMrr2ncVA3ZFdfrA+MbrdHtt8iBVYNWoOsQ5fjKTygmmaFuDj7zB1PFRwWsmtU 738m4MmgWEX+4WWGgJosDKDGEIvxERjrMS+IPSpfF1lBKq4TjQL9m391WACcwjrOHDYtO WaMym1c4MkYk9xL/Q3AT1h3nbQ5UdUgfEjPIO3M2Mmxf8EcgAl+AJDnq3OnJHT405kb+u GEjja8exZGuygvpPWrX3ceA8CCVNu8BYDu04DYy11y9TQKuQutyCQIfwgLRgMhLdqti1T oq+d3An02LSQkmaW5rNdQPm1rOYVASf4CClhLskT921uESMwaIkUynzlqe1gy3kf50Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ncB824V6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66D5E606A322; Wed, 2 Dec 2026 20:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ncB824V6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 003681F000C1; Wed, 2 Dec 2026 20:39:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796243959; bh=3ulTO9/8NUCHboPkw/gahpj5DqgOZSZ877/rbm2XJkk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ncB824V607LfL31U1k/UgHOvxUKxLCkTKQqJehuWLGun0FO97BIMINwmkxErgvEkt 5NhJ4D/1+d3e7017sMlEFLhmyeweUYyNGAO6auTTHwOyf2jaVZEaQqMgtLQE70SpK8 BqVuaUGjibBaIqBdkuFIAjJCO5zMggRdGf6Ok5rXhCVftUsfa1A/TMRomPmNC455li pkF4+KfXZCfBPzf5Y/mknWed8gp5epg8jqxw5UH9j0MOkbyf6emTgrW4vaQULk0xdq 5Z9Y4tMxpmCMty/bzWye9CwJ0cMPRN68w+WwvZxsEm7ah2cLJVYZlr1wx1Aw896/FJ X9sW1hv4Zx38w== Date: Wed, 2 Dec 2026 20:39:07 +0000 From: "Lorenzo Stoakes (ARM)" To: "David Hildenbrand (Arm)" Cc: "Liam R. Howlett" , Vlastimil Babka , "Borislav Petkov (AMD)" , Cenk =?utf-8?Q?Y=C4=B1lmaz?= , Zhang Peng , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Andrew Morton , Zi Yan , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , Mel Gorman , Sasha Levin , Ingo Molnar , Peter Xu , Hugh Dickins , Axel Rasmussen , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Yuanchu Xie , Wei Xu , Baolin Wang , Thomas Gleixner , 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 Message-ID: References: <20261201-file_folio_flush-v2-0-994d587aec8e@kernel.org> <20261201-file_folio_flush-v2-1-994d587aec8e@kernel.org> <5169e528-41fc-4c15-b34a-4ea037f47909@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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) > > 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