From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 988853F7A94 for ; Fri, 17 Jul 2026 12:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784289875; cv=none; b=XCVh5FLbhXUNDTQnp/gfIpE2nWwPEBFhHcwWjOZyFYSf21jfGed4/YyhWy0Obuk36ftQvCq6pe0lUS2Q2tkmXDoTuDE34qL7GxVic1nuAoin+grY/sWZl3HUXA2LxIvXDgswxJa/GjB+V/l5f5CSWleHkTz5JK2xlifTiF5VDUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784289875; c=relaxed/simple; bh=yagyn56tOLAO8Swhncunf1RI6UmRQ7I21XsKnX2AEig=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ebnz+ImaN4HvY8sGnaHvVKCPQhZMW9S5zYlUgbBysaiJ488s2LSAc5xFOrU6vSiz/Y3LUEK7RupI/7hg7XOvQBcOAVXl2Qw5ceOaxNhvFP8PPx0Xt4E1evfK1FxgZ8bSastDp9eecZsoZuBLKyFAjMw+LpU4yxssaweJSeg+/FA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=l1m+/UsW; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="l1m+/UsW" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-47f3b39f2a1so3105565f8f.2 for ; Fri, 17 Jul 2026 05:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1784289870; x=1784894670; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=qJ6WZXaTyawewtx3o5XBUlEYKfZN+y4PWw7nzDNSFDk=; b=l1m+/UsWYXGkqRT4nhr45IdqvRNlRsMnGm+zdR4/CJe3Hxb1CuOvGdhqP5pWN6ijyJ oJmRuTRXEYAFepYJnICrI2xiTJZ6Mdh3sZH/1+trjmctwNRTdGexP/+s/DbBJy+kwlhv lAX/3zAxdl/9mYgpQhWXIkAXN+CDoHA0OIa7YciX7zKWHBynl2JsV55Uk8X3JjPZfG6X AfxtmMs0r1oA0ecDJcOznuODyNad6cJ8HwpLA3GhWwcAJcYEBUVUeDMDzJpF44hIqZjf t80hKwasFj1Ps+8L3ukVxACUfzwHNjjmo+3HTrJOCrkBq1wU3dTdK8xCsgWMe0NhWizH kFjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784289870; x=1784894670; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qJ6WZXaTyawewtx3o5XBUlEYKfZN+y4PWw7nzDNSFDk=; b=lo4aay+OJQXxuhT/DVtvpVgOxmSWu/QZnxRTwAJ4JTukaieXhpQ5j+Ott13fjEsP1P Kmdh/lZduOYKOzMeTo/UDPtXZJAhM5dShwJ1KWtLjV8P9TaNRj930JcchV0R/Aqo8XbU NR0/jhMu4ql9bkkX9fM3nP5ypq6HItCbUsTmvwGKptyiHpyIhX5ZZeLcq5RvSSRSWXhA /iLBVT+nvNi8x4moscF1veI7vQ3RGM+GvDzBB8AzmTsz1sqwFottTjl22AhOSk4GiPSj XnT446sKc9w/D6Qjru47eFRREiuiax+vGKg8x8c/NOs5sYuYKn7Y36eEjbl03kztE0LO 12Kg== X-Forwarded-Encrypted: i=1; AHgh+Ro8XWN91F9vajAPpaG400ZLIBrTEELdG5dxAXBNF6c778mPQ0Zr7IV5J0GN+uaP/UiTgeOorJl5sXXSlDA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0mXnpZuPYRugyhJcQA2T0N4vlpnT6lBnkCcmt0EkOikj9ViPz t0VlJWF2qGBM0tSWZugWO9L1Z859plfIu0Ln/pNdhBQ0jH2PfnlK1AE0kXuCL/Bj3Fk= X-Gm-Gg: AfdE7clYCZeTE2LR0OGXjKL9gCyZEZdq1CKl+RqaaRzW4yRS7EjKN46TSad4V2jqLMl rhkfuu1LzvMFG1HUCzDwNOXnGPr1aZNVS2BHNKUmcEK7295lpI1NkmHHEcxrbqmei45PZdnTWG1 TZBQLKqgJSq8Yh9CfwhiUVzTTtmQERYngycDRws+A/USj3qSSGtGxtqlgwinF4ASA+Q0Kutu/3D cR4cC1uAOK6iCaYsCKeMs07KwR1lyTVEf2htFa9L/1moZW9P3EUTVi43xTsnVBaZrmAZxtpSJSm vKY8x0H+mvmtHijv15TzxTbDjsnh9rSDS76zKpE0DWusN/rgiY51srtbWQTDUXFB7hiZMCMs73D AWEYo7vruZVu+UOSJZv08/vRa9z8wqkRj8l/Xoqm5CBbgwkc5m1OUgJxwHEIbJt2J9olWbbD17w o= X-Received: by 2002:a05:6000:4912:b0:473:1ccc:15c9 with SMTP id ffacd0b85a97d-47f6232249fmr2988035f8f.40.1784289870493; Fri, 17 Jul 2026 05:04:30 -0700 (PDT) Received: from localhost ([2a02:8071:6401:180:d892:bf43:a0b4:83b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63e52673sm3661111f8f.15.2026.07.17.05.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 05:04:29 -0700 (PDT) Date: Fri, 17 Jul 2026 14:04:28 +0200 From: Johannes Weiner To: Ridong Cc: Andrew Morton , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , Zhongkun He , Muchun Song , Davidlohr Bueso , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ridong Chen Subject: Re: [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Message-ID: <20260717120428.GC6843@cmpxchg.org> References: <20260717113300.214717-1-ridong.chen@linux.dev> <20260717113300.214717-2-ridong.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260717113300.214717-2-ridong.chen@linux.dev> On Fri, Jul 17, 2026 at 07:32:58PM +0800, Ridong wrote: > From: Ridong Chen > > As Qi mentioned [1], when swappiness=max (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. > > Reproducer in a cgroup holding 64M of file cache, with no swap configured: > > Before (file cache is wrongly evicted): > # cat memory.stat > anon 196608 > file 67178496 > pgscan_proactive 0 > # echo "64M swappiness=max" > memory.reclaim > # cat memory.stat > anon 208896 > file 4096 <- page cache evicted > pgsteal_proactive 16400 > pgscan_proactive 16400 > > After (file cache is left intact): > # cat memory.stat > anon 200704 > file 67178496 > pgscan_proactive 0 > # echo "64M swappiness=max" > 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 > > Fix this by bailing out early when SWAPPINESS_ANON_ONLY is set and no > anonymous pages are reclaimable, before falling back to file reclaim. > > [1] https://lore.kernel.org/cgroups/7ddf3eee-5fe2-45f7-8614-c8936a039e04@linux.dev/ > > Fixes: 68a1436bde00 ("mm: add swappiness=max arg to memory.reclaim for only anon reclaim") > Suggested-by: Qi Zheng > Signed-off-by: Ridong Chen Acked-by: Johannes Weiner