Skip to contentSkip to conversation

mm: Fix madvise WILLNEED performance problem

PATCH Applied Matthew Wilcox (Oracle) 2 participants 2 messages Nov 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 mm/madvise.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -1
index 9b065d412e5f..e602333f8c0d 100644
@@ -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();
Signature · 1 line
2.28.0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Matthew Wilcox (Oracle)

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")