qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Filip Bozuta <Filip.Bozuta@syrmia.com>, qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>
Subject: Re: [PATCH 1/3] linux-user: Modify 'sendmmsg()' and 'recvmmsg()' implementation
Date: Mon, 24 Aug 2020 22:11:36 +0200	[thread overview]
Message-ID: <379457f8-3619-5438-566c-d74302188b55@vivier.eu> (raw)
In-Reply-To: <20200731190637.66698-2-Filip.Bozuta@syrmia.com>

Le 31/07/2020 à 21:06, Filip Bozuta a écrit :
> Implementations of 'sendmmsg()' and 'recvmmsg()' in 'syscall.c' use
> a loop over a host command of 'sendmsg()' and 'recvmsg()' respectively
> to send/receive individual messages from a socket. This patch changes
> these implementations to use the host commands 'sendmmsg()' and 'recvmmsg()'
> to send all messages without looping over 'sendmsg()' and 'recvmsg()'.
> 
> Implementation notes:
> 
>     Parts of code from 'do_sendrecvmsg_locked()', that are used to transfer
>     values of 'struct msghdr' between host and target, were moved to separate
>     functions 'target_to_host_msghdr()' and 'host_to_target_msghdr()'. These
>     functions are used in 'do_sendrecvmmsg()' to transfer the data of each
>     individual 'struct msghdr' from the 'msgvec' argument. Memory allocation
>     for the 'iovec' field is done outside of these functions as to ensure that
>     the memory is freed after the syscall execution.
> 
> Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
> ---
>  linux-user/syscall.c | 243 ++++++++++++++++++++++++++++---------------
>  1 file changed, 159 insertions(+), 84 deletions(-)
> 

I'm sorry but after studying the changes needed I think it's better to
keep the existing code.

For instance, if we have a EFAULT (or EMSGSIZE) while reading the iovec
we must stop to send  data and exit with the error code.

Your code correctly manages the detection of the error and stops the
conversion of the iovec. Then it uses the converted iovecs with
sendmmsg() and recvmmsg(), but "ret" is overwritten and the error is lost.

So, in the end, and as it is done in kernel, the best is to loop around
sendmsg()... and this is what the existing code does.

Thanks,
Laurent


  reply	other threads:[~2020-08-24 20:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 19:06 [PATCH 0/3] linux-user: Introducing support for 'recvmmsg_time64()' Filip Bozuta
2020-07-31 19:06 ` [PATCH 1/3] linux-user: Modify 'sendmmsg()' and 'recvmmsg()' implementation Filip Bozuta
2020-08-24 20:11   ` Laurent Vivier [this message]
2020-07-31 19:06 ` [PATCH 2/3] linux-user: Fix " Filip Bozuta
2020-07-31 19:06 ` [PATCH 3/3] linux-user: Add support for 'recvmmsg_time64()' Filip Bozuta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=379457f8-3619-5438-566c-d74302188b55@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=Filip.Bozuta@syrmia.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).