diff options
author | Huang Ying <ying.huang@intel.com> | 2018-10-26 18:03:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-26 19:25:19 -0400 |
commit | 10e364da10d73ce4e3b61e1c53319ce93ee51c63 (patch) | |
tree | dc59810d6cad5311837e68142c84b0cc02339169 /mm/swapfile.c | |
parent | bcd49e86710b42f15c7512de594d23b3ae0b21d7 (diff) |
mm/swapfile.c: call free_swap_slot() in __swap_entry_free()
This is a code cleanup patch without functionality change.
Originally, when __swap_entry_free() is called, and its return value is 0,
free_swap_slot() will always be called to free the swap entry to the
per-CPU pool. So move the call to free_swap_slot() to __swap_entry_free()
to simplify the code.
Link: http://lkml.kernel.org/r/20180827075535.17406-3-ying.huang@intel.com
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Shaohua Li <shli@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 0d44179213ed..eaa5e2e55cab 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -1182,6 +1182,8 @@ static unsigned char __swap_entry_free(struct swap_info_struct *p, | |||
1182 | ci = lock_cluster_or_swap_info(p, offset); | 1182 | ci = lock_cluster_or_swap_info(p, offset); |
1183 | usage = __swap_entry_free_locked(p, offset, usage); | 1183 | usage = __swap_entry_free_locked(p, offset, usage); |
1184 | unlock_cluster_or_swap_info(p, ci); | 1184 | unlock_cluster_or_swap_info(p, ci); |
1185 | if (!usage) | ||
1186 | free_swap_slot(entry); | ||
1185 | 1187 | ||
1186 | return usage; | 1188 | return usage; |
1187 | } | 1189 | } |
@@ -1212,10 +1214,8 @@ void swap_free(swp_entry_t entry) | |||
1212 | struct swap_info_struct *p; | 1214 | struct swap_info_struct *p; |
1213 | 1215 | ||
1214 | p = _swap_info_get(entry); | 1216 | p = _swap_info_get(entry); |
1215 | if (p) { | 1217 | if (p) |
1216 | if (!__swap_entry_free(p, entry, 1)) | 1218 | __swap_entry_free(p, entry, 1); |
1217 | free_swap_slot(entry); | ||
1218 | } | ||
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | /* | 1221 | /* |
@@ -1637,8 +1637,6 @@ int free_swap_and_cache(swp_entry_t entry) | |||
1637 | !swap_page_trans_huge_swapped(p, entry)) | 1637 | !swap_page_trans_huge_swapped(p, entry)) |
1638 | __try_to_reclaim_swap(p, swp_offset(entry), | 1638 | __try_to_reclaim_swap(p, swp_offset(entry), |
1639 | TTRS_UNMAPPED | TTRS_FULL); | 1639 | TTRS_UNMAPPED | TTRS_FULL); |
1640 | else if (!count) | ||
1641 | free_swap_slot(entry); | ||
1642 | } | 1640 | } |
1643 | return p != NULL; | 1641 | return p != NULL; |
1644 | } | 1642 | } |