mm/page_alloc: make pcpu_drain_mutex and pcpu_drain static
[linux-2.6-microblaze.git] / mm / filemap.c
index 0fbdc8e..23a051a 100644 (file)
@@ -1693,6 +1693,11 @@ EXPORT_SYMBOL(pagecache_get_page);
  * Any shadow entries of evicted pages, or swap entries from
  * shmem/tmpfs, are included in the returned array.
  *
+ * If it finds a Transparent Huge Page, head or tail, find_get_entries()
+ * stops at that page: the caller is likely to have a better way to handle
+ * the compound page as a whole, and then skip its extent, than repeatedly
+ * calling find_get_entries() to return all its tails.
+ *
  * Return: the number of pages and shadow entries which were found.
  */
 unsigned find_get_entries(struct address_space *mapping,
@@ -1724,8 +1729,15 @@ unsigned find_get_entries(struct address_space *mapping,
                /* Has the page moved or been split? */
                if (unlikely(page != xas_reload(&xas)))
                        goto put_page;
-               page = find_subpage(page, xas.xa_index);
 
+               /*
+                * Terminate early on finding a THP, to allow the caller to
+                * handle it all at once; but continue if this is hugetlbfs.
+                */
+               if (PageTransHuge(page) && !PageHuge(page)) {
+                       page = find_subpage(page, xas.xa_index);
+                       nr_entries = ret + 1;
+               }
 export:
                indices[ret] = xas.xa_index;
                entries[ret] = page;