Re: [RFC 1/3] rv: add per-edge dwell-time statistics primitive

From: Gabriele Monaco

Date: Tue Sep 01 2026 - 03:40:39 EST


On Thu, 2026-08-27 at 09:23 +0200, Tobias Schaffner wrote:
> + while (dwell_ns > (u64)max) {
> + s64 prev = local64_cmpxchg(&s->max_ns, max, dwell_ns);
> +
> + if (prev == max)
> + break;
> + max = prev;
> + }

try_cmpxchg() functions produce arguably cleaner code, would you mind doing:

while (dwell_ns > (u64)max) {
if (local64_try_cmpxchg(&s->max_ns, &max, dwell_ns))
break;
}

Also, although issues are practically impossible, I'd avoid an unbound loop in
hot paths, you could go up to MAX_DA_RETRY_RACING_EVENTS (already existing in
da_monitor) and put some warning in case you reach the maximum amount of
retries.

Thanks,
Gabriele