Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/shmem: make find_get_pages_range() work for huge page

find_get_pages_range() and find_get_pages_range_tag() already correctly
increment reference count on head when seeing compound page, but they
may still use page index from tail. Page index from tail is always
zero, so these functions don't work on huge shmem. This hasn't been a
problem because, AFAIK, nobody calls these functions on (huge) shmem.
Fix them anyway just in case.

Link: http://lkml.kernel.org/r/20190110030838.84446-1-yuzhao@google.com
Signed-off-by: Yu Zhao <yuzhao@google.com>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: "Darrick J . Wong" <darrick.wong@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Yu Zhao and committed by
Linus Torvalds
5d3ee42f afa00112

+2 -2
+2 -2
mm/filemap.c
··· 1789 1789 1790 1790 pages[ret] = page; 1791 1791 if (++ret == nr_pages) { 1792 - *start = page->index + 1; 1792 + *start = xas.xa_index + 1; 1793 1793 goto out; 1794 1794 } 1795 1795 continue; ··· 1927 1927 1928 1928 pages[ret] = page; 1929 1929 if (++ret == nr_pages) { 1930 - *index = page->index + 1; 1930 + *index = xas.xa_index + 1; 1931 1931 goto out; 1932 1932 } 1933 1933 continue;