linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Xianting Tian <tian.xianting@h3c.com>
To: <naoya.horiguchi@nec.com>, <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	Xianting Tian <tian.xianting@h3c.com>
Subject: [PATCH] mm/memory-failure: do pgoff calculation before for_each_process()
Date: Tue, 18 Aug 2020 16:26:47 +0800	[thread overview]
Message-ID: <20200818082647.34322-1-tian.xianting@h3c.com> (raw)

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



             reply	other threads:[~2020-08-18  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  8:26 Xianting Tian [this message]
2020-08-18  8:46 ` HORIGUCHI NAOYA(堀口 直也)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200818082647.34322-1-tian.xianting@h3c.com \
    --to=tian.xianting@h3c.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox