From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Leonardo Bras Soares Passos <leobras@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Jagannathan Raman" <jag.raman@oracle.com>,
"John G Johnson" <john.g.johnson@oracle.com>,
"Juan Quintela" <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Fam Zheng" <fam@euphon.net>, "Peter Xu" <peterx@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
qemu-block@nongnu.org
Subject: Re: [PATCH v11 2/7] QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX
Date: Thu, 5 May 2022 16:55:27 +0100 [thread overview]
Message-ID: <YnPzb3PG0bff7AXG@redhat.com> (raw)
In-Reply-To: <CAJ6HWG7ZAPqyszS_ZGA_JH3jvQUpsZD=zQ8ismHtgq_PiSYRgw@mail.gmail.com>
On Thu, May 05, 2022 at 12:42:47PM -0300, Leonardo Bras Soares Passos wrote:
>
> Hello Daniel,
>
> But what if this gets compiled in a Linux system without MSG_ZEROCOPY support?
> As qapi will have zero-copy-send as an option we could have this scenario:
>
> - User request migration using zero-copy-send
> - multifd_save_setup() will set write_flags = QIO_CHANNEL_WRITE_FLAG_ZERO_COPY
> - In qio_channel_socket_connect_sync(): setsockopt() part will be
> compiled-out, so no error here
> - above part in qio_channel_socket_writev() will be commented-out,
> which means write_flags will be ignored
> - sflags will not contain MSG_ZEROCOPY, so sendmsg() will use copy-mode
> - migration will succeed
>
> In the above case, the user has all the reason to think migration is
> using MSG_ZEROCOPY, but in fact it's quietly falling back to
> copy-mode.
I think we're ok because qio_channel_writev_full() does
if ((flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) &&
!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY)) {
error_setg_errno(errp, EINVAL,
"Requested Zero Copy feature is not available");
return -1;
}
and since there's no way for QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY to
get set when MSG_ZEROCOPY is compiled out, we'll trigger the error
condition.
> That's why I suggested creating a 'global' config usiing SO_ZEROCOPY &
> MSG_ZEROCOPY & CONFIG_LINUX so we can use in qapi and have no chance
> of even offering zero-copy-send if we don't have it.
>
> Another local option is to do implement your suggestions, and also
> change qio_channel_socket_connect_sync() so it returns an error if
> MSG_ZEROCOPY && SO_ZEROCOPY is not present, such as:
>
> +#ifdef CONFIG_LINUX
> +#if defined(MSG_ZEROCOPY) && defined(SO_ZEROCOPY)
> + int ret, v = 1;
> + ret = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &v, sizeof(v));
> + if (ret == 0) {
> + /* Zero copy available on host */
> + qio_channel_set_feature(QIO_CHANNEL(ioc),
> + QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY);
> + }
> +#else
> + error_setg_errno(errp, errno,"MSG_ZEROCOPY not available");
> + return -1;
> +#endif
> +#endif
Do we actually need the ifdef CONFIG_LINUX bit at all ?
Sufficient to just have the check for MSG_ZEROCOPY + SO_ZEROCOPY,
which will fail on non-Linux anyway.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2022-05-05 15:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 19:18 [PATCH v11 0/7] MSG_ZEROCOPY + multifd Leonardo Bras
2022-05-04 19:18 ` [PATCH v11 1/7] QIOChannel: Add flags on io_writev and introduce io_flush callback Leonardo Bras
2022-05-04 19:18 ` [PATCH v11 2/7] QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX Leonardo Bras
2022-05-04 19:53 ` Peter Xu
2022-05-05 4:20 ` Leonardo Bras Soares Passos
2022-05-05 12:41 ` Peter Xu
2022-05-05 8:05 ` Daniel P. Berrangé
2022-05-05 15:42 ` Leonardo Bras Soares Passos
2022-05-05 15:55 ` Daniel P. Berrangé [this message]
2022-05-05 17:01 ` Leonardo Bras Soares Passos
2022-05-04 19:18 ` [PATCH v11 3/7] migration: Add zero-copy-send parameter for QMP/HMP for Linux Leonardo Bras
2022-05-05 5:55 ` Markus Armbruster
2022-05-04 19:18 ` [PATCH v11 4/7] migration: Add migrate_use_tls() helper Leonardo Bras
2022-05-04 19:18 ` [PATCH v11 5/7] multifd: multifd_send_sync_main now returns negative on error Leonardo Bras
2022-05-04 19:18 ` [PATCH v11 6/7] multifd: Send header packet without flags if zero-copy-send is enabled Leonardo Bras
2022-05-04 19:18 ` [PATCH v11 7/7] multifd: Implement zero copy write in multifd migration (multifd-zero-copy) Leonardo Bras
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=YnPzb3PG0bff7AXG@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=elena.ufimtseva@oracle.com \
--cc=fam@euphon.net \
--cc=jag.raman@oracle.com \
--cc=john.g.johnson@oracle.com \
--cc=leobras@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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).