aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <[email protected]>2020-11-21 22:17:22 -0800
committerLinus Torvalds <[email protected]>2020-11-22 10:48:22 -0800
commit66383800df9cbdbf3b0c34d5a51bf35bcdb72fd2 (patch)
tree8172ec6d41fcdbd0af75ce75135f793b52ce5125
parent488dac0c9237647e9b8f788b6a342595bfa40bda (diff)
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: e6e88712e43b ("mm: optimise madvise WILLNEED") Reported-by: kernel test robot <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Xing Zhengjun <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: William Kucharski <[email protected]> Cc: Feng Tang <[email protected]> Cc: "Chen, Rong A" <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--mm/madvise.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/madvise.c b/mm/madvise.c
index 7e773f949ef9..a8d8d48a57fe 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();