Re: Question about atomics

2022-03-13 Thread Warner Losh
On Sun, Mar 13, 2022 at 10:36 PM Richard Henderson < richard.hender...@linaro.org> wrote: > On 3/13/22 21:09, Warner Losh wrote: > > Oh? Out of paranoia, how can I verify that this is the case when > compiled on FreeBSD? > > Perhaps the atomic sequence FreeBSD uses differs a little from Linux and

Re: Question about atomics

2022-03-13 Thread Warner Losh
On Sun, Mar 13, 2022 at 10:43 PM Richard Henderson < richard.hender...@linaro.org> wrote: > On 3/13/22 21:09, Warner Losh wrote: > > Oh? Out of paranoia, how can I verify that this is the case when > compiled on FreeBSD? > > Perhaps the atomic sequence FreeBSD uses differs a little from Linux and

Re: Question about atomics

2022-03-13 Thread Richard Henderson
On 3/13/22 21:09, Warner Losh wrote: Oh? Out of paranoia, how can I verify that this is the case when compiled on FreeBSD? Perhaps the atomic sequence FreeBSD uses differs a little from Linux and we don't trigger that code? Or there's some adjustment that I've not made yet... the code seems to

Re: Question about atomics

2022-03-13 Thread Richard Henderson
On 3/13/22 21:09, Warner Losh wrote: Oh? Out of paranoia, how can I verify that this is the case when compiled on FreeBSD? Perhaps the atomic sequence FreeBSD uses differs a little from Linux and we don't trigger that code? $ objdump -dr libqemu-arm-*-user.fa.p/accel_tcg_user-exec.c.o 00

Re: Question about atomics

2022-03-13 Thread Warner Losh
On Sun, Mar 13, 2022 at 2:19 PM Richard Henderson < richard.hender...@linaro.org> wrote: > On 3/13/22 11:29, Warner Losh wrote: > > So I was assuming that the cas instructions for arm use > start/end_exclsive under the covers. > > Is that the case? > > Nope. The store exclusive guest insn is impl

Re: Question about atomics

2022-03-13 Thread Richard Henderson
On 3/13/22 11:29, Warner Losh wrote: So I was assuming that the cas instructions for arm use start/end_exclsive under the covers. Is that the case? Nope. The store exclusive guest insn is implemented with a host cmpxchg. Oh, I'd forgotten about the old arm cmpxchg64 syscall, which is still i

Re: Question about atomics

2022-03-13 Thread Warner Losh
On Sun, Mar 13, 2022 at 11:03 AM Richard Henderson < richard.hender...@linaro.org> wrote: > On 3/13/22 09:57, Warner Losh wrote: > > > > > > On Sun, Mar 13, 2022, 10:47 AM Richard Henderson < > richard.hender...@linaro.org > > > wrote: > > > > On 3/12/22 20

Re: Question about atomics

2022-03-13 Thread Richard Henderson
On 3/13/22 09:57, Warner Losh wrote: On Sun, Mar 13, 2022, 10:47 AM Richard Henderson > wrote: On 3/12/22 20:59, Warner Losh wrote: > FreeBSD's pthread_mutex is shared between the kernel and user land. > So it does a compare and set to take t

Re: Question about atomics

2022-03-13 Thread Warner Losh
On Sun, Mar 13, 2022, 10:47 AM Richard Henderson < richard.hender...@linaro.org> wrote: > On 3/12/22 20:59, Warner Losh wrote: > > FreeBSD's pthread_mutex is shared between the kernel and user land. > > So it does a compare and set to take the lock. Uncontested and unheld > > locks will mean we've

Re: Question about atomics

2022-03-13 Thread Richard Henderson
On 3/12/22 20:59, Warner Losh wrote: FreeBSD's pthread_mutex is shared between the kernel and user land. So it does a compare and set to take the lock. Uncontested and unheld locks will mean we've taken the lock and return. Contested locks are kicked to the kernel to wait. When userland releases

Re: Question about atomics

2022-03-12 Thread Warner Losh
On Tue, Mar 8, 2022 at 9:29 AM Warner Losh wrote: > > > On Tue, Mar 8, 2022 at 7:26 AM Paolo Bonzini wrote: > >> 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. wi

Re: Question about atomics

2022-03-08 Thread Warner Losh
On Tue, Mar 8, 2022 at 7:26 AM Paolo Bonzini wrote: > 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 th

Re: Question about atomics

2022-03-08 Thread Paolo Bonzini
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 simil

Re: Question about atomics

2022-03-08 Thread Warner Losh
On Mon, Mar 7, 2022 at 10:00 PM Richard Henderson < richard.hender...@linaro.org> wrote: > On 3/7/22 18:18, Warner Losh wrote: > > I have a question related to the user-mode emulation and atomics. I > asked on IRC, but > > thinking about it, I think it may be too complex to discuss in that > mediu

Re: Question about atomics

2022-03-07 Thread Richard Henderson
On 3/7/22 18:18, Warner Losh wrote: I have a question related to the user-mode emulation and atomics. I asked on IRC, but thinking about it, I think it may be too complex to discuss in that medium... In FreeBSD we have a system call that uses host atomic operations to interact memory that user

Question about atomics

2022-03-07 Thread Warner Losh
I have a question related to the user-mode emulation and atomics. I asked on IRC, but thinking about it, I think it may be too complex to discuss in that medium... In FreeBSD we have a system call that uses host atomic operations to interact memory that userland also interacts with using atomic op