Re: [PATCH v10 07/14] unwind_user/deferred: Make unwind deferral requests NMI-safe

From: Steven Rostedt
Date: Thu Jun 19 2025 - 04:38:27 EST


On Thu, 19 Jun 2025 10:34:15 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> Why can't we cmpxchg_local() the thing and avoid this horrible stuff?
>
> static u64 get_timestamp(struct unwind_task_info *info)
> {
> u64 new, old = info->timestamp;
>
> if (old)
> return old;
>
> new = local_clock();
> old = cmpxchg_local(&info->timestamp, old, new);
> if (old)
> return old;
> return new;
> }
>
> Seems simple enough; what's wrong with it?

It's a 64 bit number where most 32 bit architectures don't have any
decent cmpxchg on 64 bit values. That's given me hell in the ring
buffer code :-p

-- Steve