WIP: update tizen_qemu_defconfig
[platform/kernel/linux-starfive.git] / mm / swapfile.c
index 5fc1237..71db6d8 100644 (file)
@@ -679,6 +679,7 @@ static void __del_from_avail_list(struct swap_info_struct *p)
 {
        int nid;
 
+       assert_spin_locked(&p->lock);
        for_each_node(nid)
                plist_del(&p->avail_lists[nid], &swap_avail_heads[nid]);
 }
@@ -973,23 +974,23 @@ done:
 scan:
        spin_unlock(&si->lock);
        while (++offset <= READ_ONCE(si->highest_bit)) {
-               if (swap_offset_available_and_locked(si, offset))
-                       goto checks;
                if (unlikely(--latency_ration < 0)) {
                        cond_resched();
                        latency_ration = LATENCY_LIMIT;
                        scanned_many = true;
                }
+               if (swap_offset_available_and_locked(si, offset))
+                       goto checks;
        }
        offset = si->lowest_bit;
        while (offset < scan_base) {
-               if (swap_offset_available_and_locked(si, offset))
-                       goto checks;
                if (unlikely(--latency_ration < 0)) {
                        cond_resched();
                        latency_ration = LATENCY_LIMIT;
                        scanned_many = true;
                }
+               if (swap_offset_available_and_locked(si, offset))
+                       goto checks;
                offset++;
        }
        spin_lock(&si->lock);
@@ -1101,6 +1102,7 @@ start_over:
                        goto check_out;
                pr_debug("scan_swap_map of si %d failed to find offset\n",
                        si->type);
+               cond_resched();
 
                spin_lock(&swap_avail_lock);
 nextsi:
@@ -2427,8 +2429,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
                spin_unlock(&swap_lock);
                goto out_dput;
        }
-       del_from_avail_list(p);
        spin_lock(&p->lock);
+       del_from_avail_list(p);
        if (p->prio < 0) {
                struct swap_info_struct *si = p;
                int nid;