From: Mikulas Patocka Date: Thu, 28 Jul 2016 22:48:47 +0000 (-0700) Subject: mm: add cond_resched() to generic_swapfile_activate() X-Git-Tag: v4.14-rc1~2792^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e4411bfe6dd29713f879717b433304a1992526d;p=platform%2Fkernel%2Flinux-rpi.git 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 Acked-by: Michal Hocko Cc: Hugh Dickins Cc: Alexander Viro Cc: Mel Gorman Cc: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/page_io.c b/mm/page_io.c index dcc5d37..fb1fa26 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -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;