From: Hugh Dickins Date: Wed, 20 Feb 2013 02:14:40 +0000 (+1100) Subject: swap: add per-partition lock for swapfile fix X-Git-Tag: next-20130220~1^2~460 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=728cff79227f1315a9e224230d4b7c53fafa0162;p=karo-tx-linux.git 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 --- 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; }