On Mon, Feb 1, 2021 at 7:38 PM Christoph Hellwig <h...@lst.de> wrote: > 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.
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? > > +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 <dhowe...@redhat.com> iov_iter: Add ITER_XARRAY > > +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