On 05/02/2021 14:45, Jens Axboe wrote: > On 2/5/21 3:06 AM, Pavel Begunkov wrote: >> On 05/02/2021 09:58, Stefan Metzmacher wrote: >>> Hi Pavel, >>> >>>>>> static int io_sendmsg_copy_hdr(struct io_kiocb *req, >>>>>> struct io_async_msghdr *iomsg) >>>>>> { >>>>>> - iomsg->iov = iomsg->fast_iov; >>>>>> iomsg->msg.msg_name = &iomsg->addr; >>>>>> + iomsg->free_iov = iomsg->fast_iov; >>>>> >>>>> Why this? Isn't the idea of this patch that free_iov is never == fast_iov? >>>> >>>> That's a part of __import_iovec() and sendmsg_copy_msghdr() API, you pass >>>> fast_iov as such and get back NULL or a newly allocated one in it. >>> I think that should at least get a comment to make this clear and >>> maybe a temporary variable like this: >>> >>> tmp_iov = iomsg->fast_iov; >>> __import_iovec(..., &tmp_iov, ...); >>> iomsg->free_iov = tmp_iov; >> >> I'd rather disagree. It's a well known (ish) API, and I deliberately >> placed such assignments right before import_iovec/etc. > > Agree on that, it's kind of a weird idiom, but it's used throughout the > kernel. However: Maybe someday someone will refactor it and make it accepting inline_vecs directly... > >>>>> kfree() handles NULL, or is this a hot path and we want to avoid a function call? >>>> >>>> Yes, the hot path here is not having iov allocated, and Jens told before >>>> that he had observed overhead for a similar place in io_[read,write]. >>> >>> Ok, a comment would also help here... > > I do agree on that one, since otherwise we get patches for it as has > been proven by the few other spots... I'll add then when queueing this > up. I didn't disagree with that, just forgot to throw one to protect ourselves from static analysis tools. Thanks for fixing up -- Pavel Begunkov