Skip to content

Commit b32d5f3

Browse files
yhuang-inteltorvalds
authored andcommitted
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>
1 parent 5d5e8f1 commit b32d5f3

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

mm/swapfile.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,16 +1123,13 @@ static struct swap_info_struct *swap_info_get_cont(swp_entry_t entry,
11231123
return p;
11241124
}
11251125

1126-
static unsigned char __swap_entry_free(struct swap_info_struct *p,
1127-
swp_entry_t entry, unsigned char usage)
1126+
static unsigned char __swap_entry_free_locked(struct swap_info_struct *p,
1127+
unsigned long offset,
1128+
unsigned char usage)
11281129
{
1129-
struct swap_cluster_info *ci;
1130-
unsigned long offset = swp_offset(entry);
11311130
unsigned char count;
11321131
unsigned char has_cache;
11331132

1134-
ci = lock_cluster_or_swap_info(p, offset);
1135-
11361133
count = p->swap_map[offset];
11371134

11381135
has_cache = count & SWAP_HAS_CACHE;
@@ -1160,6 +1157,17 @@ static unsigned char __swap_entry_free(struct swap_info_struct *p,
11601157
usage = count | has_cache;
11611158
p->swap_map[offset] = usage ? : SWAP_HAS_CACHE;
11621159

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);
11631171
unlock_cluster_or_swap_info(p, ci);
11641172

11651173
return usage;

0 commit comments

Comments
 (0)