diff mbox series

mm: Fix madvise WILLNEED performance problem

Message ID 20201109134851.29692-1-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series mm: Fix madvise WILLNEED performance problem | expand

Commit Message

Matthew Wilcox Nov. 9, 2020, 1:48 p.m. UTC
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%.

Reported-by: kernel test robot <rong.a.chen@intel.com>
Tested-by: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Fixes: e6e88712e43b ("mm: optimise madvise WILLNEED")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/madvise.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Weiner Nov. 9, 2020, 4:03 p.m. UTC | #1
On Mon, Nov 09, 2020 at 01:48:51PM +0000, Matthew Wilcox (Oracle) wrote:
> 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%.
> 
> Reported-by: kernel test robot <rong.a.chen@intel.com>
> Tested-by: Xing Zhengjun <zhengjun.xing@linux.intel.com>
> Fixes: e6e88712e43b ("mm: optimise madvise WILLNEED")
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>
diff mbox series

Patch

diff --git a/mm/madvise.c b/mm/madvise.c
index 9b065d412e5f..e602333f8c0d 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -225,7 +225,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();