From: Hans de Goede <hdegoede@redhat.com>
To: Alex Bligh <alex@alex.org.uk>, Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] main-loop: Don't lock starve io-threads when main_loop_tlg has pending events
Date: Wed, 09 Oct 2013 20:49:56 +0200 [thread overview]
Message-ID: <5255A554.1070105@redhat.com> (raw)
In-Reply-To: <AD93410C-CA5D-48E6-A615-616A34F44CE8@alex.org.uk>
Hi,
On 10/09/2013 08:36 PM, Alex Bligh wrote:
>
> On 9 Oct 2013, at 19:28, Alex Bligh wrote:
>
>>>
>>> static void audio_reset_timer (AudioState *s)
>>> {
>>> if (audio_is_timer_needed ()) {
>>> timer_mod (s->ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1);
>>> }
>>> else {
>>> timer_del (s->ts);
>>> }
>>> }
>>>
>>> static void audio_timer (void *opaque)
>>> {
>>> audio_run ("timer");
>>> audio_reset_timer (opaque);
>>> }
>>>
>>> Note how that is using a timer which expires every freaking nano second,
>>> I think it is very likely that is the culprit.
>>
>> Indeed. I am hoping that it is not my automated perl conversion code that
>> did that, because if it is, it may have broken other stuff :-/
>>
>> Thanks for finding this - let me see whether the bug existed before
>> my automated changes commit.
>
> I think this was broken prior to my changes. Here's audio/audio.c before
> my changes:
>
> static void audio_reset_timer (AudioState *s)
> {
> if (audio_is_timer_needed ()) {
> qemu_mod_timer (s->ts, qemu_get_clock_ns (vm_clock) + 1);
> }
> else {
> qemu_del_timer (s->ts);
> }
> }
>
>
> Now qemu_get_clock_ns can only return something in nanoseconds, so it's
> adding 1 nanosecond. This is thus either broken because:
> 1. ts->scale is in nanoseconds, in which case that timer expires in
> one nano-second's time; or
> 2. ts->scale is not in nanoseconds, in which case nanosecond VM clock
> is going to be a huge time in the future, and it's never going
> to expire.
>
> I wonder whether it's meant to be 1 millisecond or 1 microsecond?
Maybe once it was 1 ms, this code just exists to keep the buffers
of a soundcard filled / emptied in time. 100 times / second is more
then plenty for that, so that is what I'm going to use in the patch I'm
about to submit.
Regards,
Hans
p.s.
I still think we should unlock the io-thread in the main_loop_wait when
called with nonblocking == 0, even if there are expired timers. Any
suggestions on how to best do that ?
next prev parent reply other threads:[~2013-10-09 18:50 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 19:10 [Qemu-devel] [PATCH] main-loop: Don't lock starve io-threads when main_loop_tlg has pending events Hans de Goede
2013-10-08 19:13 ` Paolo Bonzini
2013-10-08 19:21 ` Hans de Goede
2013-10-08 19:33 ` Alex Bligh
2013-10-08 19:41 ` Hans de Goede
2013-10-08 20:01 ` Alex Bligh
2013-10-08 20:07 ` Alex Bligh
2013-10-08 20:16 ` Hans de Goede
2013-10-08 20:32 ` Alex Bligh
2013-10-08 20:50 ` Paolo Bonzini
2013-10-09 12:58 ` Hans de Goede
2013-10-09 13:18 ` Alex Bligh
2013-10-09 18:03 ` Hans de Goede
2013-10-09 18:15 ` Hans de Goede
2013-10-09 18:28 ` Alex Bligh
2013-10-09 18:36 ` Alex Bligh
2013-10-09 18:49 ` Hans de Goede [this message]
2013-10-09 19:03 ` Paolo Bonzini
2013-10-09 19:15 ` Hans de Goede
2013-10-09 14:37 ` Paolo Bonzini
2013-10-09 16:19 ` Alex Bligh
2013-10-09 16:26 ` Paolo Bonzini
2013-10-09 16:33 ` Alex Bligh
2013-10-09 17:53 ` Hans de Goede
2013-10-09 18:09 ` Hans de Goede
2013-10-08 19:48 ` Alex Bligh
2013-10-08 20:01 ` Hans de Goede
2013-10-08 21:25 ` Alex Bligh
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=5255A554.1070105@redhat.com \
--to=hdegoede@redhat.com \
--cc=alex@alex.org.uk \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).