]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
swap: add per-partition lock for swapfile fix
authorHugh Dickins <hughd@google.com>
Wed, 20 Feb 2013 02:14:40 +0000 (13:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:52:47 +0000 (16:52 +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;
        }