linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memory-failure: do pgoff calculation before for_each_process()
@ 2020-08-18  8:26 Xianting Tian
  2020-08-18  8:46 ` HORIGUCHI NAOYA(堀口 直也)
  0 siblings, 1 reply; 2+ messages in thread
From: Xianting Tian @ 2020-08-18  8:26 UTC (permalink / raw)
  To: naoya.horiguchi, akpm; +Cc: linux-mm, linux-kernel, Xianting Tian

There is no need to calcaulate pgoff in each loop of for_each_process(),
so move it to the place before for_each_process(), which can save some
CPU cycles.

Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
---
 mm/memory-failure.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 47b8ccb1f..7dc2c9d3b 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -484,11 +484,12 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
 	struct vm_area_struct *vma;
 	struct task_struct *tsk;
 	struct address_space *mapping = page->mapping;
+	pgoff_t pgoff;
 
 	i_mmap_lock_read(mapping);
 	read_lock(&tasklist_lock);
+	pgoff = page_to_pgoff(page);
 	for_each_process(tsk) {
-		pgoff_t pgoff = page_to_pgoff(page);
 		struct task_struct *t = task_early_kill(tsk, force_early);
 
 		if (!t)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/memory-failure: do pgoff calculation before for_each_process()
  2020-08-18  8:26 [PATCH] mm/memory-failure: do pgoff calculation before for_each_process() Xianting Tian
@ 2020-08-18  8:46 ` HORIGUCHI NAOYA(堀口 直也)
  0 siblings, 0 replies; 2+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2020-08-18  8:46 UTC (permalink / raw)
  To: Xianting Tian; +Cc: akpm, linux-mm, linux-kernel

On Tue, Aug 18, 2020 at 04:26:47PM +0800, Xianting Tian wrote:
> There is no need to calcaulate pgoff in each loop of for_each_process(),
> so move it to the place before for_each_process(), which can save some
> CPU cycles.
> 
> Signed-off-by: Xianting Tian <tian.xianting@h3c.com>

Looks good to me. Thank you.

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-18  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18  8:26 [PATCH] mm/memory-failure: do pgoff calculation before for_each_process() Xianting Tian
2020-08-18  8:46 ` HORIGUCHI NAOYA(堀口 直也)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).