Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1448791

[PATCH 1/2] mm: add cond_resched to generic_swapfile_activate

From Mikulas Patocka <mpatocka@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] mm: add cond_resched to generic_swapfile_activate
Date 2016-07-22 23:20 +0200
Message-ID <rXQ1s-2G8-19@gated-at.bofh.it> (permalink)
References <rXQ1r-2G8-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The function 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.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 mm/page_io.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-4.7-rc7/mm/page_io.c
===================================================================
--- linux-4.7-rc7.orig/mm/page_io.c	2016-05-30 17:34:37.000000000 +0200
+++ linux-4.7-rc7/mm/page_io.c	2016-07-11 17:23:33.000000000 +0200
@@ -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;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] mm patches Mikulas Patocka <mpatocka@redhat.com> - 2016-07-22 23:20 +0200
  [PATCH 2/2] mm: optimize copy_page_to/from_iter_iovec Mikulas Patocka <mpatocka@redhat.com> - 2016-07-22 23:20 +0200
    Re: [PATCH 2/2] mm: optimize copy_page_to/from_iter_iovec Andi Kleen <andi@firstfloor.org> - 2016-07-23 23:00 +0200
  [PATCH 1/2] mm: add cond_resched to generic_swapfile_activate Mikulas Patocka <mpatocka@redhat.com> - 2016-07-22 23:20 +0200
    Re: [PATCH 1/2] mm: add cond_resched to generic_swapfile_activate Michal Hocko <mhocko@kernel.org> - 2016-07-25 09:30 +0200

csiph-web