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 760F2388E55 for ; Thu, 20 Aug 2026 04:57:11 +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=1787201832; cv=none; b=Ye38PSY8zAgyJHYfm3o75mEIHZN9XQ8y+cZPq9Zx+9RvuOx9ZOBe7c8lqL/M1aoS9wIMl8BrbWfsqs9gVZj+MTyJeouUPhQb1Jpy4Iclk5eyC4tE7nyup3iUgs4Fl1X88vC2ibe8nAu3FDYnjoSl6C8cNQ7K2o0Dd5r7Q+Rdl4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787201832; c=relaxed/simple; bh=xU4S5wt0aBlVzzELqWgwbpX+y/fXS6BoJaGYVZGJtB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=doQeYr8RTWwIz1op5EcvjTF+ucERq60a9jpscUTg4Vwx4IghfnzCI74UwUzu4p5/LqGYgSnWfJIpbtW4DxR3S/wbG0JhXUg5ROJmokqHPd/HL06QKQurE1ANOLKmLJp39QBtrrzg1BdGgSabdPN9w+36cW92fDEwfbbagGWjIKs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AjJX9t8d; 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="AjJX9t8d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3DD81F00A3A; Thu, 20 Aug 2026 04:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787201831; bh=leejdAoqEqZUEy4AxrXKtUzDLcGvX9RnYsTPxVQMljU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AjJX9t8d1iHhdRU7OOIHyWRfxUYNBT7+IhGAeNv/mDa1oB/ISuwI9IO1gpOW/tnio CyWqy6AAx1CojOSTz0zOrLBZQuLaMFT4Zx4X8WDSeHRV2oEDVBquJnP6zoXoqRk5tM 4yBnWVrn9gS4iUXDxccgX7dVxI5PG4xKRgYO2aqHc/qB+fEzTq3qzSiinyGgU6Fndx tD3JUR+C7VkgdPQeNgkWRdtSAI+zOTqujXtJzk5mfifgeKat5dDMZuXI6B3MY/KsJM C+ZOStoNFjopd1olV3zRTrjJYrufhClOETEn2FQ9+5LNn6rDcnHCbM/q2htaeQtJPH /EwJdB3S9Z7Ag== From: "Barry Song (Xiaomi)" To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: axelrasmussen@google.com, baolin.wang@linux.alibaba.com, baoquan.he@linux.dev, 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, "Barry Song (Xiaomi)" Subject: [PATCH 3/3] mm/mglru: retry the same type once if isolation fails due to races Date: Thu, 20 Aug 2026 12:56:03 +0800 Message-Id: <20260820045603.68809-4-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20260820045603.68809-1-baohua@kernel.org> References: <20260820045603.68809-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, protections, or races, retry once more 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 1f2e574b0061..1f302386d8ab 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4862,7 +4862,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); @@ -4885,6 +4885,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 + * promotions, protections, or races. Retry once to avoid a larger loop. + */ + if (!exhausted && !tried) { + tried = true; + goto retry; + } return total_scanned; } -- 2.34.1