linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Remove redundant test from find_get_pages_contig
@ 2019-01-07 20:02 Matthew Wilcox
  2019-01-07 22:33 ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2019-01-07 20:02 UTC (permalink / raw)
  To: Andrew Morton, Hugh Dickins, linux-mm, linux-kernel; +Cc: Matthew Wilcox

After we establish a reference on the page, we check the pointer continues
to be in the correct position in i_pages.  There's no need to check the
page->mapping or page->index afterwards; if those can change after we've
got the reference, they can change after we return the page to the caller.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
---
 mm/filemap.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 9f5e323e883e6..935fbc29aeb13 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1837,16 +1837,6 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
 		if (unlikely(page != xas_reload(&xas)))
 			goto put_page;
 
-		/*
-		 * must check mapping and index after taking the ref.
-		 * otherwise we can get both false positives and false
-		 * negatives, which is just confusing to the caller.
-		 */
-		if (!page->mapping || page_to_pgoff(page) != xas.xa_index) {
-			put_page(page);
-			break;
-		}
-
 		pages[ret] = page;
 		if (++ret == nr_pages)
 			break;
-- 
2.20.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-01-08 21:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 20:02 [PATCH] mm: Remove redundant test from find_get_pages_contig Matthew Wilcox
2019-01-07 22:33 ` Andrew Morton
2019-01-07 22:39   ` Matthew Wilcox
2019-01-07 23:09     ` Andrew Morton
2019-01-08 20:26       ` Matthew Wilcox
2019-01-08 21:26         ` Andrew Morton
2019-01-08 21:36           ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox