Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.226 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796066016; b=uTYMCdemA5ahMCAWd0pQN/OyqsBrD68yX9f/GS3KxTTH3dXBBIs/YdI+d2N/Gw4FL2ST KqGMpfNzgJOAODbiKmluF87RVoa8siD/8HXqefbnI5TqHS4S/b6P/14VSPa6y2bL8fZRs W8PyTMvfxLUNY0zTeY/03167fzNucpWPjywXDXcqBEq4BAHbBUoWEr6bJVrjCWf6wow9w NuYwoSexlHMXb0z+25ZpUvapmkmGlBjx8070pS9LLFLaPeRgdfrBeKlCUj9Vs3nRDEPCq e/zY6/OCPmUl/lprbGTf1ZlTucqgSzIiAcIT9HW2YG1Zyenw7uCowwqKxkNBW+w1vkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796066016; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=349LDUJ+MK3bB+4UZnV0/eCc3RXxK7qXU2vem1XHtSc=; b=nMMLhgNvGc6VKbbRyxAxa+1YmkOfrmkDyVd3OjiYsxK8Rxw0uowuOWVOhfnaHH55VXkB 80WOhjrzHA23kNAcolUt3ek0/k2m5CJnXyDLxmY/EQ17+x/xMlrZ8Xh6X6NKTqIkzrWc2 ICRNjfSuxNXzkfI29leTjQxcmN9ZIzw+O/qjDIdSN3sZ+VPpKvFZd7IX7ZGWu1VEazkBU 2h6ysrPoQSC5aA/UC2E+rKg7MFEs+SkZrmN7gEYU7XqwszvjbqN7elcvl05cqbM7MUs/s 5QJmocKyGWxAcWrtSGFcakOmh5IEbXxLu+yK43Ale/EVEtR7Ir+GXDB6YaG1xhRQJMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=pWZGrRrC; arc=none smtp.remote-ip=95.215.58.226 Received: from mta1.migadu.com (out-226.mta1.migadu.com [95.215.58.226]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C159606A31C for ; Mon, 30 Nov 2026 19:13:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C159606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=pWZGrRrC X-Envelope-To: sashiko-reviews@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=qLRj+g9Dbw7pyRD35chMvg7WQJUk4uXEgG6Ou6y1wBY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796066013; v=1; x=1796670813; b=pWZGrRrC0HocDl58Dd6Wd01ToMwdlWxMlGUPhQXDsbU2LmPU4elizstKpPBE1VbZjm3ZDqm+ KTp9FfB8FnDtsaGG//Q5qlatqm0aEnOtiSkufNZxOwMHoh51aIq1oQ6HYJhvwFn2ALqnW5Bs7UN Ws8NVHALToZ70uCLa9p0NAMI= X-Envelope-To: sashiko-reviews@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id 528e3bb1c82a66f6; Mon, 30 Nov 2026 19:13:33 +0000 X-Mizu-Trace-ID: 528e3bb1c82a66f6 X-Migadu-Flow: FLOW_OUT Date: Mon, 30 Nov 2026 11:13:28 -0800 From: Shakeel Butt To: sashiko-reviews@lists.linux.dev Cc: Andrew Morton , Johannes Weiner , David Hildenbrand , Michal Hocko , Roman Gushchin , Muchun Song , Qi Zheng , Zi Yan , Lorenzo Stoakes , Vlastimil Babka , Kairui Song , Nhat Pham , Usama Arif , Hugh Dickins , Meta kernel team , linux-mm@kvack.org Subject: Re: [PATCH 4/4] mm/vmscan: don't give swap to an anon folio that nothing maps Message-ID: References: <20261130182755.666042-1-shakeel.butt@linux.dev> <20261130182755.666042-5-shakeel.butt@linux.dev> X-Mailing-List: sashiko-reviews@lists.linux.dev 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: On Mon, Nov 30, 2026 at 06:54:30PM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [Medium] mm/vmscan: unadjusted sc->nr_scanned in shrink_folio_list() > after folio split > - [Medium] mm/vmscan: redundant shrink_folio_list() retry in MGLRU > evict_folios() > -- > > commit adf73a464f11b1c23175eec0f7510cddfa8d6dc1 > Author: Shakeel Butt > > mm/vmscan: don't give swap to an anon folio that nothing maps > > This commit skips swap allocation in shrink_folio_list() for unmapped > anonymous folios that are not in the swap cache, and frees newly allocated > swap slots if the folio becomes an orphan during the unmap step. > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 99cb209797b4b..ddc1584d06eda 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > [ ... ] > > > @@ -1331,6 +1332,19 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, > > split_folio_to_list(folio, folio_list)) > > goto activate_locked; > > } > > + /* > > + * If nothing maps the folio, its last mapping went > > + * away, usually because its process exited, and no page > > + * table or shmem entry refers to it. It is freed when > > + * the last reference goes away. Giving it swap would > > + * only leave it in the swap cache if something else > > + * still holds a reference. KSM can map a KSM folio > > + * again; a later pass swaps it out then. This comes > > + * after the split above, so it also skips an unmapped > > + * first page of a partially mapped folio. > > + */ > > + if (!folio_mapped(folio)) > > + goto keep_locked; > > [Severity: Medium] > When split_folio_to_list() splits a partially mapped large folio and its > first page is unmapped, does jumping to keep_locked overcount > sc->nr_scanned by nr_pages - 1? Yes, thanks. The new check runs after the partial-map split, but it jumps over the fixup that every other exit after a split goes through, so the tail pages get counted twice. Will fix in v2 (after additional reviews are in). [...] > > [Severity: Medium] > Under MGLRU, does jumping to keep_locked before folio_mark_dirty() cause > evict_folios() to run a second shrink_folio_list() pass on every unmapped > non-swapcache anonymous folio? Yeah this need to be handled better. Will do something about in v2.