Skip to content

Commit b08ef5f

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
sched/mmcid: Move scheduler code out of global header
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
1 parent 925b784 commit b08ef5f

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

include/linux/mm_types.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,27 +1387,14 @@ static inline unsigned int mm_cid_size(void)
13871387
return 2 * cpumask_size(); /* mm_cpus_allowed(), mm_cidmask(). */
13881388
}
13891389

1390-
static inline void mm_set_cpus_allowed(struct mm_struct *mm, const struct cpumask *cpumask)
1391-
{
1392-
struct cpumask *mm_allowed = mm_cpus_allowed(mm);
1393-
1394-
if (!mm)
1395-
return;
1396-
/* The mm_cpus_allowed is the union of each thread allowed CPUs masks. */
1397-
guard(raw_spinlock)(&mm->mm_cid.lock);
1398-
cpumask_or(mm_allowed, mm_allowed, cpumask);
1399-
WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, cpumask_weight(mm_allowed));
1400-
}
14011390
#else /* CONFIG_SCHED_MM_CID */
14021391
static inline void mm_init_cid(struct mm_struct *mm, struct task_struct *p) { }
14031392
static inline int mm_alloc_cid(struct mm_struct *mm, struct task_struct *p) { return 0; }
14041393
static inline void mm_destroy_cid(struct mm_struct *mm) { }
1405-
14061394
static inline unsigned int mm_cid_size(void)
14071395
{
14081396
return 0;
14091397
}
1410-
static inline void mm_set_cpus_allowed(struct mm_struct *mm, const struct cpumask *cpumask) { }
14111398
#endif /* CONFIG_SCHED_MM_CID */
14121399

14131400
struct mmu_gather;

kernel/sched/core.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,6 +2669,8 @@ int push_cpu_stop(void *arg)
26692669
return 0;
26702670
}
26712671

2672+
static inline void mm_update_cpus_allowed(struct mm_struct *mm, const cpumask_t *affmask);
2673+
26722674
/*
26732675
* sched_class::set_cpus_allowed must do the below, but is not required to
26742676
* actually call this function.
@@ -2728,7 +2730,7 @@ __do_set_cpus_allowed(struct task_struct *p, struct affinity_context *ctx)
27282730
put_prev_task(rq, p);
27292731

27302732
p->sched_class->set_cpus_allowed(p, ctx);
2731-
mm_set_cpus_allowed(p->mm, ctx->new_mask);
2733+
mm_update_cpus_allowed(p->mm, ctx->new_mask);
27322734

27332735
if (queued)
27342736
enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK);
@@ -10372,6 +10374,18 @@ void call_trace_sched_update_nr_running(struct rq *rq, int count)
1037210374
* When a task exits, the MM CID held by the task is not longer required as
1037310375
* the task cannot return to user space.
1037410376
*/
10377+
static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpumask *affmsk)
10378+
{
10379+
struct cpumask *mm_allowed = mm_cpus_allowed(mm);
10380+
10381+
if (!mm)
10382+
return;
10383+
/* The mm_cpus_allowed is the union of each thread allowed CPUs masks. */
10384+
guard(raw_spinlock)(&mm->mm_cid.lock);
10385+
cpumask_or(mm_allowed, mm_allowed, affmsk);
10386+
WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, cpumask_weight(mm_allowed));
10387+
}
10388+
1037510389
void sched_mm_cid_exit_signals(struct task_struct *t)
1037610390
{
1037710391
struct mm_struct *mm = t->mm;
@@ -10411,7 +10425,9 @@ void sched_mm_cid_fork(struct task_struct *t)
1041110425
WARN_ON_ONCE(!t->mm || t->mm_cid.cid != MM_CID_UNSET);
1041210426
t->mm_cid.active = 1;
1041310427
}
10414-
#endif /* CONFIG_SCHED_MM_CID */
10428+
#else /* CONFIG_SCHED_MM_CID */
10429+
static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpumask *affmsk) { }
10430+
#endif /* !CONFIG_SCHED_MM_CID */
1041510431

1041610432
#ifdef CONFIG_SCHED_CLASS_EXT
1041710433
void sched_deq_and_put_task(struct task_struct *p, int queue_flags,

0 commit comments

Comments
 (0)