public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Asias He <asias.hejun@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Mark McLoughlin <markmc@redhat.com>,
	Pekka Enberg <penberg@kernel.org>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	Sasha Levin <levinsasha928@gmail.com>,
	Prasad Joshi <prasadjoshi124@gmail.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] kvm tools: Respect ISR status in virtio header
Date: Sat, 7 May 2011 16:47:35 +0200	[thread overview]
Message-ID: <20110507144735.GD2859@elte.hu> (raw)
In-Reply-To: <4DC55562.4070304@codemonkey.ws>


* Anthony Liguori <anthony@codemonkey.ws> wrote:

> On 05/07/2011 09:02 AM, Ingo Molnar wrote:
> >Well the optimization also avoids unnecessary VM exits (due to the injection,
> >which interrupts a guest context immediately, even if it's running on another
> >CPU), not just system calls - so it could be more expensive than a system call,
> >right?
> 
> If there's IRQ is already pending, the syscall should be a nop.  If
> the IRQ is extraneous, then there's a pretty short window when the
> IRQ wouldn't already be pending.
> 
> I took a look at the current virtio code and noticed a few things
> that are sub-optimal:
> 
> 1) No MSI.  MSI makes interrupts edge triggered and avoids the ISR
> read entirely.  The ISR read is actually pretty expensive.
> 
> 2) The access pattern is basically:
> 
> while pending_requests:
>    a = get_next_request();
>    process_next_request(a);
> 
> But this is not the optimal pattern with virtio.  The optimal pattern is:
> 
> if pending_requests:
>   disable_notifications();
> 
> again:
>   while pending_requests:
>     a = get_next_request();
>     process_next_request();
> 
>   enable_notifications();
>   if pending_requests:
>      goto again;
> 
> You're currently taking exits way more than you should, particularly
> since you're using threads for processing the ring queues.
> 
> 3) You aren't advertising VIRTIO_F_NOTIFY_ON_EMPTY.  Particularly
> with TX, it's advantageous to inject an IRQ even if they're disabled
> when there are no longer packets in the ring.
> 
> (2) and (1) are definitely the most important for performance.  (2)
> should be a pretty simple change and should have a significant
> impact.

Can you anything in the virtio protocol implementation that would explain 
networking lags, which seem to be caused by guest notifications either not be 
sent or being missed?

In particular this sequence:

> while pending_requests:
>    a = get_next_request();
>    process_next_request(a);

is apparently not what Qemu uses - so maybe there's some latent bug or some 
silly oversight somewhere.

It is suboptimal and i agree with you that the better sequence should be 
implemented, but the above *should* work, yet it does not.

Thanks,

	Ingo

  reply	other threads:[~2011-05-07 14:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-07  2:34 [PATCH 1/2] kvm tools: Respect ISR status in virtio header Asias He
2011-05-07  2:34 ` [PATCH 2/2] kvm tools: Respect VRING_AVAIL_F_NO_INTERRUPT Asias He
2011-05-07  7:55   ` Ingo Molnar
2011-05-07  9:03     ` Pekka Enberg
2011-05-07 11:25       ` Asias He
2011-05-07  9:30 ` [PATCH 1/2] kvm tools: Respect ISR status in virtio header Ingo Molnar
2011-05-07 10:34   ` Sasha Levin
2011-05-07 10:39     ` Pekka Enberg
2011-05-07 10:39     ` Asias He
2011-05-07 11:15   ` Asias He
2011-05-07 14:00     ` Ingo Molnar
2011-05-07 14:24       ` Asias He
2011-05-07 13:14   ` Anthony Liguori
2011-05-07 14:02     ` Ingo Molnar
2011-05-07 14:21       ` Anthony Liguori
2011-05-07 14:47         ` Ingo Molnar [this message]
2011-05-07 14:52           ` Pekka Enberg
2011-05-07 14:55             ` Ingo Molnar
2011-05-07 14:50     ` Pekka Enberg
2011-05-07 15:01       ` Anthony Liguori
2011-05-07 15:02         ` Pekka Enberg
2011-05-07 15:06           ` Ingo Molnar

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=20110507144735.GD2859@elte.hu \
    --to=mingo@elte.hu \
    --cc=anthony@codemonkey.ws \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=markmc@redhat.com \
    --cc=mst@redhat.com \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    --cc=rusty@rustcorp.com.au \
    /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