Skip to content

Refactor sys_swapon

Cesar Eduardo Barros linux-mm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest posting 2/224 patches 43 repliesIn review
  2. v2 posting 1/224 patches 7 repliesSuperseded
  3. v124 patches 2 repliesSuperseded

Changes in v2 from the cover letter

Rebased from v2.6.38-rc4 to v2.6.38-rc7.

Patches in v2 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/24sys_swapon: use vzalloc instead of vmalloc/memsetmm/swapfile.c+1 -23 replies
2/24sys_swapon: remove changelog from function commentmm/swapfile.c+0 -53 replies
3/24sys_swapon: do not depend on "type" after allocationmm/swapfile.c+5 -52 replies
4/24sys_swapon: separate swap_info allocationmm/swapfile.c+37 -202 replies
5/24sys_swapon: simplify error return from swap_info allocationmm/swapfile.c+2 -42 replies
6/24sys_swapon: simplify error flow in alloc_swap_infomm/swapfile.c+1 -62 replies
7/24sys_swapon: remove initial value of name variablemm/swapfile.c+1 -12 replies
8/24sys_swapon: move setting of error nearer usemm/swapfile.c+6 -53 replies
9/24sys_swapon: remove did_down variablemm/swapfile.c+1 -31 reply
10/24sys_swapon: remove bdev variablemm/swapfile.c+9 -101 reply
11/24sys_swapon: do only cleanup in the cleanup blocksmm/swapfile.c+3 -41 reply
12/24sys_swapon: use a single error labelmm/swapfile.c+3 -41 reply
13/24sys_swapon: separate bdev claim and inode lockmm/swapfile.c+39 -251 reply
14/24sys_swapon: simplify error flow in claim_swapfilemm/swapfile.c+6 -141 reply
15/24sys_swapon: move setting of swapfilepages near usemm/swapfile.c+1 -23 replies
16/24sys_swapon: separate parsing of swapfile headermm/swapfile.c+78 -621 reply
17/24sys_swapon: simplify error flow in read_swap_headermm/swapfile.c+6 -91 reply
18/24sys_swapon: call swap_cgroup_swapon earliermm/swapfile.c+4 -42 replies
19/24sys_swapon: separate parsing of bad blocks and extentsmm/swapfile.c+54 -292 replies
20/24sys_swapon: simplify error flow in setup_swap_map_and_extentsmm/swapfile.c+5 -142 replies
21/24sys_swapon: remove nr_good_pages variablemm/swapfile.c+3 -52 replies
22/24sys_swapon: move printk outside lockmm/swapfile.c+8 -71 reply
23/24sys_swapoff: change order to match sys_swaponmm/swapfile.c+4 -32 replies
24/24sys_swapon: separate final enabling of the swapfilemm/swapfile.c+42 -422 replies

Reviews trailers per patch

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

PatchEric B MunsonPekka EnbergJesper JuhlKAMEZAWA Hiroyuki
1/24T-b A-b R-b R-b R-b
2/24T-b A-b R-b R-b R-b
3/24T-b A-b R-b R-b
4/24T-b A-b R-b R-b
5/24T-b A-b R-b R-b
6/24T-b A-b R-b R-b
7/24T-b A-b R-b R-b
8/24T-b A-b R-b R-b R-b
9/24T-b A-b R-b
10/24T-b A-b R-b
11/24T-b A-b R-b
12/24T-b A-b R-b
13/24T-b A-b R-b
14/24T-b A-b R-b
15/24T-b A-b R-b R-b R-b
16/24T-b A-b R-b
17/24T-b A-b R-b
18/24T-b A-b R-b R-b
19/24T-b A-b R-b R-b
20/24T-b A-b R-b R-b
21/24T-b A-b R-b R-b
22/24T-b A-b R-b
23/24T-b A-b R-b R-b
24/24T-b A-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 4 reviewers.

Read the v2 thread

Cover letter [PATCHv2 00/24] Refactor sys_swapon

[Resending with a Cc: list generated by get_maintainer.pl as suggested by Eric B Munson, and with his Tested-by and Acked-by added to each patch.]

This patch series refactors the sys_swapon function.

sys_swapon is currently a very large function, with 313 lines (more than 12 25-line screens), which can make it a bit hard to read. This patch series reduces this size by half, by extracting large chunks of related code to new helper functions.

One of these chunks of code was nearly identical to the part of sys_swapoff which is used in case of a failure return from try_to_unuse(), so this patch series also makes both share the same code.

As a side effect of all this refactoring, the compiled code gets a bit smaller (from v1 of this patch series):

   text       data        bss        dec        hex    filename
  14012        944        276      15232       3b80    mm/swapfile.o.before
  13941        944        276      15161       3b39    mm/swapfile.o.after

The v1 of this patch series was lightly tested on a x86_64 VM.

[Eric B Munson <[email protected]> adds for the v2 of this patch series:

Quoted 4 lines

I have tested this set on x86_64 by manually adding/removing swap files and partitions. Also I used the hugeadm program (fomr libhugetlbfs) to add temporary swap files on disk and using ram disks. All of this worked well.

]

Changes from v1:
Rebased from v2.6.38-rc4 to v2.6.38-rc7.

Cesar Eduardo Barros (24):
sys_swapon: use vzalloc instead of vmalloc/memset
sys_swapon: remove changelog from function comment
sys_swapon: do not depend on "type" after allocation
sys_swapon: separate swap_info allocation
sys_swapon: simplify error return from swap_info allocation
sys_swapon: simplify error flow in alloc_swap_info
sys_swapon: remove initial value of name variable
sys_swapon: move setting of error nearer use
sys_swapon: remove did_down variable
sys_swapon: remove bdev variable
sys_swapon: do only cleanup in the cleanup blocks
sys_swapon: use a single error label
sys_swapon: separate bdev claim and inode lock
sys_swapon: simplify error flow in claim_swapfile
sys_swapon: move setting of swapfilepages near use
sys_swapon: separate parsing of swapfile header
sys_swapon: simplify error flow in read_swap_header
sys_swapon: call swap_cgroup_swapon earlier
sys_swapon: separate parsing of bad blocks and extents
sys_swapon: simplify error flow in setup_swap_map_and_extents
sys_swapon: remove nr_good_pages variable
sys_swapon: move printk outside lock
sys_swapoff: change order to match sys_swapon
sys_swapon: separate final enabling of the swapfile

 mm/swapfile.c |  360 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 197 insertions(+), 163 deletions(-)
Signature · 8 lines
1.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>