]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
sched/mmcid: Optimize transitional CIDs when scheduling out
authorThomas Gleixner <tglx@kernel.org>
Mon, 2 Feb 2026 09:39:55 +0000 (10:39 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 4 Feb 2026 11:21:12 +0000 (12:21 +0100)
commit4463c7aa11a6e67169ae48c6804968960c4bffea
treeab71341f1e9725425461b1aed59b262ed10ab850
parent007d84287c7466ca68a5809b616338214dc5b77b
sched/mmcid: Optimize transitional CIDs when scheduling out

During the investigation of the various transition mode issues
instrumentation revealed that the amount of bitmap operations can be
significantly reduced when a task with a transitional CID schedules out
after the fixup function completed and disabled the transition mode.

At that point the mode is stable and therefore it is not required to drop
the transitional CID back into the pool. As the fixup is complete the
potential exhaustion of the CID pool is not longer possible, so the CID can
be transferred to the scheduling out task or to the CPU depending on the
current ownership mode.

The racy snapshot of mm_cid::mode which contains both the ownership state
and the transition bit is valid because runqueue lock is held and the fixup
function of a concurrent mode switch is serialized.

Assigning the ownership right there not only spares the bitmap access for
dropping the CID it also avoids it when the task is scheduled back in as it
directly hits the fast path in both modes when the CID is within the
optimal range. If it's outside the range the next schedule in will need to
converge so dropping it right away is sensible. In the good case this also
allows to go into the fast path on the next schedule in operation.

With a thread pool benchmark which is configured to cross the mode switch
boundaries frequently this reduces the number of bitmap operations by about
30% and increases the fastpath utilization in the low single digit
percentage range.

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