All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>, svt-core@virtuozzo.com
Subject: Re: [PATCH hci-dev] monitor: fix abort when a rate-limited event races with its timer #VSTOR-156540
Date: Tue, 24 Nov 2026 14:12:51 +0200	[thread overview]
Message-ID: <440ab363-3414-4c60-89ff-ff1814316cd4@virtuozzo.com> (raw)
In-Reply-To: <20261123212942.242422-1-den@openvz.org>

Ack
Applied to both hci-dev and hci-8.1

On 11/23/26 11:29 PM, Denis V. Lunev wrote:
> From: Denis V. Lunev <den@openvz.org>
> 
> Rate-limited events can be raised from iothreads, outside the BQL.
> QUORUM_REPORT_BAD always could be. Since 2155d2dd7f73 BLOCK_IO_ERROR is
> rate limited too, and any disk on an iothread raises it.
> 
> The rate-limit timer runs in the main loop. timerlist_run_timers()
> takes it off the active list before it calls the handler, and only then
> does the handler take monitor_lock. An iothread raising the same event
> for the same device in between finds the rate-limit entry with a timer
> that is no longer pending, and QEMU aborts with:
> 
>   Assertion `!evstate || timer_pending(evstate->timer)' failed.
> 
> This hits virtio-blk on an iothread with an error policy other than
> stop when the storage goes away and every guest request fails.
> 
> The state is fine, the assert is wrong. Once the timer has fired, the
> handler is committed to run: it takes the lock as soon as the iothread
> drops it, sends the stored event and re-arms the timer, exactly as for
> an event stored while the timer was pending. The event goes out at the
> same moment it would have had the iothread come in after the handler.
> The entry is only created, re-armed and freed under monitor_lock, so it
> cannot go away under the iothread. Drop the assert.
> 
> Fixes: a24712af5425 ("monitor: Turn monitor_qapi_event_state[] into a hash table")
> Fixes: 2155d2dd7f73 ("block-backend: per-device throttling of BLOCK_IO_ERROR reports")
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Dr. David Alan Gilbert <dave@treblig.org>
> Cc: qemu-stable@nongnu.org
> ---
>  monitor/monitor.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index f7703d9bd05..408cbfeac58 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -397,13 +397,14 @@ monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)
>          MonitorQAPIEventState key = { .event = event, .data = data };
>  
>          evstate = g_hash_table_lookup(monitor_qapi_event_state, &key);
> -        assert(!evstate || timer_pending(evstate->timer));
>  
>          if (evstate) {
>              /*
>               * Timer is pending for (at least) evconf->rate ns after
> -             * last send.  Store event for sending when timer fires,
> -             * replacing a prior stored event if any.
> +             * last send, or it has expired and its handler has not
> +             * taken monitor_lock yet. Either way the handler will
> +             * send what is stored here. Store event for sending
> +             * then, replacing a prior stored event if any.
>               */
>              qobject_unref(evstate->qdict);
>              evstate->qdict = qobject_ref(qdict);
> 
> base-commit: dd934872c8855d6ed6752edb41bfd9720d584651


      parent reply	other threads:[~2026-11-24 12:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 21:29 Denis V. Lunev
2026-11-23 21:32 ` no-reply
2026-11-24 12:12 ` Andrey Drobyshev [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=440ab363-3414-4c60-89ff-ff1814316cd4@virtuozzo.com \
    --to=andrey.drobyshev@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=svt-core@virtuozzo.com \
    /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.