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 6E5A6438012 for ; Wed, 12 Aug 2026 12:18:16 +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=1786537097; cv=none; b=q3ua7RS1LCoPv/PWHa7nNuGhBhHNnjJZjSeXZ47esqPxPed/TevLPHLkGZDkhdZ+12h7Y52H+UGCJzUEH7OWpg7fX4PjxbWQCFN136Hpr5sjaSXvnlmcUgLtI0yGj1hWb2ziX9YjRrIvjAb3u/cGwH4R1DdT6EfznuoUgfMHzdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786537097; c=relaxed/simple; bh=UQK3XK6c5Wr4mcmzYRvd3zgI8+nyrnhmwRcECofVmPY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JMUZ7n2XMu9I0/SZUhYtKCCUlL8+ClkdkzCCH6y98VwbhDusZ6dF5K7hRXl9C1SpVHrrR/lVBqoNdf+lChjvNNsfow8mKxeTgNglwsaZ0b1OzkbWyP2NEg/qkTH2lxRQcLiUtd6TRlwhsEt32HnLoVQ5ZjZHwyRwsaCkmR0tQxk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R9S12A8I; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R9S12A8I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CCFC1F00ACA; Wed, 12 Aug 2026 12:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786537096; bh=uepm22g2J/5iiwM0/TymuO6Dk8rItX1/CDBy+v0l+eE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R9S12A8IO8zHeVVFYk3oGKcmS8dHnKtd493X3Or8A9aMUAnd6TNwa1+X4f5MGtMO4 HZkg1bXcsT54Nq1o0ZUngNCkE7ad4jVS6yhmG9vec/HJLix348ZdwSfOffTFYWzUQn hlQ8+kbywEs6WbtaDYMCUFY6Jt3Y92l0pxWPusHszQozoihM8HV18KN4Jf2RSME68h FDSuRqkmtnRbAzctC9qysMudGB9lb8be25nzo46e9D+vU6CUqdrBdL9FlU9F6/ePLR jV1Dtr/Bon9GdcngDpxypLFv611Zo0azHucegMQWobd0dcSjZXFMZa9UenFCzkaosC 0XnW0QYQJb98A== From: "Barry Song (Xiaomi)" To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: axelrasmussen@google.com, chenridong@xiaomi.com, david@kernel.org, hannes@cmpxchg.org, kasong@tencent.com, lianux.mm@gmail.com, linux-kernel@vger.kernel.org, ljs@kernel.org, lyugaofei@xiaomi.com, mhocko@kernel.org, qi.zheng@linux.dev, shakeel.butt@linux.dev, stevensd@chromium.org, wangzicheng@honor.com, weixugc@google.com, yuanchu@google.com, zhangbo56@xiaomi.com, baolin.wang@linux.alibaba.com, baoquan.he@linux.dev, "Barry Song (Xiaomi)" Subject: [RFC PATCH v4 03/16] mm/mglru: retry the same type once if isolation fails due to races Date: Wed, 12 Aug 2026 20:16:45 +0800 Message-Id: <20260812121658.69965-4-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20260812121658.69965-1-baohua@kernel.org> References: <20260812121658.69965-1-baohua@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If we are not exhausted (i.e., there are still folios in the reclaimable generations) but fail to isolate any folios due to promotions, protection, or races, give this type one more chance to avoid going through the outer loop again. Signed-off-by: Barry Song (Xiaomi) --- mm/vmscan.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 0670a25d3a7e..dddd2ecf970a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4868,7 +4868,7 @@ static int isolate_folios(unsigned long nr_to_scan, struct lruvec *lruvec, bool type_fallback_allowed = !is_single_type_reclaim(swappiness); int type = get_type_to_scan(lruvec, swappiness); int total_scanned = 0, scanned, tier; - bool exhausted; + bool exhausted, tried = false; retry: tier = get_tier_idx(lruvec, type); @@ -4891,6 +4891,14 @@ static int isolate_folios(unsigned long nr_to_scan, struct lruvec *lruvec, type_fallback_allowed = false; goto retry; } + /* + * We are not exhausted, but failed to isolate any folios due to + * races. Give this type one more chance to avoid a larger loop. + */ + if (!exhausted && !tried) { + tried = true; + goto retry; + } return total_scanned; } -- 2.34.1