]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/mmcid: Move scheduler code out of global header
authorThomas Gleixner <tglx@linutronix.de>
Wed, 19 Nov 2025 17:26:53 +0000 (18:26 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 20 Nov 2025 11:14:53 +0000 (12:14 +0100)
This is only used in the scheduler core code, so there is no point to have
it in a global header.

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.321259077@linutronix.de
include/linux/mm_types.h
kernel/sched/core.c

index e4818e932a1d00a9bca0021e53d1804dccaee7d2..67a7bdf772f7c198f9dd025fef2efd95641a7747 100644 (file)
@@ -1387,27 +1387,14 @@ static inline unsigned int mm_cid_size(void)
        return 2 * cpumask_size();      /* mm_cpus_allowed(), mm_cidmask(). */
 }
 
-static inline void mm_set_cpus_allowed(struct mm_struct *mm, const struct cpumask *cpumask)
-{
-       struct cpumask *mm_allowed = mm_cpus_allowed(mm);
-
-       if (!mm)
-               return;
-       /* The mm_cpus_allowed is the union of each thread allowed CPUs masks. */
-       guard(raw_spinlock)(&mm->mm_cid.lock);
-       cpumask_or(mm_allowed, mm_allowed, cpumask);
-       WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, cpumask_weight(mm_allowed));
-}
 #else /* CONFIG_SCHED_MM_CID */
 static inline void mm_init_cid(struct mm_struct *mm, struct task_struct *p) { }
 static inline int mm_alloc_cid(struct mm_struct *mm, struct task_struct *p) { return 0; }
 static inline void mm_destroy_cid(struct mm_struct *mm) { }
-
 static inline unsigned int mm_cid_size(void)
 {
        return 0;
 }
-static inline void mm_set_cpus_allowed(struct mm_struct *mm, const struct cpumask *cpumask) { }
 #endif /* CONFIG_SCHED_MM_CID */
 
 struct mmu_gather;
index b667171b442289cb4c64ca9b188445bd553339f9..f5e37c233b0162e0c7fa37fbafdf70f11c3bf7ae 100644 (file)
@@ -2669,6 +2669,8 @@ out_unlock:
        return 0;
 }
 
+static inline void mm_update_cpus_allowed(struct mm_struct *mm, const cpumask_t *affmask);
+
 /*
  * sched_class::set_cpus_allowed must do the below, but is not required to
  * actually call this function.
@@ -2728,7 +2730,7 @@ __do_set_cpus_allowed(struct task_struct *p, struct affinity_context *ctx)
                put_prev_task(rq, p);
 
        p->sched_class->set_cpus_allowed(p, ctx);
-       mm_set_cpus_allowed(p->mm, ctx->new_mask);
+       mm_update_cpus_allowed(p->mm, ctx->new_mask);
 
        if (queued)
                enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK);
@@ -10372,6 +10374,18 @@ void call_trace_sched_update_nr_running(struct rq *rq, int count)
  * When a task exits, the MM CID held by the task is not longer required as
  * the task cannot return to user space.
  */
+static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpumask *affmsk)
+{
+       struct cpumask *mm_allowed = mm_cpus_allowed(mm);
+
+       if (!mm)
+               return;
+       /* The mm_cpus_allowed is the union of each thread allowed CPUs masks. */
+       guard(raw_spinlock)(&mm->mm_cid.lock);
+       cpumask_or(mm_allowed, mm_allowed, affmsk);
+       WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, cpumask_weight(mm_allowed));
+}
+
 void sched_mm_cid_exit_signals(struct task_struct *t)
 {
        struct mm_struct *mm = t->mm;
@@ -10411,7 +10425,9 @@ void sched_mm_cid_fork(struct task_struct *t)
        WARN_ON_ONCE(!t->mm || t->mm_cid.cid != MM_CID_UNSET);
        t->mm_cid.active = 1;
 }
-#endif /* CONFIG_SCHED_MM_CID */
+#else /* CONFIG_SCHED_MM_CID */
+static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpumask *affmsk) { }
+#endif /* !CONFIG_SCHED_MM_CID */
 
 #ifdef CONFIG_SCHED_CLASS_EXT
 void sched_deq_and_put_task(struct task_struct *p, int queue_flags,