qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Richard Henderson <rth@twiddle.net>,
	"Emilio G . Cota" <cota@braap.org>,
	peterx@redhat.com
Subject: [PATCH 3/3] rcu: Avoid double rcu frees
Date: Mon, 29 Sep 2025 15:08:01 -0400	[thread overview]
Message-ID: <20250929190801.931989-4-peterx@redhat.com> (raw)
In-Reply-To: <20250929190801.931989-1-peterx@redhat.com>

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 */
+    assert(node->func == NULL);
     node->func = func;
     enqueue(node);
     qatomic_inc(&rcu_call_count);
-- 
2.50.1



  parent reply	other threads:[~2025-09-29 19:08 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 ` Peter Xu [this message]
2025-09-30  9:19   ` [PATCH 3/3] rcu: Avoid double rcu frees Peter Maydell
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=20250929190801.931989-4-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=cota@braap.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).