Skip to content

Commit 2c8507c

Browse files
fdmananakdave
authored andcommitted
btrfs: avoid monopolizing a core when activating a swap file
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: [email protected] # 5.4+ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 9a45022 commit 2c8507c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10078,6 +10078,8 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
1007810078
ret = -EINTR;
1007910079
goto out;
1008010080
}
10081+
10082+
cond_resched();
1008110083
}
1008210084

1008310085
if (bsi.block_len)

0 commit comments

Comments
 (0)