@@ -526,9 +526,15 @@ size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
return copy_pipe_to_iter(addr, bytes, i);
if (user_backed_iter(i))
might_fault();
+ /*
+ * When using direct data placement (DDP) the hardware writes
+ * data directly to the destination buffer, and constructs
+ * IOVs such that they point to this data.
+ * Thus, when the src == dst we skip the memcpy.
+ */
iterate_and_advance(i, bytes, base, len, off,
copyout(base, addr + off, len),
- memcpy(base, addr + off, len)
+ (base != addr + off) && memcpy(base, addr + off, len)
)
return bytes;