mm: add cond_resched() to generic_swapfile_activate()
authorMikulas Patocka <[email protected]>
Thu, 28 Jul 2016 22:48:47 +0000 (15:48 -0700)
committerLinus Torvalds <[email protected]>
Thu, 28 Jul 2016 23:07:41 +0000 (16:07 -0700)
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]>
mm/page_io.c

index dcc5d3769608088a8c100f04f4e01dcccf5b74da..fb1fa269d3a06416151a2b3ef9e57a1e99ae4db5 100644 (file)
@@ -166,6 +166,8 @@ int generic_swapfile_activate(struct swap_info_struct *sis,
                unsigned block_in_page;
                sector_t first_block;
 
+               cond_resched();
+
                first_block = bmap(inode, probe_block);
                if (first_block == 0)
                        goto bad_bmap;