]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/memory-failure: do pgoff calculation before for_each_process()
authorXianting Tian <tian.xianting@h3c.com>
Tue, 13 Oct 2020 23:54:42 +0000 (16:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Oct 2020 01:38:32 +0000 (18:38 -0700)
There is no need to calculate 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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Link: http://lkml.kernel.org/r/20200818082647.34322-1-tian.xianting@h3c.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory-failure.c

index a1e73943445e77525a1fc22626552705a6f95487..24c28f80628d0704058fc90195862cc23f8a774f 100644 (file)
@@ -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)