From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F9AA606A322 for ; Wed, 2 Dec 2026 21:36:16 +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=jcXGpYgb Received: by kanga.kvack.org (Postfix) id 2A60C6B05B1; Wed, 2 Dec 2026 16:36:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 27DD86B05B2; Wed, 2 Dec 2026 16:36:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16C4D6B05BD; Wed, 2 Dec 2026 16:36:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E5A106B05B1 for ; Wed, 2 Dec 2026 16:36:14 -0500 (EST) Received: from smtpin28.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 72BE61C3C95 for ; Wed, 2 Dec 2026 21:36:14 +0000 (UTC) X-FDA: 85500351468.28.74FB550 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf26.hostedemail.com (Postfix) with ESMTP id 99B95140007 for ; Wed, 2 Dec 2026 21:36:12 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=jcXGpYgb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of david@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=david@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796247372; b=Duns0ql4V7qSUEPYezINFEfs2dRR36O+imO/VODpNPcxGuCJkxFIuv5WFFHHbam3i8DLNB UwDwQCOjyRenzqdaeoCe3+k4QHew+/S2Q1wEqPyZBy++ejnN8OAm8RZ74LYfvN14feBYej CeFwOOnjRqGABuTl+/i20ZeRFsGlCfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796247372; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v+D+u4MXvT2WWvJML329LqVMjo4stuEeASFrpIk+Txo=; b=8lOwxdd82Z7JX+T8IwaG3+UThn4eWfVSIuTMTCh7Tln/+GT53Y4O7R+99SsssEaOPGP/aV EfGUReXQpXzFggLdUUNGNGAymDHi5kqmFv+pwvwWfJjPQlrsNAFIG/Kltx1mWs0XnO5Duk vzdWIYGNdYXECMgwmHUZdFVwHnA8NY4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=jcXGpYgb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of david@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=david@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 10CB56012A; Wed, 2 Dec 2026 21:36:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 166901F00927; Wed, 2 Dec 2026 21:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796247371; bh=v+D+u4MXvT2WWvJML329LqVMjo4stuEeASFrpIk+Txo=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=jcXGpYgbCKm/ufeagx41DMWzbX87dlqDi6jAPoy1udQIlrti1u8q8/+bROOHm249g W49WXLdtrM5Kx29e8mV2X06eFwfVH/pDgEDNafBWD3qA+MbVURwfeLr89B4w66LpSa wK+ZdOOd3iJ1cyEAT7/CJjnFnaC73FIvfuhUT6F8d8PWoAgPsIetJo6uvnvJYVDjDb o5EMQpG6B/bb2GQ8K33ClwEkRdLkNvhjDOLfLcG1guIvG9AQniDPrZ/+7d3QXDdZWc Cu0Jin4pLNVOeQxchAaEhJKZzR1Ai/k8wuTQE4CNjNe7Ru7dn40X2MX8wJpJW9jnXz toavkxyzXO8wA== Message-ID: Date: Wed, 2 Dec 2026 22:35:59 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] mm/vmscan: unlock unmapped folios only after the deferred TLB flush To: "Lorenzo Stoakes (ARM)" Cc: "Liam R. Howlett" , Vlastimil Babka , "Borislav Petkov (AMD)" , =?UTF-8?Q?Cenk_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 References: <20261201-file_folio_flush-v2-0-994d587aec8e@kernel.org> <20261201-file_folio_flush-v2-2-994d587aec8e@kernel.org> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnac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zXEw6Rg38yk3e EPcA/4NaBQJonNqrBQkmWAihAAoJEE3eEPcA/4NaKtMQALAJ8PzprBEXbXcEXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: k5u55p4aswzy61s5ziqd7oxooyhmifjk X-Rspamd-Queue-Id: 99B95140007 X-Rspamd-Server: rspam05 X-Rspam-User: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, USER_AGENT_SANE_1 autolearn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t4nuKbqmXCVjuL6PfZb4vrcQCOPls1ST+KgcOZYPMJqSXehgILeVtyAJYGoConDkCEXlrCiRB+B4DCCXJnHYgOutxIPUurvB5XfTRpLzz3Cvb643VDm+tQBRL2Wj0ThgAIrWpdxrU+FkF9v0+Wp7wT1MBRWA/mGEL5UyU18QyfehoxAi9bhsssdw+dbe/mudUCs/SVVzX9gKfVGpyLClHTJpquyDJNGxrtFjLwifuYEom3916Nf44md1aPSr6nKTM6QPY4qrk0C6hMWNymT5Pmek2aPQxLntk8gfdawMFWyqUTHZ8W9di9mCksk9RxAmw55M2t4Q3eKObV+n9fNtZF84v2SRWrtBKCa4VGmPhfiddtr2WbKZxAyqkApRthzuN17RK6QJ4ehqGMs3CmXTGTFb56eOt+9zo1qdiJUJ9DN9xuD8h+r4VDovOz/X4fneNgnUd8/NgZm94GB+OfuKN9noEwT5lDxNlM2wL26Hysk39c2u684I3+f3agQzUfHZgHKYp2XnWX3PBMhC0/ZIIkgOc0ZS5n3joNM9SQJx9JOzfqOWLZ+uB9DiTaYaQyIsoZxGiqyBWg3qXuuDRbvAvQMYbiLDM Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 [...] >> (1) Cleanly separate the stages of shrink_folio_list() (see the TODO). >> >> (2) Avoid unlocking and locking folios again that do not require a TLB >> flush. But only if it's worth it and doesn't make the code too >> ugly. >> >> (3) Remove the remaining try_to_unmap_flush() calls before freeing >> folios; we only free folios that we flushed already or that we >> never unmapped. >> >> (4) Remove the now-unused try_to_unmap_flush_dirty() infrastructure. >> >> Fixes: 72b252aed506 ("mm: send one IPI per CPU to TLB flush all entries after unmapping pages") >> Link: https://lore.kernel.org/linux-mm/20261031-batch-tlb-flush-v6-0-190539839eec@tencent.com/ [1] >> Cc: stable@vger.kernel.org >> Acked-by: Zi Yan >> Reviewed-by: Kairui Song >> Signed-off-by: David Hildenbrand (Arm) > > Hmm this seems like a really heavyweight and significant change to be > backporting, especially so far. > > It's like you're implementing a whole new mechanism here, but also backporting > it. > No way around fixing it without destroying performance, I'm afraid. I tried and it would mean giving up delayed tlb flushing completely for reclaim, which is just unacceptable. It's a slightly biggger fix, yes, but I tried to be as little intrusive as possible. That's why I'm not sending it as a hotfix but will give it a bit of soaking time in -next. > I wonder a bit how the net of these backported patches are going to interact > honestly. But maybe I worry too much:) > > Maybe I'm just a bit frustrated at the rate of change going on ATM and how > completely unmanageable it is to keep up with it all. > Yeah. Fortunately we have memory reclaim experts around that know this code better than I do. > I fear waking up to an mm with about 20 new mechanisms I wasn't aware of + now I > have to figure them out/support them/etc :))) > Yes, same feeling here having to write fixes for serious problems on a weekly basis. [...] >> + /* >> + * Don't wait for synchronous discard I/O while keeping other folios >> + * locked: there is potential for deadlocks and long delays. >> + */ >> + staged_folios_flush(staged); >> + may_sync_discard = true; >> + return folio_alloc_swap(folio, may_sync_discard); >> +} >> + > > I genuinely do not think I've ever seen a Cc: stable patch add this much before, > it's really crazy. Oh, you didn't see my PAE patches back then? This here is trivial lol. > > Can we find some way of breaking this up or something? :) I wrote this fix to minimally impact existing code. We are just adding helpers here to make the changes to shrink_folio_list() below as minimal as possible. I don't see how splitting up the current patch would make any sense. Doing the full thing with cleanups first would be something different, but there is no way we could backport that. [...] >> - while (!list_empty(folio_list)) { >> + /* >> + * We reclaim folios in batches, in three phases: >> + * >> + * (a) Collect: we take folios from folio_list to pre-process them >> + * (lock, check, unmap). Then, they move to the staged(unflushed) >> + * list. If no TLB flush is pending for a folio, it moves to the >> + * staged(flushed) list directly. >> + * >> + * (b) Flush: once we collected a batch of staged folios, or there are >> + * no more folios to pre-process, we perform a single TLB flush and >> + * move the staged(unflushed) folios to the staged(flushed) list >> + * after unlocking them. >> + * >> + * (c) Reclaim: we take folios from the staged(flushed) list to actually >> + * reclaim them, or to activate them if they are still mapped. Once >> + * we took all folios of the batch, we start collecting again (a). >> + * >> + * Once all lists are empty, we are done. >> + * >> + * TODO: the stages of this algorithm should be cleanly separated. > > I mean this TODO is I guess you intended this patch to be reworked right? :) You mean the code? Yes, as also spelled out in the description above. Not this patch. [...] >> - /* >> - * Flush deferred writable TLB entries before we could >> - * drop the folio lock and others could start writeback. >> - */ >> - if (folio_test_dirty(folio)) >> - try_to_unmap_flush_dirty(); >> + unmapped = true; > > This seems like you're throwing in an optimisation for fun here too, which isn't > really great. I think it's the same thing we effectively had before: if nobody set delayed flushes, no flush for the folio was required. So it's not something new. if we didn't unmap, there is no need to flush for this folio. > > But claude raised the fact that PTE markers rely on this too (e.g. guard regions > can be applied to file-backed mappings, but also UFFDIO_POISON) and you'll get > writers writing through stale TLB entries this way, which seems like a really > bad (TM) thing. There might be other delayed TLB flushing issues, sure. I would be surprised if there wouldn't be some, because it's complicated. I spelled one out in the cover letter of v1. We have flush_tlb_batched_pending() to sync against exactly what you describe. I am pretty sure guard marker installation so far missed to call flush_tlb_batched_pending(). They really have to if they want to make sure no stale TLB entries can be used. zapping will call flush_tlb_batched_pending(), but if guard markers don't need that, there might be stale tlb entries (which wont cause corruption or anything like that). I had uffd in mind when working on this. But I was able to convince myself (well, AI helped) that it's just no something relevant to happen for uffd. uffd will just fail if something is already mapped. Which is why it's only used either after zapping (flush_tlb_batched_pending()) or on unpopulated ranges. so the race doesn't matter, in particular, about UFFDIO_POISON. Even for guard markers, there is only a tiny time window where you could still access the stale entries (while the folio is still in the page cache). It's hard to believe that that's really relevant in practice. The right fix would be to throw in a flush_tlb_batched_pending(), if we care. But that's completely independent of the changes here. That's just "syncing with reclaim" in a way people envisioned. Unfortunately. > > It's gross to have to 'just know' to think about these things here but I think > this should be reconsidered? Yes, a lot of the delayed tlb flushing is "you have to do the right thing". But I don't see us changing that in a fix :) We'll definetly need better docs, and I packed quite some information into my recent tlb flushing commit descriptions + cover letters. [...[ >> > > I think the rest of it needs to be chopped up to be really reviewable, or at > least it's late here so :) This is not really the material you're supposed to review after a long day :) . If Kairui, Zi and others that are familiar with this code give it their blessing, it should be good enough as a fix. -- Cheers, David