mm: swap: skip slot cache on freeing for mTHP
authorKairui Song <kasong@tencent.com>
Wed, 31 Jul 2024 06:49:17 +0000 (23:49 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Sep 2024 04:15:25 +0000 (21:15 -0700)
commit650975d2b181e30c9017c42cb3f6535287555b1e
tree874ce1490b317804d772174f239b7c51b0f91c60
parent3b2561b5daeb3531c011491e9a6d2b934cc8f49f
mm: swap: skip slot cache on freeing for mTHP

Currently when we are freeing mTHP folios from swap cache, we free then
one by one and put each entry into swap slot cache.  Slot cache is
designed to reduce the overhead by batching the freeing, but mTHP swap
entries are already continuous so they can be batch freed without it
already, it saves litle overhead, or even increase overhead for larger
mTHP.

What's more, mTHP entries could stay in swap cache for a while.
Contiguous swap entry is an rather rare resource so releasing them
directly can help improve mTHP allocation success rate when under
pressure.

Link: https://lkml.kernel.org/r/20240730-swap-allocator-v5-5-cb9c148b9297@kernel.org
Signed-off-by: Kairui Song <kasong@tencent.com>
Reported-by: Barry Song <21cnbao@gmail.com>
Acked-by: Barry Song <baohua@kernel.org>
Cc: Chris Li <chrisl@kernel.org>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swapfile.c