summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-12 13:43:42 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-12 13:43:42 -0700
commitdbc2fba3fc46084f502aec53183995a632998dcd (patch)
treea4ee9c95d40c807a133a1542d082f773661869f4 /lib
parent5f739e4a491ab63730ef3b7464171340c689fbff (diff)
parent6daef95b8c914866a46247232a048447fff97279 (diff)
downloadlinux-dbc2fba3fc46084f502aec53183995a632998dcd.tar.bz2
Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull iov_iter updates from Al Viro: "A couple of iov_iter patches - Christoph's crapectomy (the last remaining user of iov_for_each() went away with lustre, IIRC) and Eric'c optimization of sanity checks" * 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: iov_iter: optimize page_copy_sane() uio: remove the unused iov_for_each macro
Diffstat (limited to 'lib')
-rw-r--r--lib/iov_iter.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index be4bd627caf0..ea36dc355da1 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -861,8 +861,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;