From: Paolo Bonzini <pbonzini@redhat.com>
To: Warner Losh <imp@bsdimp.com>,
Richard Henderson <richard.henderson@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: Question about atomics
Date: Tue, 8 Mar 2022 15:26:05 +0100 [thread overview]
Message-ID: <e60a4298-17f3-d3e7-bf94-bf2dbbe83141@redhat.com> (raw)
In-Reply-To: <CANCZdfqwA8HbxYhud8pKxF_f=BMoMtrO+R=zg7GiKesz8_YZvg@mail.gmail.com>
On 3/8/22 15:09, Warner Losh wrote:
>
> Yes, qatomic_foo is expected to work. It's what we use across
> threads, and it is expected to work "in kernel mode", i.e. within cpu_loop().
>
> Even when the writers are done in the context of system calls to the kernel?
Yes.
That said, for the similar syscall in Linux we just forward it to the
kernel (and the kernel obviously can only do an atomic---no
start_exclusive/end_exclusive involved).
> And if the system call does this w/o using
> the start_exclusive/end_exclusive stuff, is that a problem?
If it does it without start_exclusive/end_exclusive they must use
qatomic_foo(). If it does it with start_exclusive/end_exclusive, they
can even write a compare-and-exchange as
old = *(uint64_t *)g2h(cs, addr);
if (old == oldval)
*(uint64_t *)g2h(cs, addr) = new;
Paolo
next prev parent reply other threads:[~2022-03-08 14:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 4:18 Question about atomics Warner Losh
2022-03-08 5:00 ` Richard Henderson
2022-03-08 14:09 ` Warner Losh
2022-03-08 14:26 ` Paolo Bonzini [this message]
2022-03-08 16:29 ` Warner Losh
2022-03-13 4:59 ` Warner Losh
2022-03-13 16:47 ` Richard Henderson
2022-03-13 16:57 ` Warner Losh
2022-03-13 17:03 ` Richard Henderson
2022-03-13 18:29 ` Warner Losh
2022-03-13 20:19 ` Richard Henderson
2022-03-14 4:09 ` Warner Losh
2022-03-14 4:36 ` Richard Henderson
2022-03-14 5:42 ` Warner Losh
2022-03-14 4:43 ` Richard Henderson
2022-03-14 5:34 ` Warner Losh
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=e60a4298-17f3-d3e7-bf94-bf2dbbe83141@redhat.com \
--to=pbonzini@redhat.com \
--cc=imp@bsdimp.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;
as well as URLs for NNTP newsgroup(s).