Re: [RFC] in-kernel rseq

From: Mathieu Desnoyers

Date: Tue Feb 24 2026 - 08:35:35 EST


On 2026-02-24 05:27, David Laight wrote:
[...]

No scaling, in this case it is fine to add the rseq just before needing it.

In all cases it is fine to set the per-task rseq pointer just before
needing it. That's how the userspace rseq was implemented.

But if they have to be set in advance then you start getting a long list
to check - I'm sure that must happen with userspace rseq?

No, userspace declares rseq_cs descriptors in its data, and populates
the rseq_abi->rseq_cs field (thread-local) with a pointer to that
descriptor at the very beginning of the critical section.

So return to userspace after context switch either finds a NULL pointer
or only needs to load from a single rseq_cs descriptor from userspace.

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com