Re: [PATCH v3 net-next 01/21] iov_iter: Introduce new procedures for copy to iter/pages
From: Christoph Hellwig <hch@lst.de>
Date: 2021-02-01 17:36:00
Also in:
netdev
On Mon, Feb 01, 2021 at 12:04:49PM +0200, Boris Pismenny wrote:
+static __always_inline __must_check
+size_t ddp_copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
+{
+ if (unlikely(!check_copy_size(addr, bytes, true)))
+ return 0;
+ else
+ return _ddp_copy_to_iter(addr, bytes, i);
+}No need for the else after a return, and the normal kernel convention double underscores for magic internal functions. But more importantly: does this belong into the generic header without and comments what the ddp means and when it should be used?
+static void ddp_memcpy_to_page(struct page *page, size_t offset, const char *from, size_t len)
Overly long line. But we're also looking into generic helpers for this kind of things, not sure if they made it to linux-next in the meantime, but please check.
+size_t _ddp_copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
+{
+ const char *from = addr;
+ if (unlikely(iov_iter_is_pipe(i)))
+ return copy_pipe_to_iter(addr, bytes, i);
+ if (iter_is_iovec(i))
+ might_fault();
+ iterate_and_advance(i, bytes, v,
+ copyout(v.iov_base, (from += v.iov_len) - v.iov_len, v.iov_len),
+ ddp_memcpy_to_page(v.bv_page, v.bv_offset,
+ (from += v.bv_len) - v.bv_len, v.bv_len),
+ memcpy(v.iov_base, (from += v.iov_len) - v.iov_len, v.iov_len)
+ )
+
+ return bytes;
+}This bloats every kernel build, so please move it into a conditionally built file. And please document the whole thing. _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme