Re: [PATCH] bitops: add _local bitops

From: H. Peter Anvin
Date: Wed May 09 2012 - 10:04:15 EST


On 05/09/2012 06:45 AM, Michael S. Tsirkin wrote:
> kvm needs to update some hypervisor variables atomically
> in a sense that the operation can't be interrupted
> in the middle. However the hypervisor always runs
> on the same CPU so it does not need any memory
> barrier or lock prefix.
>
> At Peter Anvin's suggestion, add _local bitops for this purpose:
> define them as non-atomics for x86 and (for now) atomics
> for everyone else.
>
> Uses are not restricted to virtualization: they
> might be useful to communicate with an interrupt
> handler if we know that it's running on the same CPU.
>
> Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>

I don't think you can use the x86 nonatomics as-is, because they don't
contain optimization barriers.

-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/