]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
btrfs: avoid monopolizing a core when activating a swap file
authorFilipe Manana <fdmanana@suse.com>
Mon, 9 Dec 2024 16:43:44 +0000 (16:43 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Dec 2024 21:04:48 +0000 (22:04 +0100)
During swap activation we iterate over the extents of a file and we can
have many thousands of them, so we can end up in a busy loop monopolizing
a core. Avoid this by doing a voluntary reschedule after processing each
extent.

CC: stable@vger.kernel.org # 5.4+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index c4675f4345fd7fcf8fe44b232f50e1f7f3875220..623d9d7ab48032d50ffe20c586f665ef90363890 100644 (file)
@@ -10078,6 +10078,8 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
                        ret = -EINTR;
                        goto out;
                }
+
+               cond_resched();
        }
 
        if (bsi.block_len)