qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	 Stefan Hajnoczi <stefanha@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	 "Emilio G . Cota" <cota@braap.org>
Subject: Re: [PATCH 3/3] rcu: Avoid double rcu frees
Date: Tue, 30 Sep 2025 10:19:54 +0100	[thread overview]
Message-ID: <CAFEAcA-7OC3AfDyowK9pCW6yxo_LoTVv=B+AvT=1g+6W46DmrQ@mail.gmail.com> (raw)
In-Reply-To: <20250929190801.931989-4-peterx@redhat.com>

On Mon, 29 Sept 2025 at 20:08, Peter Xu <peterx@redhat.com> wrote:
>
> Trap call_rcu1() to make sure it won't be invoked twice for one rcu head.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  util/rcu.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/util/rcu.c b/util/rcu.c
> index b703c86f15..9272fe5796 100644
> --- a/util/rcu.c
> +++ b/util/rcu.c
> @@ -307,6 +307,8 @@ static void *call_rcu_thread(void *opaque)
>
>  void call_rcu1(struct rcu_head *node, void (*func)(struct rcu_head *node))
>  {
> +    /* Avoid double rcu frees */

I would maybe have this say "Catch accidental attempts to
use the same rcu node for two things at once", which
isn't the same as a "double free" in the usual sense.

> +    assert(node->func == NULL);
>      node->func = func;
>      enqueue(node);
>      qatomic_inc(&rcu_call_count);

thanks
-- PMM


  reply	other threads:[~2025-09-30  9:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-29 19:07 [PATCH 0/3] rcu: Detect accidental reuse of rcu head Peter Xu
2025-09-29 19:07 ` [PATCH 1/3] qht: Zero-initialize qht_map Peter Xu
2025-09-29 19:08 ` [PATCH 2/3] tests/test-rcu-*: Zero-initialize allocated elements Peter Xu
2025-09-29 19:08 ` [PATCH 3/3] rcu: Avoid double rcu frees Peter Xu
2025-09-30  9:19   ` Peter Maydell [this message]
2025-09-30 16:14     ` Peter Xu

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='CAFEAcA-7OC3AfDyowK9pCW6yxo_LoTVv=B+AvT=1g+6W46DmrQ@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=cota@braap.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.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 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).