qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about atomics


From: Paolo Bonzini
Subject: Re: Question about atomics
Date: Tue, 8 Mar 2022 15:26:05 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]