[08/17] net/virtio: use previous value atomic fetch operations
Checks
Commit Message
Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch when we have no interest in the
result of the operation.
Reduces unnecessary codegen that provided the result of the atomic
operation that was not used.
Change brings closer alignment with atomics available in C11 standard
and will reduce review effort when they are integrated.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
drivers/net/virtio/virtio_user/virtio_user_dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 3/2/23 01:47, Tyler Retzlaff wrote:
> Use __atomic_fetch_{add,and,or,sub,xor} instead of
> __atomic_{add,and,or,sub,xor}_fetch when we have no interest in the
> result of the operation.
>
> Reduces unnecessary codegen that provided the result of the atomic
> operation that was not used.
>
> Change brings closer alignment with atomics available in C11 standard
> and will reduce review effort when they are integrated.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
> drivers/net/virtio/virtio_user/virtio_user_dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index f46a131..2b4607a 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -1025,7 +1025,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
> uep->id = desc_idx;
> uep->len = n_descs;
>
> - __atomic_add_fetch(&vring->used->idx, 1, __ATOMIC_RELAXED);
> + __atomic_fetch_add(&vring->used->idx, 1, __ATOMIC_RELAXED);
> }
> }
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
@@ -1025,7 +1025,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
uep->id = desc_idx;
uep->len = n_descs;
- __atomic_add_fetch(&vring->used->idx, 1, __ATOMIC_RELAXED);
+ __atomic_fetch_add(&vring->used->idx, 1, __ATOMIC_RELAXED);
}
}