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 1477C3D5241 for ; Thu, 11 Jun 2026 10:51:35 +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=1781175096; cv=none; b=Nv8f75fDQkjT8JY8FMlBmYYd40ZyKceOYM0Uhc/1EYIj1H5bMUOW02HKD677172wDI6nCl4T/CE9uoiP9isAuEVXxDZG+3X2cF8uBFo0NFl+kyxGSllTnQJIkpsf3waGGLTV38I5352VMVWbj7ItrzFRQyxV+qx+mkdosimjljA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781175096; c=relaxed/simple; bh=zJG1ToGe29e5fTcHpM/Cz2gfoBihQn7hvp329q/QIL4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fcS9PJHgzCiZl++EJjBiWbC2r6Yk4XmhyGW5RMMjcIv+NgMUvRVi5Iw1nkVx+DOaJEeVMrHGy11ljkFllZ5LmU8LDXQtRV6GtJYEUcQyrSe/h8k4jJ9Aa2Cq5kDeaOXj+Ayo3nJuQq1u0Rjq2vfkNxcWDqQFQIosD48cc8Y1Gqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DFJYVtwB; 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="DFJYVtwB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A8251F00893; Thu, 11 Jun 2026 10:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781175095; bh=rp4x1W2aaSXSOWAvb1ECGK7Mj6f2q5dWywK0jlX3R/0=; h=From:To:Cc:Subject:Date; b=DFJYVtwBXfYe9uyg/0bHusYw5TtKQ5QnASLgQG1otjGAy3ixDyXm8aH+KBUruvYS1 3D3XJaHo9Qj4L1Si3WEzsDmxNMfaOt1ug0KhYQdaCQhOLLP89D9jiTDO9Pd88grZzu kMRUljzHrqtJa2CMDnbX1+m9Lja67RzDVpYsQspPTIftgrqJlnrndp/ZYpnvZ2ZhiY 1yJaIZ4wxtWT0jhBi6t6t7ydLRTKTC7p8k5l+Zd3t7HSHNw2OYsqoQGCglpr2jceX/ G21sbsxvhQrHmNIdvMXzE0WXGZk6sufS0HU1I/o1knq1R6qa5/DgIY9pm2uI1meAym wnLCMvmKunxRw== From: "Barry Song (Xiaomi)" To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, david@kernel.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, baoquan.he@linux.dev, youngjun.park@lge.com, jp.kobryn@linux.dev, usama.arif@linux.dev, shakeel.butt@linux.dev, "Barry Song (Xiaomi)" Subject: [RFC PATCH 0/3] mm: drop redundant lru_add_drain in anon folio reuse paths Date: Thu, 11 Jun 2026 18:51:21 +0800 Message-Id: <20260611105124.98668-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 We are doing a large number of redundant lru_add_drain() calls in both wp_can_reuse_anon_folio() and do_swap_page(), leading to LRU lock contention and unnecessary overhead. In wp_can_reuse_anon_folio(), we can check the refcount against the lru_cache before deciding to drain. In do_swap_page(), the drain is now entirely redundant after Kairui's work to route SYNC I/O through the swapcache in the same way as ASYNC I/O. Build the kernel within a 1GB memcg using 20 threads with zRAM swap. The number of lru_add_drain() calls is reduced from 276,787 to 230,283, while sys time decreases slightly from 3m40.125s to 3m37.128s. Build the kernel within an 800MB memcg using 20 threads with zRAM swap. The number of lru_add_drain() calls is reduced from 796,661 to 537,262, while sys time decreases slightly from 6m25.981s to 6m22.678s. Barry Song (Xiaomi) (3): mm: avoid unnecessary lru drain for wp_can_reuse_anon_folio() mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic mm: entirely remove lru_add_drain in do_swap_page mm/memory.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) -- 2.39.3 (Apple Git-146)