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 966524483B4 for ; Wed, 12 Aug 2026 12:19:08 +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=1786537150; cv=none; b=Q803Ydn6uYfvwf4tnwShi4NdGtcWSC84DlqIcEAs2Y0EvjxwUbrtgGS+oPggHA4D6iCRbCH1CRrW6sAX8crzbZKQrf7AmWMC4LptInECVO5ZpsHS00ZNrbgPzTcD85r8PfiJmxujy2N7658WvPKykQ9tcuH9Yze8MIxfdhFtrQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786537150; c=relaxed/simple; bh=jFSf4JY9UOydcxq5jAdVNUTNf1xAMWVhGYmVKnID0GY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HNx/emvibT8AtOhqMOFVjWi57tIDX8s2Yvg1h10CjJKlad/Msjdu8ZKCWWh938GYQ/FmQMq0+ESM1aOIjFsmz0MKioTw85GUU2BOHwQJbEmW5zPXyBj6b6r+nIsdMCm7UtdGTgCMeN0ZYnBVsvA03fHdSfOOZq37s3rTNYeuqQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BsFRzI2n; 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="BsFRzI2n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C99A31F00A3E; Wed, 12 Aug 2026 12:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786537148; bh=SOSrpdrgv6m75PZgqu/T7iS0CPPWanT5qI9R6irTmB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BsFRzI2nY/1moZp4Yo1jlnOlYcl3kc9gOA06lA5u6dIR0/qRsH/qbcaotVI9o6wVc D7f2GopsSziedN0lyRn9BqFZ7s2cLl4ptJQVjlnLdsGkT0JaPDJqYjYH7uOrugOp06 +MazIwctBjQKUerp5d4ILwNXf74z6BkGGmtr23nDuDeWS6qRXK6aHL/nlazZekMNAo JtEaAspJfrtH0EgLKph41ZGAWAfIUUSx+A47N4QFWZfBlBFtZo70kSZ3vA7ZOFpRRo 3HI2LzekNYZsaoANA0beFRJaWuyBIGBJZiEXxjQ9fFzaCTF+KjHJaAKWQSp600T82H 94rX0SYL89juA== 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 16/16] mm/mglru: reduce folios pulled from the oldest gen in inc_min_seq() Date: Wed, 12 Aug 2026 20:16:58 +0800 Message-Id: <20260812121658.69965-17-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 Pulling folios from the oldest generation to the second-oldest generation with MAX_LRU_BATCH can take a long time, as the spinlock is held throughout the operation and blocks other users. Reduce the remaining batch size significantly. This reduces the lock hold time, allowing concurrent reclaim, lru_cache_drain, and other operations to make progress. Signed-off-by: Barry Song (Xiaomi) --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index c0350a8b61d1..8e6fcefe0353 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3945,7 +3945,7 @@ static inline void flush_lru_batch(struct list_head *head, struct list_head **ba static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness) { int zone; - int remaining = MAX_LRU_BATCH; + int remaining = MAX_LRU_BATCH / (is_extreme_swappiness(swappiness) ? 2 : 8); struct lru_gen_folio *lrugen = &lruvec->lrugen; int hist = lru_hist_from_seq(lrugen->min_seq[type]); int new_gen, old_gen = lru_gen_from_seq(lrugen->min_seq[type]); -- 2.34.1