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 E2A98387371 for ; Thu, 20 Aug 2026 04:56:59 +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=1787201820; cv=none; b=RJnrEiDdE/CF14feY158Hq0JgkwXJYPm5vCruP0iE8JaFtJgY4w0MFgYrKgLeuVEcdyAO+gklyEMLRevrmwLd+ka6mWS2XpNldB1c1lOG6CARsYaV4m5CY2+NDx/DqpRaC4jgsG4YdUFFKBhCPi5NFjSwrKlHFfmfmfnfVjDK1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787201820; c=relaxed/simple; bh=+pd/zcXuMiUZ07eITykZJIyvW/YFMRtWDAjuvUEMvcc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iszc8ghMjLemQxwlQoHnfBfIbF3X4YyqXQPHTE1KVd3neyty2tjuhnrVXbK2v5lEo0UkSEWScM6oj1k+ig3hOXxCS2pdwYZ33ZLUDoJHF9gizBicpjkMyuNMpMNYPwCz27yCguZ6Piz4TYtNKBLtvMmHfnpbMyFUtKWDCzcsJgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NFUgWOys; 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="NFUgWOys" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14A071F000E9; Thu, 20 Aug 2026 04:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787201819; bh=4L3tCYfMcprThTLF8cGSPkkXsWoPgAHAwOsqwT0J3EQ=; h=From:To:Cc:Subject:Date; b=NFUgWOysqFkevH2ZIEaDAd+BW0UQ3QQY/W3BpLgPgTDV1UDTLHVkss0hbYQUFJAWW OBilIRV7RMcezR+VXGnXMioPtkQ7ip7cYTIoqKypvllfQ/j3YZxFbcJwDroHU0whhC 3XD0PvU6Z5ebQ7HHkzGGbzlmwiIkjgisePXr0YqMGyQVBPr1AATdoHZU7Tq4peUafi sXIG9CGn417LTehvsMMq5kQnyxecVJk4VOUJ7K24CyCjNfndD/DPTfqCON+Ee1sHXD nxPrR5A4hs4l+VBQD1baPY2ddDntsquS7SOspxq9b+OOpVwY/S5ZxGo5OAN8CIILyo BNuTJYCYocpiw== 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 0/3] mm/mglru: clean up isolate_folios and scan_folios for readability and clarity Date: Thu, 20 Aug 2026 12:56:00 +0800 Message-Id: <20260820045603.68809-1-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is a cleanup series split out from the MGLRU swappiness series [1], with the cleanup changes separated to make them easier to review. Right now, isolate_folios() is quite difficult to follow: 1. It uses for_each_evictable_type(i, swappiness) to iterate over the types, but i is not actually used as the type within the loop body. 2. It uses scanned == 0 to detect whether the current reclaim type is exhausted, but this is not an accurate indication. 3. It has an internal retry when no folios can be isolated after scanning some folios, but the retry is implemented in a way nobody can understand. This patchset makes these behaviors explicit and much easier to follow. Run kernel builds for several rounds in a 1 GB memcg and take the average build time. The patchset shows almost no performance impact, with a very small improvement that could simply be noise: w/o patch w/patch Delta real 109.149 108.990 -0.15% sys 223.213 222.592 -0.28% pgscan_file 498,208 486,994 -2.25% refault_file 262,696 254,688 -3.05% Thanks very much to Baolin and Lian for their previous reviews of the original RFC patchset for this part. [1] https://lore.kernel.org/linux-mm/20260812121658.69965-1-baohua@kernel.org/ Barry Song (Xiaomi) (2): mm/mglru: improve scan_folios() exhaustion detection mm/mglru: retry the same type once if isolation fails due to races Ridong Chen (1): mm/mglru: improve readability of isolate_folios() mm/vmscan.c | 78 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 24 deletions(-) -- 2.34.1