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

From: Peter Zijlstra
Date: Thu Jun 19 2025 - 04:44:46 EST


On Thu, Jun 19, 2025 at 04:37:33AM -0400, Steven Rostedt wrote:
> 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

Do we really have to support 32bit?

But IIRC a previous version of all this had a syscall counter. If you
make this a per task syscall counter, unsigned long is plenty.

I suppose that was dropped because adding that counter increment to all
syscalls blows. But if you really want to support 32bit, that might be a
fallback.

Luckily, x86 dropped support for !CMPXCHG8B right along with !TSC. So on
x86 we good with timestamps, even on 32bit.