From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 1/3] qom/object: merge double hash table traversal in object_property_del_child
Date: Thu, 30 Apr 2026 10:24:20 +0100 [thread overview]
Message-ID: <afMfxMlnBsXH7kGQ@redhat.com> (raw)
In-Reply-To: <81772bda-5aed-43a0-ab2d-ac9b95b518d5@linaro.org>
On Thu, Apr 30, 2026 at 07:07:03AM +1000, Richard Henderson wrote:
> On 4/29/26 16:20, Bin Guo wrote:
> > object_property_del_child() previously performed two full iterations
> > over obj->properties: the first to find the matching child property and
> > call its release callback, the second to find the same property again
> > and remove it from the hash table.
> >
> > Merge the two loops into one: when the matching property is found, call
> > the release callback and immediately remove the entry via
> > g_hash_table_iter_remove(), then break. This halves the number of hash
> > table operations in the common case and avoids the redundant second scan.
> >
> > Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
> > ---
> > qom/object.c | 7 -------
> > 1 file changed, 7 deletions(-)
> >
> > diff --git a/qom/object.c b/qom/object.c
> > index f981e27044..9c0e8dfd02 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -629,13 +629,6 @@ static void object_property_del_child(Object *obj, Object *child)
> > prop->release(obj, prop->name, prop->opaque);
> > prop->release = NULL;
> > }
> > - break;
> > - }
> > - }
> > - g_hash_table_iter_init(&iter, obj->properties);
> > - while (g_hash_table_iter_next(&iter, &key, &value)) {
> > - prop = value;
> > - if (object_property_is_child(prop) && prop->opaque == child) {
> > g_hash_table_iter_remove(&iter);
> > break;
> > }
>
> Fixes: b604a854e84 ("qom: Replace object property list with GHashTable")
On the contrary, this proposed patch breaks that commit.
The original proposal for that old commit had a single iteration,
but it was discovered that this broke cleanup for certain devices,
as prop->release can have side-effects that trigger assertions in
g_hash_table_iter_remove. This requires a two phase iteration
to be safe.
A test for that problem was added in 8c4d156c187c84b574d287bd4b9ddf9a6975de7c
and this new patch proposal duly breaks the check-qom-proplist test.
With regards,
Daniel
next prev parent reply other threads:[~2026-04-30 9:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 6:20 [PATCH 0/3] Minor cleanups: eliminate redundant code in QOM, block-backend and vl.c Bin Guo
2026-04-29 6:20 ` [PATCH 1/3] qom/object: merge double hash table traversal in object_property_del_child Bin Guo
2026-04-29 21:07 ` Richard Henderson
2026-04-30 9:24 ` Daniel P. Berrangé [this message]
2026-04-30 13:36 ` Philippe Mathieu-Daudé
2026-04-29 6:20 ` [PATCH 2/3] block/block-backend: delegate blk_co_preadv to blk_co_preadv_part Bin Guo
2026-04-29 21:07 ` Richard Henderson
2026-05-12 12:58 ` Kevin Wolf
2026-04-29 6:20 ` [PATCH 3/3] system/vl.c: inline qemu_opts_parse_noisily() result checks Bin Guo
2026-04-29 8:04 ` Philippe Mathieu-Daudé
2026-04-29 21:03 ` Richard Henderson
2026-04-30 6:07 ` Philippe Mathieu-Daudé
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=afMfxMlnBsXH7kGQ@redhat.com \
--to=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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