All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Bligh <alex@alex.org.uk>
To: Hans de Goede <hdegoede@redhat.com>
Cc: qemu-devel@nongnu.org, Alex Bligh <alex@alex.org.uk>
Subject: Re: [Qemu-devel] [PATCH] main-loop: Don't lock starve io-threads when main_loop_tlg has pending events
Date: Tue, 8 Oct 2013 22:25:04 +0100	[thread overview]
Message-ID: <8EE2AD26-1C32-4C69-BA89-B5C4C4D46DA2@alex.org.uk> (raw)
In-Reply-To: <52546492.7000809@redhat.com>


On 8 Oct 2013, at 21:01, Hans de Goede wrote:

>>> +    /* When not non-blocking always allow io-threads to acquire the lock */
>>> +    if (timeout != 0 && timeout_ns == 0) {
>>> +        timeout_ns = 1;
>>> +    }
>>> +
>>>     ret = os_host_main_loop_wait(timeout_ns);
>>>     qemu_iohandler_poll(gpollfds, ret);
>>> #ifdef CONFIG_SLIRP
>> 
>> I /think/ you might mean "if (!blocking && timeout_ns == 0)"
>> as timeout can be zero on a blocking call at this stage (i.e.
>> when there is a timer which has already expired.
> 
> timeout does not get modified, except by the slirp-stuff, which
> won't ever set it to 0 I think.

Ignoring the slirp stuff (which is hopefully irrelevant):

For your patch to have any effect, timeout_ns must be zero
or your timeout_ns=1 would not execute.

timeout_ns should not be zero frequently for the reason
I described.

If the call to main_loop_wait is blocking (i.e. nonblocking==0),
timeout_ns should start at -1 - this is the case you described.
If the call is non-blocking (as I originally thought)
timeout_ns should start at zero.

Then this line happens:

    timeout_ns = qemu_soonest_timeout(timeout_ns,
                                      timerlistgroup_deadline_ns(
                                          &main_loop_tlg));

If timeout_ns is zero (i.e. non-blocking, caused by timeout=0)
this will do nothing (lack of optimisation and opacity here is
down to slirp stuff).

If timeout_ns is -1 (i.e. blocking, timeout=UINT32_MAX), then
this will use the return from
timerlistgroup_deadline_ns(). You said this was returning
zero, which would cause os_host_main_loop_wait() to
be called with a zero parameter.

This would explain the symptom, and explain why the fix
worked. But the question is why is timerlistgroup_deadline_ns
returning zero.


>  But your right writing
> 
>   if (!nonblocking && timeout_ns == 0)
> 
> would be much clearer, so I'll do that in v2 of the patch.


-- 
Alex Bligh

      reply	other threads:[~2013-10-08 21:25 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
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 [this message]

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=8EE2AD26-1C32-4C69-BA89-B5C4C4D46DA2@alex.org.uk \
    --to=alex@alex.org.uk \
    --cc=hdegoede@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.