diff options
author | Huang Ying <ying.huang@intel.com> | 2018-08-22 00:52:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-22 13:52:44 -0400 |
commit | b32d5f32b9dbe64970f41602066f7904df15f3e9 (patch) | |
tree | 3c9255d3f983350ea545b175e91bc334865759ea /mm/swapfile.c | |
parent | 5d5e8f19544a35ae1609bd96ae6b28c9fcd1baf6 (diff) |
mm/swapfile.c: add __swap_entry_free_locked()
The part of __swap_entry_free() with lock held is separated into a new
function __swap_entry_free_locked(). Because we want to reuse that
piece of code in some other places.
Just mechanical code refactoring, there is no any functional change in
this function.
Link: http://lkml.kernel.org/r/20180720071845.17920-8-ying.huang@intel.com
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Acked-by: 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>
Cc: Rik van Riel <riel@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Matthew Wilcox <willy@infradead.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 | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index b30dd0642ccf..d44b2d60a66a 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -1123,16 +1123,13 @@ static struct swap_info_struct *swap_info_get_cont(swp_entry_t entry, | |||
1123 | return p; | 1123 | return p; |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | static unsigned char __swap_entry_free(struct swap_info_struct *p, | 1126 | static unsigned char __swap_entry_free_locked(struct swap_info_struct *p, |
1127 | swp_entry_t entry, unsigned char usage) | 1127 | unsigned long offset, |
1128 | unsigned char usage) | ||
1128 | { | 1129 | { |
1129 | struct swap_cluster_info *ci; | ||
1130 | unsigned long offset = swp_offset(entry); | ||
1131 | unsigned char count; | 1130 | unsigned char count; |
1132 | unsigned char has_cache; | 1131 | unsigned char has_cache; |
1133 | 1132 | ||
1134 | ci = lock_cluster_or_swap_info(p, offset); | ||
1135 | |||
1136 | count = p->swap_map[offset]; | 1133 | count = p->swap_map[offset]; |
1137 | 1134 | ||
1138 | has_cache = count & SWAP_HAS_CACHE; | 1135 | has_cache = count & SWAP_HAS_CACHE; |
@@ -1160,6 +1157,17 @@ static unsigned char __swap_entry_free(struct swap_info_struct *p, | |||
1160 | usage = count | has_cache; | 1157 | usage = count | has_cache; |
1161 | p->swap_map[offset] = usage ? : SWAP_HAS_CACHE; | 1158 | p->swap_map[offset] = usage ? : SWAP_HAS_CACHE; |
1162 | 1159 | ||
1160 | return usage; | ||
1161 | } | ||
1162 | |||
1163 | static unsigned char __swap_entry_free(struct swap_info_struct *p, | ||
1164 | swp_entry_t entry, unsigned char usage) | ||
1165 | { | ||
1166 | struct swap_cluster_info *ci; | ||
1167 | unsigned long offset = swp_offset(entry); | ||
1168 | |||
1169 | ci = lock_cluster_or_swap_info(p, offset); | ||
1170 | usage = __swap_entry_free_locked(p, offset, usage); | ||
1163 | unlock_cluster_or_swap_info(p, ci); | 1171 | unlock_cluster_or_swap_info(p, ci); |
1164 | 1172 | ||
1165 | return usage; | 1173 | return usage; |