From: Kevin Wolf <kwolf@redhat.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
Hanna Reitz <hreitz@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Subject: Re: [PATCH v2 0/3] block/accounting: fix unlocked latency histogram reconfiguration races
Date: Fri, 24 Jul 2026 15:02:32 +0200 [thread overview]
Message-ID: <amNiaGIifcK8FNDe@redhat.com> (raw)
In-Reply-To: <20260724111311.4086859-1-den@openvz.org>
Am 24.07.2026 um 13:13 hat Denis V. Lunev geschrieben:
> block_latency_histogram_set() and block_latency_histograms_clear()
> replace BlockLatencyHistogram's nbins/boundaries/bins without taking
> stats->lock, while block_account_one_io() reads those same fields
> under that lock from whatever iothread completes the I/O. A histogram
> reconfiguration (block-latency-histogram-set QMP command, monitor
> thread) racing an in-flight completion can therefore observe those
> fields torn, hitting assert(pos != NULL) in
> block_latency_histogram_account(), or corrupting the heap outright.
> This showed up as a qemu-kvm SIGABRT on a customer's virtio-blk guest.
>
> Regression test is added for illustrative purpose but I am unsure that
> it is viable long term. Feel free to drop.
>
> v1 -> v2
> * patch 1, 2: WITH_QEMU_LOCK_GUARD -> plain lock()/unlock(), pure
> additions, nothing reindented or moved
> * patch 3: writer thread now also calls
> block_latency_histograms_clear(), the other function patch 1 fixes
> * patch 2: take stats->lock for bdrv_query_blk_stats()'s whole call
> instead of per-section, since the interval loop's
> timed_average_min/max/avg() calls race timed_average_account() the
> same way the already-locked fields did; block_acct_queue_depth()
> now requires the caller to hold the lock instead of taking it
> itself, since bdrv_query_blk_stats() is its only caller
Thanks, applied to the block branch.
Kevin
prev parent reply other threads:[~2026-07-24 13:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 11:13 [PATCH v2 0/3] block/accounting: fix unlocked latency histogram reconfiguration races Denis V. Lunev
2026-07-24 11:13 ` [PATCH v2 1/3] block/accounting: take stats->lock in latency histogram setters Denis V. Lunev
2026-07-24 11:13 ` [PATCH v2 3/3] tests/unit: add reproducer for BlockAcctStats histogram locking race Denis V. Lunev
2026-07-24 13:02 ` Kevin Wolf [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=amNiaGIifcK8FNDe@redhat.com \
--to=kwolf@redhat.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=den@openvz.org \
--cc=hreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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.