From: Richard Henderson <richard.henderson@linaro.org>
To: Michael Tokarev <mjt@tls.msk.ru>, qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PULL 02/10] util/interval-tree: Use qatomic_set_mb in rb_link_node
Date: Fri, 4 Aug 2023 06:41:31 -0700 [thread overview]
Message-ID: <04b4edc5-f24d-3d33-970a-172e889d9c02@linaro.org> (raw)
In-Reply-To: <8854030f-73ea-b92b-2ee4-c219acfbe1c3@tls.msk.ru>
On 8/4/23 02:02, Michael Tokarev wrote:
> 01.08.2023 00:02, Richard Henderson wrote:
>> Ensure that the stores to rb_left and rb_right are complete before
>> inserting the new node into the tree. Otherwise a concurrent reader
>> could see garbage in the new leaf.
>>
>> Cc: qemu-stable@nongnu.org
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> util/interval-tree.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/util/interval-tree.c b/util/interval-tree.c
>> index 5a0ad21b2d..759562db7d 100644
>> --- a/util/interval-tree.c
>> +++ b/util/interval-tree.c
>> @@ -128,7 +128,11 @@ static inline void rb_link_node(RBNode *node, RBNode *parent,
>> RBNode **rb_link)
>> node->rb_parent_color = (uintptr_t)parent;
>> node->rb_left = node->rb_right = NULL;
>> - qatomic_set(rb_link, node);
>> + /*
>> + * Ensure that node is initialized before insertion,
>> + * as viewed by a concurrent search.
>> + */
>> + qatomic_set_mb(rb_link, node);
>
> FWIW, there's no qatomic_set_mb() in 8.0 and before, so this can not be
> directly applied to stable-8.0. This commit is missing in 8.0 before
> qatomic_set_mb() can be used:
>
> commit 06831001ac8949b0801e0d20c347d97339769a20
> Author: Paolo Bonzini <pbonzini@redhat.com>
> Date: Fri Mar 3 14:37:51 2023 +0100
>
> atomics: eliminate mb_read/mb_set
>
> I don't think it's a good idea to back-port this commit to stable-8.0.
>
> How do you think we can solve this for 8.0?
The function is called qatomic_mb_set instead of qatomic_set_mb in stable-8.0.
r~
next prev parent reply other threads:[~2023-08-04 13:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 21:02 [PULL 00/10] tcg patch queue for rc2 Richard Henderson
2023-07-31 21:02 ` [PULL 01/10] util/interval-tree: Use qatomic_read for left/right while searching Richard Henderson
2023-07-31 21:02 ` [PULL 02/10] util/interval-tree: Use qatomic_set_mb in rb_link_node Richard Henderson
2023-08-04 9:02 ` Michael Tokarev
2023-08-04 13:41 ` Richard Henderson [this message]
2023-08-04 16:22 ` Michael Tokarev
2023-07-31 21:02 ` [PULL 03/10] util/interval-tree: Introduce pc_parent Richard Henderson
2023-07-31 21:02 ` [PULL 04/10] util/interval-tree: Use qatomic_read/set for rb_parent_color Richard Henderson
2023-07-31 21:02 ` [PULL 05/10] accel/tcg: Clear tcg_ctx->gen_tb on buffer overflow Richard Henderson
2023-07-31 21:02 ` [PULL 06/10] bsd-user: Allocate guest virtual address space Richard Henderson
2023-07-31 21:02 ` [PULL 07/10] bsd-user: Specify host page alignment if none specified Richard Henderson
2023-07-31 21:02 ` [PULL 08/10] target/ppc: Disable goto_tb with architectural singlestep Richard Henderson
2023-08-01 6:05 ` Michael Tokarev
2023-08-01 6:08 ` Michael Tokarev
2023-07-31 21:02 ` [PULL 09/10] linux-user/armeb: Fix __kernel_cmpxchg() for armeb Richard Henderson
2023-07-31 21:02 ` [PULL 10/10] target/s390x: Move trans_exc_code update to do_program_interrupt Richard Henderson
2023-08-01 4:08 ` [PULL 00/10] tcg patch queue for rc2 Richard Henderson
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=04b4edc5-f24d-3d33-970a-172e889d9c02@linaro.org \
--to=richard.henderson@linaro.org \
--cc=mjt@tls.msk.ru \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.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;
as well as URLs for NNTP newsgroup(s).