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 0193A606A332 for ; Mon, 30 Nov 2026 14:03:09 +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=ZnM6XU7n Received: by kanga.kvack.org (Postfix) id 147AE6B05B4; Mon, 30 Nov 2026 09:03:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F94C6B05B5; Mon, 30 Nov 2026 09:03:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00F446B05B6; Mon, 30 Nov 2026 09:03:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CC1AF6B05B4 for ; Mon, 30 Nov 2026 09:03:07 -0500 (EST) Received: from smtpin05.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3AAD7120A85 for ; Mon, 30 Nov 2026 14:03:07 +0000 (UTC) X-FDA: 85491952014.05.B135FC6 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf08.hostedemail.com (Postfix) with ESMTP id 595B316000F for ; Mon, 30 Nov 2026 14:03:05 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ZnM6XU7n; spf=pass (imf08.hostedemail.com: domain of ljs@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=ljs@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796047385; b=qUa0uTBL/II1/JDbSqHn6MZWwTLo7+pNhpy114uN2CW2zkLAuBSRmSIjb9N2ZRuMsz39cM xJtLUmQoJbPusgQLa/v9Mjjh+ByMiyWM0djXaZC1reWC3tRqO2fjVUWnYCf7hlQ0xVJITC 7LOILFG87b+b6lKn24Kuqhs0fG9m8qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796047385; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eD/z512KJFkMdwLb1AtuS/dZaxt/Oxg7ARIUduFvD9M=; b=XN79zvAuzzXKDdI36j6ZoNGYzLrZXw0xlMIWZ+h4bYkVYJ72QyZM/3znu1ohvsg2R9nqeL zHCCsQq5GwdYPxbQI/khHc81qYNpZR/EZznJBXki5tk8zwGW0scr/zzhUP3bGvm4B1gFWa z5hrjpqkbH4m65apjzLiWfOCVZ2bQIY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ZnM6XU7n; spf=pass (imf08.hostedemail.com: domain of ljs@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=ljs@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A5428620FC; Mon, 30 Nov 2026 14:03:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19A731F00932; Mon, 30 Nov 2026 14:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796047384; bh=eD/z512KJFkMdwLb1AtuS/dZaxt/Oxg7ARIUduFvD9M=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ZnM6XU7nIcPSbkjzEdHIVHmOqndZ+ePCRS8sT8POK1brKgPFnmZ/y+chaC10JTkEI fhqMMbWxqjOra4HTP7K1OWQr2ZQnv8gTbiSHQNGNOCppxQw7sz6tbsbshBwtyiKkI2 GX7x6gLIRn25bG27GBhFg0eHHNkimonmiGGBrgyQ68FuMK75iK9L1oqxAwfesTp2L5 orrAyaql1Nuz8T44LafkKUzQTvh1QPUkDGcLuEtRbryQB7Knz+tfbq9WrMTHx6Yyr5 Ap1TUsYBw8UN/YmZTBA+dYkVS0dBysagvM2+fs7+BxS8h84JIWLNQnhV9YF4vsiWRa Wa2WlU/0zpsKw== Date: Mon, 30 Nov 2026 14:02:53 +0000 From: "Lorenzo Stoakes (ARM)" To: Pedro Falcato Cc: Jan Harkes , coda@cs.cmu.edu, Andrew Morton , David Rheinsberg , Hugh Dickins , Vlastimil Babka , "Liam R. Howlett" , David Hildenbrand , Jann Horn , Alex Shi , Johannes Weiner , David Rientjes , Rik van Riel , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Shuah Khan , Randy Dunlap , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Arnd Bergmann , Stephen Rothwell , Muhammad Usama Anjum , codalist@coda.cs.cmu.edu, linux-mm@kvack.org, Andrei Vagin , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Chris Mason Subject: Re: [PATCH 2/4] mm/madvise: don't declare OOM for MADV_WILLNEED swapin Message-ID: References: <20261127-mlock-madvise-mprotect-ai-fixes-v1-0-e46b2b1eb435@kernel.org> <20261127-mlock-madvise-mprotect-ai-fixes-v1-2-e46b2b1eb435@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 595B316000F X-Stat-Signature: qxqojspixxiqnd513qy6fi7w8brg1p4b X-Rspamd-Server: rspam12 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFF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PnYQWEXDCdLY3/74Y dtRGwA8B 8JpMuIux2stvCwF059OrB5IfCmhqbBLcaYP1F4cKNh5Dj8E8jQ1L6L30owWqYXjO3V34QcdN/UGlrMb4lg+4Cqw+N6yFLNV0TOKG2Tzt/TFlcpddz6sDTbRlkbBuybnFTH4hhPi1I3TcAwcy9hv1HFfJdveRIkjVFY5Mz5kDHIO0xbeacCH0HyIJ+8vnUUh57p2myKsXPdaRHKoZsscnxYRu9N4gA0CgbcNK5s0ddFrA+nRSFwMv5qgE+RlM1spugM3b0RbMFdabZa3J9+3PLul6yvGnTn1wY8Moh/587Pd8UQfG/R3uYtPB9FMX1J8p38+EBbA2+53k9Ttpdo1zsaXIMPbOhCtFpF9p1/XcJNpIo5slGB2rVj3ekCThHeHqsW4AAgUWLabZHDYmgx6wBhDmBOLyBW1jaL/iXeNP8SA9iZ0ySOKQAveaSbp3jeLOXQ9Jex3qNohCKw+YKQZdxAMxtTtJfmLxr1TIm4zUj0naKNYBaMdagQXw0ftTSqXziv26B1KNvjPVvlvsxb8uHANWueASwgvxnGKDrzYpOahDTHyc= 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 On Fri, Nov 27, 2026 at 10:14:39PM +0000, Pedro Falcato wrote: > On Fri, Nov 27, 2026 at 07:45:41PM +0000, Lorenzo Stoakes (ARM) wrote: > > From: Chris Mason > > > > MADV_WILLNEED on memory in swap can OOM kill a task when the memcg that > > the swap entries are charged to is at its limit. > > > > The hint is only a prefetch, so it has to give up on a page when memory > > is short. But swapin_walk_pmd_entry() and shmem_swapin_range() call > > read_swap_cache_async() with GFP_HIGHUSER_MOVABLE and with the gfp mask > > of the mapping, so the allocation and the memcg charge can both go as > > far as the OOM killer. > > > > The charge goes to the memcg of the swap entry, which need not be the > > caller's. > > > > The fix used here is to allocate with the gfp mask of readahead, and to > > flush the block plug when a page fails. madvise_do_behavior() plugs the > > whole walk, so the swap writes of reclaim can sit in that plug. Their > > folios stay under writeback, and with no retries the rest of the range > > can fail as well. > > How about we don't do that? Something something separation of concerns. > If we want this functionality (and we very well might), I would suggest > we do this in reclaim code itself. Something like > > blk_finish_plug_or_flush(). > > Because I really don't want to set the precedent of making every direct reclaim > caller aware of block plugs. > > Either that, or we let it fail. > I think that's follow-up stuff in general! The block plug stuff is pretty grim overall... > > > > The hint can now skip pages when memory is short, whether in a memcg at > > its limit or on the system as a whole, since neither the allocation nor > > the memcg charge is retried any longer. > > > > This applies in particular where reclaim has to write to swap to make > > room. Skipped pages stay in swap until a fault reads them. > > > > Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation") > > Signed-off-by: Chris Mason > > [ ljs: commit message tweak ] > > Signed-off-by: Lorenzo Stoakes (ARM) > > Aside from the above: > Reviewed-by: Pedro Falcato Thanks! > > -- > Pedro -- Cheers, Lorenzo