Hans de Goede 0262f65aaa ehci: Improve latency of interrupt delivery and async schedule scanning
While doing various performance tests of reading from USB mass storage devices
I noticed the following::
1) When an async handled packet completes, we don't immediately report an
   interrupt to the guest, instead we wait for the frame-timer to run and
   report it from there
2) If 1) has been fixed and an async handled packet takes a while to complete,
   then async_stepdown will become a high value, which means that there
   will be a large latency before any new packets queued by the guest in
   response to the interrupt get seen

1) was done deliberately as part of commit f0ad01f92:
http://www.kraxel.org/cgit/qemu/commit/?h=usb.57&id=f0ad01f92ca02eee7cadbfd225c5de753ebd5fce
Since setting the interrupt immediately on async packet completion was causing
issues with Linux guests, I believe this recently fixed Linux bug explains
why this is happening:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=361aabf395e4a23cf554cf4ec0c0c6963b8beb01

Note that we can *not* count on this fix being present in all Linux guests!

I was hoping that the recently added support for Interrupt Threshold Control
would fix the issues with Linux guests, but adding a simple ehci_commit_irq()
call to ehci_async_bh() still caused problems with Linux guests.

The problem is, that when doing ehci_commit_irq() from ehci_async_bh(),
the "old" frindex value is used to calculate usbsts_frindex, and when
the frame-timer then runs possibly very shortly after ehci_async_bh(),
it increases the frame-timer, and thus any interrupts raised from that
frame-timer run, will also get reported to the guest immediately, rather
then being delayed to the next frame-timer run.

Luckily the solution for this is simple, this means that we need to
increase frindex before calling ehci_commit_irq() from ehci_async_bh(),
which in the end boils down to simple calling ehci_frame_timer() instead
of ehci_async_bh() from the bh.

This may seem like it causes a lot of extra work to be done, but this
is not true. Any work done from the frame-timer processing the periodic
schedule is work which then does not need to be done the next time the
frame timer runs, also the frame-timer will re-arm itself at (possibly)
a later time then it was armed for saving a vmexit at that time.

As an additional advantage moving to simply calling the frame-timer also
fixes 2) as the packet completion will set async_stepdown to 0, and the
re-arming of the timer with an async_stepdown of 0 ensures that any
newly queued up packets get seen in a reasonable amount of time.

This improves the speed (MB/s) of a Linux guest reading from a USB mass
storage device by a factor of 1.5 - 1.7 with input pipelining disabled,
and by a factor of 1.8 with input pipelining enabled.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25 09:08:09 +02:00
..
2012-06-21 16:06:11 +00:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-07-04 15:52:55 +03:00
2012-02-07 22:11:04 +04:00
2012-10-10 11:13:31 +10:00
2012-10-22 13:26:42 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-06-21 16:06:11 +00:00
2012-10-23 08:58:25 -05:00
2012-01-13 10:55:56 -06:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-10-05 15:10:21 +02:00
2012-10-23 08:58:25 -05:00
2011-12-06 09:56:41 +00:00
2012-07-28 09:23:11 +00:00
2012-03-14 22:20:26 +01:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-08-22 10:47:17 -05:00
2011-10-17 15:59:18 +02:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-01-13 10:55:56 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-10 11:13:32 +10:00
2012-10-10 11:13:32 +10:00
2012-10-23 08:58:25 -05:00
2012-02-10 10:44:52 +00:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-08-22 10:47:17 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2011-12-06 09:56:41 +00:00
2011-12-14 11:09:12 +00:00
2012-04-26 12:54:17 +04:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-20 07:56:22 +00:00
2012-06-18 15:14:38 +02:00
2012-03-07 12:27:41 +02:00
2012-03-07 12:27:41 +02:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2011-10-16 11:10:48 +00:00
2012-09-23 07:11:28 +01:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-22 13:26:42 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-10-22 13:26:42 -05:00
2012-10-10 11:13:31 +10:00
2012-02-15 09:39:21 -06:00
2012-10-05 08:02:30 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-08-03 10:04:37 +02:00
2012-03-14 22:20:26 +01:00
2012-10-22 13:26:42 -05:00
2012-03-14 22:20:26 +01:00
2012-10-22 13:26:42 -05:00
2012-10-23 08:58:25 -05:00
2012-03-14 22:20:26 +01:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-08-01 13:32:10 +01:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-07-27 21:13:01 +00:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-07-29 17:05:35 +03:00
2012-10-23 08:58:25 -05:00
2012-10-22 13:26:42 -05:00
2012-07-29 17:05:35 +03:00
2012-08-09 18:21:47 +00:00
2012-10-23 08:58:25 -05:00
2012-10-22 14:50:08 +02:00
2012-01-27 10:50:50 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-17 09:58:22 -06:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2011-12-14 11:08:23 +00:00
2011-12-14 11:08:23 +00:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-03-14 22:20:26 +01:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-03-14 22:20:26 +01:00
2012-03-14 22:20:26 +01:00
2012-10-23 08:58:25 -05:00
2012-04-07 14:00:45 +00:00
2012-04-12 11:14:29 +01:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-08 12:15:17 +02:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-05 15:10:21 +02:00
2012-10-23 08:58:25 -05:00
2012-10-05 15:10:21 +02:00
2012-08-13 11:04:07 +01:00
2012-10-22 13:26:42 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2011-12-06 09:56:41 +00:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-03-16 00:41:15 +02:00
2012-03-16 00:41:28 +02:00
2012-03-16 00:41:28 +02:00
2012-10-23 08:58:25 -05:00
2012-01-13 10:55:56 -06:00
2012-02-15 09:39:21 -06:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-05 07:58:37 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-10-10 11:13:32 +10:00
2012-10-10 11:13:32 +10:00
2012-10-10 11:13:32 +10:00
2012-10-10 11:13:32 +10:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-09-11 07:43:01 +02:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-04 12:45:10 +00:00
2012-10-20 07:52:54 +00:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-04 12:45:10 +00:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-03-16 00:45:23 +02:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-02-15 09:39:21 -06:00
2012-03-14 22:20:26 +01:00
2012-02-15 09:39:21 -06:00
2012-10-23 08:58:25 -05:00
2012-10-23 08:58:25 -05:00
2012-10-03 13:48:45 +00:00
2012-10-23 08:58:25 -05:00
2012-10-04 15:54:18 +02:00
2012-10-23 08:58:25 -05:00
2012-03-14 22:20:26 +01:00
2012-10-23 08:58:25 -05:00