Skip to content

mm/swap: remove plist swap_active_head

Baoquan He linux-mm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mm/swapfile.c: remove __has_usable_swap()mm/swapfile.c+1 -60 replies
2/3mm/swapfile.c: use swap_info[] to find the swap devicemm/swapfile.c+3 -14 replies
3/3mm/swap: remove unneeded swap_active_headinclude/linux/swap.h mm/swapfile.c+4 -1711 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] mm/swap: remove plist swap_active_head

In mm/swapfile.c, there are two plist variables, swap_active_head and swap_avail_head. swap_avail_head contains all available (active, not full) swap_info_structs orderred by priority. While swap_active_head contains all active swap_info_structs (active, nor full and full) orderred by priority. Earlier, it serves three purposes:

1) When swapoff one swap device in the middle, swap devices of priority
lower than the swapped off swap device will be promoted up value one,
e.g, I swapped off zram1 of priority '-3', then zram2 promoted to
have priority '-3', zram3 has priority '-4'. This is done via plist swap_active_head.
- This code has been taken off in
- [PATCH v3 0/2] mm/swapfile.c: select the swap device with default priority round robin

# swapon
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition  16G   0B   -2
/dev/zram1 partition  16G   0B   -3
/dev/zram2 partition  16G   0B   -4
/dev/zram3 partition  16G   0B   -5
# swapoff /dev/zram1
# swapon
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition  16G   0B   -2
/dev/zram2 partition  16G   0B   -3
/dev/zram3 partition  16G   0B   -4

2) Find a swap device in swap_active_head when swap off.
- This can be done through iterating swap_info[] instead. Change is done in patch 2.

3) Judge if there's any active swap device via __has_usable_swap().
- This can be done by checking total_swap_pages instead. Change is done in patch 1.

Among them, the purpose 1) is the most important, while it has been
taken off in below patchset. So this patchset removing swap_active_head sits on top of it.
- [PATCH v3 0/2] mm/swapfile.c: select the swap device with default priority round robin
- https://lore.kernel.org/all/[email protected]/T/#u

Baoquan He (3):
mm/swapfile.c: remove __has_usable_swap() mm/swapfile.c: use swap_info[] to find the swap device mm/swap: remove unneeded swap_active_head

 include/linux/swap.h |  1 -
 mm/swapfile.c        | 31 ++++++++-----------------------
 2 files changed, 8 insertions(+), 24 deletions(-)
Signature · 1 line
2.41.0