From nobody Mon Feb 9 06:31:01 2026 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (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 D2DE11DF26E for ; Wed, 21 Jan 2026 09:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768986476; cv=none; b=fAMk9w1iR7OtQ900SH0tXQSWypeImAdTSO2e4SiFoEqSSrhVdIQdGEVKX8TRO+YSzVuNBX/gBjqthgVav/NJph4Qr9QRxlR4EsHvKye/DkItclJKgz9dvNyJ1l9hJG/zc9d1/iNxVhA6B71iNvM0w7K1yi1ZEfAgYdMbv3qRwQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768986476; c=relaxed/simple; bh=QPaYhyVO2ho7o3xoaInoF1w9v1+n2OQRyW/huvnMpvs=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=b2Ed+fjdfWKXjitM8nwIr7lnsBMfCeiMQcdriSW74YxHXNYHcJr78U0ILBdADp3ALy6xAXER728pIrKcKmbXDBZkaFhjJlqj+Kb6LRFgSpIQSCoGPKoAgwU2dqozLndczWfBEGHfIKxowEe8blhg5dYjAE8k7jPM1FG0w2/EuHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; dkim=pass (2048-bit key) header.d=unisoc.com header.i=@unisoc.com header.b=IGSBgW9r; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unisoc.com header.i=@unisoc.com header.b="IGSBgW9r" Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 60L96UuJ012986; Wed, 21 Jan 2026 17:06:30 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (BJMBX01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4dwypS02FCz2MGpnb; Wed, 21 Jan 2026 17:00:47 +0800 (CST) Received: from bj03382pcu03.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 21 Jan 2026 17:06:28 +0800 From: "zhaoyang.huang" To: Andrew Morton , Michal Hocko , Johannes Weiner , , , Zhaoyang Huang , Subject: [PATCH] mm: bail out when meet the goal of proactive memcg reclaim Date: Wed, 21 Jan 2026 17:06:20 +0800 Message-ID: <20260121090620.559242-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 60L96UuJ012986 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unisoc.com; s=default; t=1768986410; bh=Ti/VJ8zqauemkj5X2GjKo0Pb5M0bLDQ2QV+IUZscyAc=; h=From:To:Subject:Date; b=IGSBgW9rSzEU/BbXcaDhvmqhTe497jczaQL9kQ6+Bb1FA67/1or0fVU7DYYD/1Wbj qC+zVF5v7yJs/Xne0eiV4KMJZe9urhqQ5Z/K+m8yOQWwF+Q/dEZXmCrcMfigK7anxI zfteYpCKgCXKuibq8Q+q8MLSTjDAqVUgPcPR5kOxGWW/8f0ScQtBLAnmPQHOtjGN63 tSvjxLnbmi5W/Byy65qOrepuzgZwoBsOyiR4EvHbBi+jO6dIDmVBh6LnU08QhiXdpr aRHg4eW+Aynv3JDFkwy7kzY9Z8ki44WHycyRjltzZcXM21CvMBLJlD3YcxzbzTjGnw W7cfc2+mdVIKw== Content-Type: text/plain; charset="utf-8" From: Zhaoyang Huang The proactive memcg reclaim defines the specific target mem cgroup as well as a certain number of memories, which is different to the kswapd and direct reclaim that need to keep the fairness among cgroups. This commit would like to introduce a criteria to have proactive reclaim bail out when target mem cgroup could meet the goal via its own lruvec, which means the reclaim would also go through the whole tree if the iter start on the desendants. Signed-off-by: Zhaoyang Huang --- mm/vmscan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 670fe9fae5ba..5dcca4559b18 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6028,8 +6028,15 @@ static void shrink_node_memcgs(pg_data_t *pgdat, str= uct scan_control *sc) sc->nr_scanned - scanned, sc->nr_reclaimed - reclaimed); =20 - /* If partial walks are allowed, bail once goal is reached */ - if (partial && sc->nr_reclaimed >=3D sc->nr_to_reclaim) { + /* If partial walks are allowed, or proactive reclaim where + * the target memcg is clearly defined that could let us ignore + * the fairness thing, bail once goal is reached. + * note: for proactive reclaim, the criteria make sense only + * when target_memcg has both of descendant groups and folios + * charged. Other wise, walk the whole tree under target_memcg. + */ + if ((partial || (sc->proactive && target_memcg =3D=3D memcg)) && + sc->nr_reclaimed >=3D sc->nr_to_reclaim) { mem_cgroup_iter_break(target_memcg, memcg); break; } --=20 2.25.1