[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] qemu-char: eliminate busy waiting on can_rea
From: |
Peter Crosthwaite |
Subject: |
Re: [Qemu-devel] [PATCH v2] qemu-char: eliminate busy waiting on can_read returning zero |
Date: |
Sun, 7 Apr 2013 15:09:03 +1000 |
Hi Paolo,
On Sat, Apr 6, 2013 at 1:59 AM, Paolo Bonzini <address@hidden> wrote:
> The character backend refactoring introduced an undesirable busy wait.
> The busy wait happens if can_read returns zero and there is data available
> on the character device's file descriptor. Then, the I/O watch will
> fire continuously and, with TCG, the CPU thread will never run.
>
> 1) Char backend asks front end if it can write
> 2) Front end says no
> 3) poll() finds the char backend's descriptor is available
> 4) Goto (1)
>
> What we really want is this (note that step 3 avoids the busy wait):
>
> 1) Char backend asks front end if it can write
> 2) Front end says no
> 3) poll() goes on without char backend's descriptor
> 4) Goto (1) until qemu_chr_accept_input() called
>
> 5) Char backend asks front end if it can write
> 6) Front end says yes
> 7) poll() finds the char backend's descriptor is available
> 8) Backend handler called
>
> After this patch, the IOWatchPoll source and the watch source are
> separated. The IOWatchPoll is simply a hook that runs during the prepare
> phase on each main loop iteration. The hook adds/removes the actual
> source depending on the return value from can_read.
>
> A simple reproducer is
>
> qemu-system-i386 -serial mon:stdio
>
> ... followed by banging on the terminal as much as you can. :)
Mouse wheel paste does the trick nicely for me :)
> Without this patch, emulation will hang.
>
Emulation still hangs for me with this patch. It also plays foul with
Anthonys rework of my patch. The only way I can get it to work is
either mine or Anthonys patch and a revert of this one. I think your
patch adversely affects the timeout logic that Anthonys patch relies
on.
Ping me if you want my replication instructions. I will have to send
images as Microblaze doesn't like a null guest.
Regards,
Peter