All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: chuang xu <xuchuangxclwt@bytedance.com>
Cc: "Leonardo Bras" <leobras@redhat.com>,
	qemu-devel@nongnu.org, "Peter Xu" <peterx@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
	"Jagannathan Raman" <jag.raman@oracle.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"John G Johnson" <john.g.johnson@oracle.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	lizefan.x@bytedance.com, zhouyibo@bytedance.com
Subject: Re: [External] [PATCH v13 3/8] QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX
Date: Tue, 14 Jun 2022 15:14:26 +0100	[thread overview]
Message-ID: <YqiXwhG+TxG7IPY3@work-vm> (raw)
In-Reply-To: <c951a606-e306-6f11-0bd9-204a8b0d223a@bytedance.com>

* chuang xu (xuchuangxclwt@bytedance.com) wrote:
> 
> On 2022/5/13 下午2:28, Leonardo Bras wrote:
> > @@ -557,15 +578,31 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
> >           memcpy(CMSG_DATA(cmsg), fds, fdsize);
> >       }
> > +#ifdef QEMU_MSG_ZEROCOPY
> > +    if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
> > +        sflags = MSG_ZEROCOPY;
> > +    }
> > +#endif
> > +
> >    retry:
> > -    ret = sendmsg(sioc->fd, &msg, 0);
> > +    ret = sendmsg(sioc->fd, &msg, sflags);
> >       if (ret <= 0) {
> > -        if (errno == EAGAIN) {
> > +        switch (errno) {
> > +        case EAGAIN:
> >               return QIO_CHANNEL_ERR_BLOCK;
> > -        }
> > -        if (errno == EINTR) {
> > +        case EINTR:
> >               goto retry;
> > +#ifdef QEMU_MSG_ZEROCOPY
> > +        case ENOBUFS:
> > +            if (sflags & MSG_ZEROCOPY) {
> > +                error_setg_errno(errp, errno,
> > +                                 "Process can't lock enough memory for using MSG_ZEROCOPY");
> > +                return -1;
> > +            }
> > +            break;
> > +#endif
> >           }
> > +
> >           error_setg_errno(errp, errno,
> >                            "Unable to write to socket");
> >           return -1;
> 
> Hi, Leo.
> 
> There are some other questions I would like to discuss with you.
> 
> I tested the multifd zero_copy migration and found that sometimes even if
> max locked memory of qemu was set to 16GB(much greater than
> `MULTIFD_PACKET_SIZE`), the error "Process can't lock enough memory for
> using MSG_ZEROCOPY" would still be reported.
> 
> I noticed that the
> doc(https://www.kernel.org/doc/html/v5.12/networking/msg_zerocopy.html) says
> "A zerocopy failure will return -1 with errno ENOBUFS. This happens if the
> socket option was not set, _the socket exceeds its optmem limit_ or the user
> exceeds its ulimit on locked pages."
> 
> I also found that the RFC(https://lwn.net/Articles/715279/) says _"__The
> change to allocate notification skbuffs from optmem requires__ensuring that
> net.core.optmem is at least a few 100KB."_

Interesting.

> On my host,  optmem was initially set to 20KB, I tried to change it to 100KB
> (echo 102400 > /proc/sys/net/core/optmem_max) as the RFC says.Then I tested
> the multifd zero_copy migration repeatedly,and the error disappeared.
> 
> So when sendmsg returns -1 with errno ENOBUFS, should we distinguish between
> error ''socket exceeds optmem limit" and error "user exceeds ulimit on
> locked pages"? Or is there any better way to avoid this problem?

I don't think we can tell which one of them triggered the error; so the
only thing I can suggest is that we document the need for optmem_max
setting; I wonder how we get a better answer than 'a few 100KB'?
I guess it's something like the number of packets inflight *
sizeof(cmsghdr) ?

Dave

> Best Regards,
> 
> chuang xu
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2022-06-14 14:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13  6:28 [PATCH v13 0/8] MSG_ZEROCOPY + multifd Leonardo Bras
2022-05-13  6:28 ` [PATCH v13 1/8] meson.build: Fix docker-test-build@alpine when including linux/errqueue.h Leonardo Bras
2022-05-16 11:13   ` Dr. David Alan Gilbert
2022-05-16 11:17     ` Daniel P. Berrangé
2022-05-16 11:30       ` Dr. David Alan Gilbert
2022-05-16 11:35         ` Daniel P. Berrangé
2022-05-16 12:51           ` Dr. David Alan Gilbert
2022-05-16 14:04             ` Daniel P. Berrangé
2022-05-13  6:28 ` [PATCH v13 2/8] QIOChannel: Add flags on io_writev and introduce io_flush callback Leonardo Bras
2022-05-13  6:28 ` [PATCH v13 3/8] QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX Leonardo Bras
2022-06-01  9:37   ` [External] " 徐闯
2022-06-01 13:58     ` Peter Xu
2022-06-08  5:37       ` Leonardo Bras Soares Passos
2022-06-08 11:41         ` Peter Xu
2022-06-08 18:14           ` Leonardo Bras Soares Passos
2022-06-08 20:23             ` Peter Xu
2022-06-13 20:58               ` Leonardo Bras Soares Passos
2022-06-13 22:53                 ` Peter Xu
2022-06-14  3:14                   ` Leonardo Bras Soares Passos
2022-06-08  5:24     ` Leonardo Bras Soares Passos
2022-06-08  6:48       ` chuang xu
2022-06-14 13:09   ` chuang xu
2022-06-14 14:14     ` Dr. David Alan Gilbert [this message]
2022-06-15 14:44       ` chuang xu
2022-05-13  6:28 ` [PATCH v13 4/8] migration: Add zero-copy-send parameter for QMP/HMP for Linux Leonardo Bras
2022-05-13  6:28 ` [PATCH v13 5/8] migration: Add migrate_use_tls() helper Leonardo Bras
2022-05-13  6:28 ` [PATCH v13 6/8] multifd: multifd_send_sync_main now returns negative on error Leonardo Bras
2022-05-13  6:28 ` [PATCH v13 7/8] multifd: Send header packet without flags if zero-copy-send is enabled Leonardo Bras
2022-05-13  6:28 ` [PATCH v13 8/8] 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=YqiXwhG+TxG7IPY3@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@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=lizefan.x@bytedance.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=xuchuangxclwt@bytedance.com \
    --cc=zhouyibo@bytedance.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.