]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - lib/iov_iter.c
Partially revert "kfifo: fix kfifo_alloc() and kfifo_init()"
[mirror_ubuntu-bionic-kernel.git] / lib / iov_iter.c
index 970212670b6a11bf8e033bd7d0cc0fff34041dc8..c6b859431832c74fe2dd8ce03518f5282baba09e 100644 (file)
@@ -687,8 +687,21 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
 
 static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
 {
-       struct page *head = compound_head(page);
-       size_t v = n + offset + page_address(page) - page_address(head);
+       struct page *head;
+       size_t v = n + offset;
+
+       /*
+        * The general case needs to access the page order in order
+        * to compute the page size.
+        * However, we mostly deal with order-0 pages and thus can
+        * avoid a possible cache line miss for requests that fit all
+        * page orders.
+        */
+       if (n <= v && v <= PAGE_SIZE)
+               return true;
+
+       head = compound_head(page);
+       v += (page - head) << PAGE_SHIFT;
 
        if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head))))
                return true;