From: Marcelo Tosatti <mtosatti@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Liu Ping Fan <pingfank@linux.vnet.ibm.com>,
kvm <kvm@vger.kernel.org>, qemu-devel <qemu-devel@nongnu.org>,
Alexander Graf <agraf@suse.de>, Jan Kiszka <jan.kiszka@web.de>,
Avi Kivity <avi@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [PATCH] kvm: First step to push iothread lock out of inner run loop
Date: Wed, 27 Jun 2012 08:09:31 -0300 [thread overview]
Message-ID: <20120627110930.GA3590@amt.cnet> (raw)
In-Reply-To: <CAJSP0QW=ZzJzjKes+e+9qSSEWWXAsDH+w00DgNY18yoQDPDHMg@mail.gmail.com>
On Wed, Jun 27, 2012 at 08:41:49AM +0100, Stefan Hajnoczi wrote:
> On Wed, Jun 27, 2012 at 8:39 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > On Tue, Jun 26, 2012 at 8:34 PM, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> >> On Sat, Jun 23, 2012 at 12:55:49AM +0200, Jan Kiszka wrote:
> >> net.txt
> >> --------
> >>
> >>
> >> iothread flow
> >> =============
> >>
> >> 1) Skip-work-if-device-locked
> >>
> >> select(tap fd ready)
> >> tap_send
> >> if (trylock(TAPState->NetClientState->dev))
> >> proceed;
> >> else
> >> continue; (data remains in queue)
> >> tap_read_packet
> >> qemu_send_packet_async
> >>
> >> DRAWBACK: lock intensive.
> >> DRAWBACK: VCPU threads can starve IOTHREAD (can be fixed with
> >> a scheme such as trylock() marks a flag saying "iothread wants lock".
> >
> > One alternative is to say the lock cannot be held across system calls
> > or other long-running operations (similar to interrupt handler
> > spinlocks in the kernel). But QEMU threads are still at the mercy of
> > the scheduler or page faults, so perhaps this is not a good idea
> > because waiting on the lock could tie up the iothread.
> >
> >> 2) Queue-work-to-vcpu-context
> >>
> >> select(tap fd ready)
> >> tap_send
> >> if (trylock(TAPState->NetClientState->dev)) {
> >> proceed;
> >> } else {
> >> AddToDeviceWorkQueue(work);
> >> }
> >> tap_read_packet
> >> qemu_send_packet_async
> >>
> >> DRAWBACK: lock intensive
> >> DRAWBACK: cache effects
> >
> > This almost suggests we should invert packet reception for NICs. tap
> > fd ready should add a work item and the guest device calls into
> > net/tap.c to pull out any packets from the work function:
> >
> > tap_send
> > dev_add_work(work);
> >
> > virtio_net_rx_work_fn
> > while ((req = virtqueue_pop(rx_queue))) {
> > if (!net_receive_packet(netclient, req->buf)) {
> > break; /* no more packets available */
> > }
> > /* ...mark req complete and push onto virtqueue... */
> > }
> > virtqueue_notify(rx_queue);
> >
> > The idea is to avoid copies on the rx path and make the locking simple
> > by always deferring to a work function (which can be invoked
> > immediately if the device isn't locked).
>
> I just realized this approach bypasses net/queue.c. I think it works
> really well for the peer model (no "VLANs"). Basically flow control
> is dictated by the peer (receiver) and we don't need to use NetQueue
> anymore. Whether this works elegantly for slirp and other backends,
> I'm not sure yet.
Right. The advantage is only backends where performance matters
need to be converted (and only net hw drivers that matter performance
wise need to be converted).
next prev parent reply other threads:[~2012-06-27 11:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4FE4F56D.1020201@web.de>
2012-06-22 22:55 ` [PATCH] kvm: First step to push iothread lock out of inner run loop Jan Kiszka
2012-06-23 0:22 ` Marcelo Tosatti
2012-06-23 9:06 ` Marcelo Tosatti
2012-06-23 11:45 ` Jan Kiszka
2012-06-24 8:49 ` Avi Kivity
2012-06-24 14:08 ` [Qemu-devel] " Jan Kiszka
2012-06-24 14:31 ` Avi Kivity
2012-07-06 17:16 ` Jan Kiszka
2012-07-06 18:06 ` Jan Kiszka
2012-07-08 7:49 ` Avi Kivity
2012-06-24 13:34 ` liu ping fan
2012-06-24 14:08 ` Jan Kiszka
2012-06-24 14:35 ` Avi Kivity
2012-06-24 14:40 ` Jan Kiszka
2012-06-24 14:46 ` Avi Kivity
2012-06-24 14:51 ` Jan Kiszka
2012-06-24 14:56 ` Avi Kivity
2012-06-24 14:58 ` Jan Kiszka
2012-06-24 14:59 ` Avi Kivity
2012-06-23 9:22 ` Jan Kiszka
2012-06-28 1:11 ` Marcelo Tosatti
2012-06-26 19:34 ` Marcelo Tosatti
2012-06-27 7:39 ` Stefan Hajnoczi
2012-06-27 7:41 ` [Qemu-devel] " Stefan Hajnoczi
2012-06-27 11:09 ` Marcelo Tosatti [this message]
2012-06-27 11:19 ` Marcelo Tosatti
2012-06-28 8:45 ` Stefan Hajnoczi
2012-06-27 7:54 ` Avi Kivity
2012-06-27 14:36 ` Jan Kiszka
2012-06-28 14:10 ` [Qemu-devel] " Anthony Liguori
2012-06-28 15:12 ` Avi Kivity
2012-06-29 1:29 ` Marcelo Tosatti
2012-06-29 1:45 ` [Qemu-devel] " Marcelo Tosatti
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=20120627110930.GA3590@amt.cnet \
--to=mtosatti@redhat.com \
--cc=agraf@suse.de \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=pingfank@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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).