]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: swapfile: fix SSD detection with swapfile on btrfs
authorJohannes Weiner <hannes@cmpxchg.org>
Thu, 22 Aug 2024 11:24:58 +0000 (13:24 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Sep 2024 04:15:46 +0000 (21:15 -0700)
commitb843786b0bd01ced7fcdbf3b033d68db2f7c61b2
tree1ae6a263ab7e356c723b10ec2eecd47d5f2add48
parent0692fad55d3c1ed3766a1e8627af15b951097894
mm: swapfile: fix SSD detection with swapfile on btrfs

We've been noticing a trend of significant lock contention in the swap
subsystem as core counts have been increasing in our fleet.  It turns out
that our swapfiles on btrfs on flash were in fact using the old swap code
for rotational storage.

This turns out to be a detection issue in the swapon sequence: btrfs sets
si->bdev during swap activation, which currently happens *after* swapon's
SSD detection and cluster setup.  Thus, none of the SSD optimizations and
cluster lock splitting are enabled for btrfs swap.

Rearrange the swapon sequence so that filesystem activation happens
*before* determining swap behavior based on the backing device.

Afterwards, the nonrotational drive is detected correctly:

- Adding 2097148k swap on /mnt/swapfile.  Priority:-3 extents:1 across:2097148k
+ Adding 2097148k swap on /mnt/swapfile.  Priority:-3 extents:1 across:2097148k SS

Link: https://lkml.kernel.org/r/20240822112707.351844-1-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swapfile.c