From: Matthew Wilcox (Oracle) Date: Sun, 22 Nov 2020 06:17:22 +0000 (-0800) Subject: mm: fix madvise WILLNEED performance problem X-Git-Tag: baikal/mips/sdk5.9~12179^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=957f0d9db4225bf3ad71b946e77ad6e68bb18624;p=kernel.git mm: fix madvise WILLNEED performance problem The calculation of the end page index was incorrect, leading to a regression of 70% when running stress-ng. With this fix, we instead see a performance improvement of 3%. Fixes: 299c45725573 ("mm: optimise madvise WILLNEED") Reported-by: kernel test robot Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Andrew Morton Tested-by: Xing Zhengjun Acked-by: Johannes Weiner Cc: William Kucharski Cc: Feng Tang Cc: "Chen, Rong A" Link: https://lkml.kernel.org/r/20201109134851.29692-1-willy@infradead.org Signed-off-by: Linus Torvalds --- diff --git a/mm/madvise.c b/mm/madvise.c index 7e773f949ef9f..a8d8d48a57fe9 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -226,7 +226,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma, struct address_space *mapping) { XA_STATE(xas, &mapping->i_pages, linear_page_index(vma, start)); - pgoff_t end_index = end / PAGE_SIZE; + pgoff_t end_index = linear_page_index(vma, end + PAGE_SIZE - 1); struct page *page; rcu_read_lock();