From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3AF53D1A97 for ; Fri, 17 Jul 2026 12:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784293088; cv=none; b=MRD/pmQp3z5ZdPclymRReY8mfrrtZLPn0MTPyceLvfN7+ohpGHusR2/GDqdrTvlK46BQoZ9e91jTOy3Bcyx6Nk0GNZ6Ph7Zi1h5EN3BWoWvhlpDcnwUdawFWltovHio36MliW5m8OtqTueIdwOWJz/w4lJpHLv6wiAdZEhOCyMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784293088; c=relaxed/simple; bh=EmtrvTwPJg0UuZRE2KPhogWOkFa5s0OSDm195dweb6Q=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=NBq/vfBBE8galuiNxIWC5erZxU32wWzpisfnrSysvOFBh9+UNbaO4JYw2H1QaOXAkPMEzdmBSS/i3mooniBTonx8M/O5r/Y1PHIdM++TqwA7Ulsp9hZHUwUOMzUiPs/6+0vzTymT/gYkHITMKEAQrTlb0uQgyhOUla/7UnrRehg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EGs1NHeo; arc=none smtp.client-ip=91.218.175.181 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) header.d=linux.dev header.i=@linux.dev header.b="EGs1NHeo" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784293084; h=from:from: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; bh=h8QlOs/Th6MXRqRGOnwqE9p4KTXTTAFv9QAMgXIYmo4=; b=EGs1NHeoq9tit3WxCJSM8I1cK2HPTVo1PoXxmags79SQ5+CwLK4+WybfxUpB85JZO2jGRN eJr142nugAiwh0kSzCEQZMkDIRfiXF/M4kRWrB3uPo3lkN6festRI7xPKXCpQKYeih79vE q3Pqogh/7ovzC9/k0bQN0ci5xpWpN2w= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260717113300.214717-2-ridong.chen@linux.dev> Date: Fri, 17 Jul 2026 20:57:31 +0800 Cc: Andrew Morton , Johannes Weiner , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , Zhongkun He , Davidlohr Bueso , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ridong Chen Content-Transfer-Encoding: quoted-printable Message-Id: References: <20260717113300.214717-1-ridong.chen@linux.dev> <20260717113300.214717-2-ridong.chen@linux.dev> To: Ridong X-Migadu-Flow: FLOW_OUT > On Jul 17, 2026, at 19:32, Ridong wrote: >=20 > From: Ridong Chen >=20 > As Qi mentioned [1], when swappiness=3Dmax (SWAPPINESS_ANON_ONLY) is = set, > the reclaim logic is expected to reclaim anonymous pages exclusively. > However, due to the current ordering of checks in get_scan_count(), > file pages may still be evicted if can_reclaim_anon_pages() returns > false, which contradicts the semantics of SWAPPINESS_ANON_ONLY. >=20 > Reproducer in a cgroup holding 64M of file cache, with no swap = configured: >=20 > Before (file cache is wrongly evicted): > # cat memory.stat > anon 196608 > file 67178496 > pgscan_proactive 0 > # echo "64M swappiness=3Dmax" > memory.reclaim > # cat memory.stat > anon 208896 > file 4096 <- page cache evicted > pgsteal_proactive 16400 > pgscan_proactive 16400 >=20 > After (file cache is left intact): > # cat memory.stat > anon 200704 > file 67178496 > pgscan_proactive 0 > # echo "64M swappiness=3Dmax" > memory.reclaim > -bash: echo: write error: Resource temporarily unavailable > # cat memory.stat > anon 208896 > file 67178496 <- page cache untouched > pgsteal_proactive 0 > pgscan_proactive 0 >=20 > Fix this by bailing out early when SWAPPINESS_ANON_ONLY is set and no > anonymous pages are reclaimable, before falling back to file reclaim. >=20 > [1] = https://lore.kernel.org/cgroups/7ddf3eee-5fe2-45f7-8614-c8936a039e04@linux= .dev/ >=20 > Fixes: 68a1436bde00 ("mm: add swappiness=3Dmax arg to memory.reclaim = for only anon reclaim") > Suggested-by: Qi Zheng > Signed-off-by: Ridong Chen Reviewed-by: Muchun Song