Merge tag 'block-6.1-2022-12-08' of git://git.kernel.dk/linux
[platform/kernel/linux-starfive.git] / mm / swapfile.c
index 5fc1237..72e481a 100644 (file)
@@ -973,23 +973,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);