From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9077D171CD for ; Fri, 24 Jul 2026 05:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784871427; cv=none; b=rgQCvKTn6ll8TM02LI7khEYEWtLWgKPhP2SqjlVKuJqsNrB/O/qGh+/3Tqd5cEzQJ6gUawar5ns6GUMROgigkRV8V9pJXBOTZhJD8M8zpdFKb1FQUWWqOxglQB/Eo0bqOyjc/aqd7UCBlDqCDds71MqVF2sPt0iQlS9fbe0i5dw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784871427; c=relaxed/simple; bh=EKIGUG+tgAjn0ogbcp38XikaPTJRTFzoRaanmfzlLjM=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=KURcTR0Z9pSOb9sVsLudBu8ANaKM3Iwql+SyBH2nH5ydMvixqIFj/auJs0VXAlkM3uDPj5VmVZodjgcJ8OkFaeRgT4poylyJRUUEl6EFs9Na0DUaMZKJftZ9MNcQkChZp6Loex/jWoA79W3Ya94TUHO5JeW8aCLQ9zs6+OZGtag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=MnLxdN9h; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="MnLxdN9h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 598E81F000E9; Fri, 24 Jul 2026 05:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1784871426; bh=wJtbvJ1YpwlbmNpCTYOzLU+4UtJm/ekub34SmAtyOvA=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=MnLxdN9hGGlqIFi8VE0gKP3pUPuVEzC6vNzl8hLsC6T/fK7yLqycMOyGXYaVGypVo JEc3mJxsVwxN7qQG+homPj5qs+4cVW26R++IKAID02jk4nzYNX+n0vIPo+kLqOWomL wpvvSFwgBWKlcHbCTtEC1zTDHvnMnYUeZab1okvI= Date: Thu, 23 Jul 2026 22:37:04 -0700 From: Andrew Morton To: Ridong Cc: Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Zhongkun He , Muchun Song , Davidlohr Bueso , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ridong Chen Subject: Re: [PATCH -v4 0/4] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Message-Id: <20260723223704.b030220f6ca120c53c2f68d7@linux-foundation.org> In-Reply-To: <20260724033435.2573323-1-ridong.chen@linux.dev> References: <20260724033435.2573323-1-ridong.chen@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 24 Jul 2026 11:34:31 +0800 Ridong wrote: > Fixes and one cleanup. > > Patch 1 fixes "swappiness=max": the anon-only test in get_scan_count() > sat after the "cannot reclaim anon" check, so when no anon was > reclaimable the request fell back to SCAN_FILE and evicted page cache > instead. > > Patch 2 fixes reclaim_store() collapsing every error into -EAGAIN, so > callers can no longer tell an invalid argument from a busy interface; > propagate the real error code, matching the memcg path. > > Patch 3 drops the now-unused gfp_mask parameter from __node_reclaim(). > > Patch 4 fixes the same "swappiness=max" issue for MGLRU. Thanks, I've updated mm.git's mm-unstable branch to this version. Sashiko said one thing, but you've examined this before. Hopefully MGLRU maintainers will consider your suggestion in https://lore.kernel.org/8336e48a-ab3a-4db9-a7f9-5bb6af2b22c3@linux.dev https://sashiko.dev/#/patchset/20260723045718.2052070-1-ridong.chen@linux.dev > v3 -> v4: > - Patch 4: Update comments and commit message. > - Patch 4: Adopted Sashiko's suggestion to use WARN_ON_ONCE. Here's how v4 altered mm.git: mm/vmscan.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) --- a/mm/vmscan.c~b +++ a/mm/vmscan.c @@ -2492,7 +2492,13 @@ static void get_scan_count(struct lruvec enum scan_balance scan_balance; enum lru_list lru; - /* Proactive reclaim initiated by userspace for anonymous memory only */ + /* + * Proactive reclaim initiated by userspace for anonymous memory only. + * SWAPPINESS_ANON_ONLY is set only on the proactive reclaim path, so + * warn if it shows up elsewhere. When anon cannot be reclaimed (e.g. + * no swap), bail out instead of falling back to evicting file pages, + * which would violate the anon-only semantics. + */ if (swappiness == SWAPPINESS_ANON_ONLY) { WARN_ON_ONCE(!sc->proactive); if (!can_reclaim_anon_pages(memcg, pgdat->node_id, sc)) { @@ -2693,6 +2699,10 @@ static int get_swappiness(struct lruvec { struct mem_cgroup *memcg = lruvec_memcg(lruvec); struct pglist_data *pgdat = lruvec_pgdat(lruvec); + int swappiness = sc_swappiness(sc, memcg); + + if (swappiness == SWAPPINESS_ANON_ONLY) + return swappiness; if (!sc->may_swap) return 0; @@ -2701,7 +2711,7 @@ static int get_swappiness(struct lruvec mem_cgroup_get_nr_swap_pages(memcg) < MIN_LRU_BATCH) return 0; - return sc_swappiness(sc, memcg); + return swappiness; } static int get_nr_gens(struct lruvec *lruvec, int type) @@ -4903,6 +4913,20 @@ static long get_nr_to_scan(struct lruvec struct mem_cgroup *memcg, int swappiness) { unsigned long nr_to_scan, evictable; + struct pglist_data *pgdat = lruvec_pgdat(lruvec); + + /* + * Proactive reclaim initiated by userspace for anonymous memory only. + * SWAPPINESS_ANON_ONLY is set only on the proactive reclaim path, so + * warn if it shows up elsewhere. When anon cannot be reclaimed (e.g. + * no swap), return 0 to skip the scan entirely, avoiding useless scan + * work when there is nothing eligible to reclaim. + */ + if (swappiness == SWAPPINESS_ANON_ONLY) { + WARN_ON_ONCE(!sc->proactive); + if (!can_reclaim_anon_pages(memcg, pgdat->node_id, sc)) + return 0; + } evictable = lruvec_evictable_size(lruvec, swappiness); _