Skip to content

swap: cleanup get/put_swap_device() usage

Huang Ying linux-mm lkml 1 version Applied

Status from this message: [merged mm-stable] swap-remove-__swp_swapcount.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 8 repliesApplied 5/5

V3 from the cover letter

- Fix build error in [2/5], Thanks David!

- Fix comments and patch description about the folio in swap cache, Thanks David!

- Collected reviewed-by.

Patches in v1 All 5 applied

#Subject and filesSizeRepliesApplied
1/5swap: Remove get/put_swap_device() in __swap_count()mm/swapfile.c+2 -81 replyApplied
2/5swap, __read_swap_cache_async(): enlarge get/put_swap_device protection rangemm/swap_state.c+21 -102 repliesApplied
3/5swap: remove __swp_swapcount()include/linux/swap.h mm/swap_state.c mm/swapfile.c+4 -222 repliesApplied
4/5swap: remove get/put_swap_device() in __swap_duplicate()mm/swapfile.c+1 -42 repliesApplied
5/5swap: comments get_swap_device() with usage rulemm/swapfile.c+9 -31 replyApplied

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchYosry AhmedDavid HildenbrandChris Li (Google)
1/5R-b R-b R-b
2/5R-b R-b
3/5R-b R-b
4/5R-b R-b R-b
5/5R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH -V3 0/5] swap: cleanup get/put_swap_device() usage

The general rule to use a swap entry is as follows.

When we get a swap entry, if there aren't some other ways to prevent swapoff, such as the folio in swap cache is locked, page table lock is held, etc., the swap entry may become invalid because of swapoff. Then, we need to enclose all swap related functions with get_swap_device() and put_swap_device(), unless the swap functions call get/put_swap_device() by themselves.

Based on the above rule, all get/put_swap_device() usage are checked and cleaned up if necessary.

Changelogs:

V3:

- Fix build error in [2/5], Thanks David!

- Fix comments and patch description about the folio in swap cache, Thanks David!

- Collected reviewed-by.

V2:

- Split patch per David's comments. Thanks!

Best Regards,
Huang, Ying