[02/17] telemetry: 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>
---
lib/telemetry/telemetry.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Wed, Mar 01, 2023 at 04:47:33PM -0800, 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>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
@@ -391,7 +391,7 @@ struct socket {
bytes = read(s, buffer, sizeof(buffer) - 1);
}
close(s);
- __atomic_sub_fetch(&v2_clients, 1, __ATOMIC_RELAXED);
+ __atomic_fetch_sub(&v2_clients, 1, __ATOMIC_RELAXED);
return NULL;
}
@@ -414,7 +414,7 @@ struct socket {
close(s_accepted);
continue;
}
- __atomic_add_fetch(s->num_clients, 1,
+ __atomic_fetch_add(s->num_clients, 1,
__ATOMIC_RELAXED);
}
rc = pthread_create(&th, NULL, s->fn,
@@ -424,7 +424,7 @@ struct socket {
strerror(rc));
close(s_accepted);
if (s->num_clients != NULL)
- __atomic_sub_fetch(s->num_clients, 1,
+ __atomic_fetch_sub(s->num_clients, 1,
__ATOMIC_RELAXED);
continue;
}