]> Gentwo Git Trees - linux/.git/commit
rseq: Optimize event setting
authorThomas Gleixner <tglx@linutronix.de>
Mon, 27 Oct 2025 08:45:14 +0000 (09:45 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 4 Nov 2025 07:34:03 +0000 (08:34 +0100)
commit39a167560a61f913560ba803a96dbe6c15239f5c
treeeb6459ef532e42617b26670d36343e3b34ec20c1
parente2d4f42271155045a49b89530f2c06ad8e9f1a1e
rseq: Optimize event setting

After removing the various condition bits earlier it turns out that one
extra information is needed to avoid setting event::sched_switch and
TIF_NOTIFY_RESUME unconditionally on every context switch.

The update of the RSEQ user space memory is only required, when either

  the task was interrupted in user space and schedules

or

  the CPU or MM CID changes in schedule() independent of the entry mode

Right now only the interrupt from user information is available.

Add an event flag, which is set when the CPU or MM CID or both change.

Evaluate this event in the scheduler to decide whether the sched_switch
event and the TIF bit need to be set.

It's an extra conditional in context_switch(), but the downside of
unconditionally handling RSEQ after a context switch to user is way more
significant. The utilized boolean logic minimizes this to a single
conditional branch.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20251027084307.578058898@linutronix.de
fs/exec.c
include/linux/rseq.h
include/linux/rseq_types.h
kernel/rseq.c
kernel/sched/core.c
kernel/sched/sched.h