Skip to content

Commit 79c11fb

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
sched/mmcid: Use cpumask_weighted_or()
Use cpumask_weighted_or() instead of cpumask_or() and cpumask_weight() on the result, which walks the same bitmap twice. Results in 10-20% less cycles, which reduces the runqueue lock hold time. 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> Acked-by: Yury Norov (NVIDIA) <yury.norov@gmail.com> Link: https://patch.msgid.link/20251119172549.511736272@linutronix.de
1 parent 437cb3d commit 79c11fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/sched/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10377,6 +10377,7 @@ void call_trace_sched_update_nr_running(struct rq *rq, int count)
1037710377
static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpumask *affmsk)
1037810378
{
1037910379
struct cpumask *mm_allowed;
10380+
unsigned int weight;
1038010381

1038110382
if (!mm)
1038210383
return;
@@ -10387,8 +10388,8 @@ static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpu
1038710388
*/
1038810389
guard(raw_spinlock)(&mm->mm_cid.lock);
1038910390
mm_allowed = mm_cpus_allowed(mm);
10390-
cpumask_or(mm_allowed, mm_allowed, affmsk);
10391-
WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, cpumask_weight(mm_allowed));
10391+
weight = cpumask_weighted_or(mm_allowed, mm_allowed, affmsk);
10392+
WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, weight);
1039210393
}
1039310394

1039410395
void sched_mm_cid_exit_signals(struct task_struct *t)

0 commit comments

Comments
 (0)