Message ID | 20190801184244.3169074-3-songliubraving@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Enable THP for text section of non-shmem files | expand |
On Thu, Aug 01, 2019 at 11:42:39AM -0700, Song Liu wrote: > Similar to previous patch, pagecache_get_page() avoids race condition > with truncate by checking page->mapping == mapping. This does not work > for compound pages. This patch let it check compound_head(page)->mapping > instead. > > Suggested-by: Johannes Weiner <hannes@cmpxchg.org> > Signed-off-by: Song Liu <songliubraving@fb.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
diff --git a/mm/filemap.c b/mm/filemap.c index d0bd9e585c2f..aaee1ef96f6d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1644,7 +1644,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, } /* Has the page been truncated? */ - if (unlikely(page->mapping != mapping)) { + if (unlikely(compound_head(page)->mapping != mapping)) { unlock_page(page); put_page(page); goto repeat;
Similar to previous patch, pagecache_get_page() avoids race condition with truncate by checking page->mapping == mapping. This does not work for compound pages. This patch let it check compound_head(page)->mapping instead. Suggested-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Song Liu <songliubraving@fb.com> --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)