Skip to content

Commit 6638380

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
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: e6e8871 ("mm: optimise madvise WILLNEED") Reported-by: kernel test robot <rong.a.chen@intel.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Tested-by: Xing Zhengjun <zhengjun.xing@linux.intel.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: William Kucharski <william.kucharski@oracle.com> Cc: Feng Tang <feng.tang@intel.com> Cc: "Chen, Rong A" <rong.a.chen@intel.com> Link: https://lkml.kernel.org/r/20201109134851.29692-1-willy@infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 488dac0 commit 6638380

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/madvise.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma,
226226
struct address_space *mapping)
227227
{
228228
XA_STATE(xas, &mapping->i_pages, linear_page_index(vma, start));
229-
pgoff_t end_index = end / PAGE_SIZE;
229+
pgoff_t end_index = linear_page_index(vma, end + PAGE_SIZE - 1);
230230
struct page *page;
231231

232232
rcu_read_lock();

0 commit comments

Comments
 (0)