Thread (44 messages) 44 messages, 7 authors, 2021-02-07

Re: [PATCH v3 net-next 01/21] iov_iter: Introduce new procedures for copy to iter/pages

From: Or Gerlitz <hidden>
Date: 2021-02-02 18:01:16
Also in: netdev

On Mon, Feb 1, 2021 at 7:38 PM Christoph Hellwig [off-list ref] wrote:
On Mon, Feb 01, 2021 at 12:04:49PM +0200, Boris Pismenny wrote:
quoted
+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.
ack for the no-else-after-a-return

Re the double underscoring, I was not sure, e.g the non-ddp counterpart
(_copy_to_iter) is single underscored
But more importantly: does this belong into the generic header without
and comments what the ddp means and when it should be used?
will look into this, any idea for a more suitable location?
quoted
+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.
This is what I found in linux-next - note sure if you were referring to it

commit 11432a3cc061c39475295be533c3674c4f8a6d0b
Author: David Howells [off-list ref]

    iov_iter: Add ITER_XARRAY
quoted
+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.
ack
 And please document the whole thing.
ok

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help