Skip to contentSkip to conversation

mm: add cond_resched() to generic_swapfile_activate()

PATCH New [email protected] 1 participant 1 message Jul 28, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 86/101 mm: add cond_resched() to generic_swapfile_activate()

From: Mikulas Patocka <[email protected]>
Subject: 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.

---

 mm/page_io.c |    2 ++
 1 file changed, 2 insertions(+)
mm/page_io.c renamed from mm/page_io.c~mm-add-cond_resched-to-generic_swapfile_activate +2 -0
diff -puN mm/page_io.c~mm-add-cond_resched-to-generic_swapfile_activate mm/page_io.c
@@ -166,6 +166,8 @@ int generic_swapfile_activate(struct swa
 		unsigned block_in_page;
 		sector_t first_block;
 
+		cond_resched();
+
 		first_block = bmap(inode, probe_block);
 		if (first_block == 0)
 			goto bad_bmap;

_