Skip to content

Commit 7e4411b

Browse files
Mikulas Patockatorvalds
authored andcommitted
mm: add cond_resched() to generic_swapfile_activate()
generic_swapfile_activate() can take quite long time, it iterates over all blocks of a file, so add cond_resched to it. I observed about 1 second stalls when activating a swapfile that was almost unfragmented - this patch fixes it. Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1607221710580.4818@file01.intranet.prod.int.rdu2.redhat.com Signed-off-by: Mikulas Patocka <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4e390b2 commit 7e4411b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/page_io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ int generic_swapfile_activate(struct swap_info_struct *sis,
166166
unsigned block_in_page;
167167
sector_t first_block;
168168

169+
cond_resched();
170+
169171
first_block = bmap(inode, probe_block);
170172
if (first_block == 0)
171173
goto bad_bmap;

0 commit comments

Comments
 (0)