]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
swap: add per-partition lock for swapfile fix
authorHugh Dickins <hughd@google.com>
Thu, 7 Feb 2013 01:26:52 +0000 (12:26 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:46:42 +0000 (16:46 +1100)
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 <hughd@google.com>
Cc: Shaohua Li <shli@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swapfile.c

index dfaff5f9286550dda1453bc71444be69f7225d01..7df5270fe3c84caabb411b46d070139a028806fa 100644 (file)
@@ -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;
        }