summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Glisse <jglisse@redhat.com>2019-04-11 14:20:30 -0400
committerJérôme Glisse <jglisse@redhat.com>2019-05-22 17:19:11 -0400
commit9950c15548a7adb07ae2a34e2c8ebdfa87887bc5 (patch)
tree0da17c65627e3a23c66d644b92ce9d38d23a9dbc
parenta986bccd540078fc8030fb2a9f1ba15825ed7f64 (diff)
iov_iter: add helper to test if an iter would use GUP v2
Add an helper to test if call to iov_iter_get_pages*() with a given iter would result in calls to GUP (get_user_pages*()). We want to track differently page reference if they are coming from GUP and thus we need to know when GUP is use for a given iter. Changes since v1: - only iovec use GUP, pipe have special case before iterate_all_kind() Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Cc: linux-fsdevel@vger.kernel.org Cc: linux-block@vger.kernel.org Cc: linux-mm@kvack.org Cc: John Hubbard <jhubbard@nvidia.com> Cc: Jan Kara <jack@suse.cz> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: Christoph Hellwig <hch@lst.de> Cc: Jens Axboe <axboe@kernel.dk> Cc: Ming Lei <ming.lei@redhat.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Matthew Wilcox <willy@infradead.org>
-rw-r--r--include/linux/uio.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 2d0131ad4604..11cff46381a2 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -98,6 +98,17 @@ static inline bool iov_iter_bvec_no_ref(const struct iov_iter *i)
return (i->type & ITER_BVEC_FLAG_NO_REF) != 0;
}
+/**
+ * iov_iter_get_pages_use_gup - true if iov_iter_get_pages(i) use GUP
+ * @i: iter
+ * Returns: true if a call to iov_iter_get_pages*() with the iter provided in
+ * argument would result in the use of get_user_pages*()
+ */
+static inline bool iov_iter_get_pages_use_gup(const struct iov_iter *i)
+{
+ return iov_iter_type(i) & (ITER_IOVEC | ITER_PIPE);
+}
+
/*
* Total number of bytes covered by an iovec.
*