]> Gentwo Git Trees - linux/.git/commit
sched/mmcid: Provide precomputed maximal value
authorThomas Gleixner <tglx@linutronix.de>
Wed, 19 Nov 2025 17:27:09 +0000 (18:27 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 25 Nov 2025 18:45:40 +0000 (19:45 +0100)
commitb0c3d51b54f8a4f4c809432d210c0c983d5cd97e
tree7c76e8d9f0631969fa9a2833d950b7394fbb4787
parentbf070520e398679cd582b3c3e44107bf22c143ba
sched/mmcid: Provide precomputed maximal value

Reading mm::mm_users and mm:::mm_cid::nr_cpus_allowed every time to compute
the maximal CID value is just wasteful as that value is only changing on
fork(), exit() and eventually when the affinity changes.

So it can be easily precomputed at those points and provided in mm::mm_cid
for consumption in the hot path.

But there is an issue with using mm::mm_users for accounting because that
does not necessarily reflect the number of user space tasks as other kernel
code can take temporary references on the MM which skew the picture.

Solve that by adding a users counter to struct mm_mm_cid, which is modified
by fork() and exit() and used for precomputing under mm_mm_cid::lock.

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