Re: [patch V4 26/36] rseq: Optimize event setting
From: Mathieu Desnoyers
Date: Thu Sep 11 2025 - 13:15:12 EST
On 2025-09-11 12:06, Thomas Gleixner wrote:
On Thu, Sep 11 2025 at 10:03, Mathieu Desnoyers wrote:Note that this concerns code that documents an explicit " & " as
On 2025-09-08 17:32, Thomas Gleixner wrote:
static inline void rseq_handle_notify_resume(struct pt_regs *regs)
{
- if (current->rseq.event.has_rseq)
+ /* '&' is intentional to spare one conditional branch */
+ if (current->rseq.event.sched_switch & current->rseq.event.has_rseq)
I wonder.. except for the corner case of rseq unregistration,
when can we have sched_switch set but not has_rseq ?
We could remove a load from the fast path and the AND if we
clear the sched_switch flag on rseq unregistration.
We probably could. Though I doubt it matters much and I opted for
correctness instead of premature optimization.
intentional to spare a branch, which led me to assume that optimizing
it was important.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com