From ad20de2cd5838b6783e84eead0439643f3e5101a Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Thu, 7 Feb 2013 12:26:52 +1100 Subject: [PATCH] swap: add per-partition lock for swapfile fix I had all cpus spinning in swap_info_get(), for the lock on an area being swapped off: probably because get_swap_page() forgot to unlock. Signed-off-by: Hugh Dickins Cc: Shaohua Li Signed-off-by: Andrew Morton --- mm/swapfile.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index dfaff5f92865..7df5270fe3c8 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -470,10 +470,9 @@ swp_entry_t get_swap_page(void) spin_unlock(&swap_lock); /* This is called for allocating swap entry for cache */ offset = scan_swap_map(si, SWAP_HAS_CACHE); - if (offset) { - spin_unlock(&si->lock); + spin_unlock(&si->lock); + if (offset) return swp_entry(type, offset); - } spin_lock(&swap_lock); next = swap_list.next; } -- 2.39.5