Skip to content

Commit 77d7dc8

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
sched/mmcid: Revert the complex CID management
The CID management is a complex beast, which affects both scheduling and task migration. The compaction mechanism forces random tasks of a process into task work on exit to user space causing latency spikes. Revert back to the initial simple bitmap allocating mechanics, which are known to have scalability issues as that allows to gradually build up a replacement functionality in a reviewable way. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://patch.msgid.link/20251119172549.068197830@linutronix.de
1 parent 80adacc commit 77d7dc8

4 files changed

Lines changed: 64 additions & 800 deletions

File tree

include/linux/mm_types.h

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -922,13 +922,9 @@ struct vm_area_struct {
922922
#define vma_policy(vma) NULL
923923
#endif
924924

925-
#ifdef CONFIG_SCHED_MM_CID
926925
struct mm_cid {
927-
u64 time;
928-
int cid;
929-
int recent_cid;
926+
unsigned int cid;
930927
};
931-
#endif
932928

933929
/*
934930
* Opaque type representing current mm_struct flag state. Must be accessed via
@@ -1000,27 +996,13 @@ struct mm_struct {
1000996
* runqueue locks.
1001997
*/
1002998
struct mm_cid __percpu *pcpu_cid;
1003-
/*
1004-
* @mm_cid_next_scan: Next mm_cid scan (in jiffies).
1005-
*
1006-
* When the next mm_cid scan is due (in jiffies).
1007-
*/
1008-
unsigned long mm_cid_next_scan;
1009999
/**
10101000
* @nr_cpus_allowed: Number of CPUs allowed for mm.
10111001
*
10121002
* Number of CPUs allowed in the union of all mm's
10131003
* threads allowed CPUs.
10141004
*/
10151005
unsigned int nr_cpus_allowed;
1016-
/**
1017-
* @max_nr_cid: Maximum number of allowed concurrency
1018-
* IDs allocated.
1019-
*
1020-
* Track the highest number of allowed concurrency IDs
1021-
* allocated for the mm.
1022-
*/
1023-
atomic_t max_nr_cid;
10241006
/**
10251007
* @cpus_allowed_lock: Lock protecting mm cpus_allowed.
10261008
*
@@ -1371,35 +1353,7 @@ static inline void vma_iter_init(struct vma_iterator *vmi,
13711353

13721354
#ifdef CONFIG_SCHED_MM_CID
13731355

1374-
enum mm_cid_state {
1375-
MM_CID_UNSET = -1U, /* Unset state has lazy_put flag set. */
1376-
MM_CID_LAZY_PUT = (1U << 31),
1377-
};
1378-
1379-
static inline bool mm_cid_is_unset(int cid)
1380-
{
1381-
return cid == MM_CID_UNSET;
1382-
}
1383-
1384-
static inline bool mm_cid_is_lazy_put(int cid)
1385-
{
1386-
return !mm_cid_is_unset(cid) && (cid & MM_CID_LAZY_PUT);
1387-
}
1388-
1389-
static inline bool mm_cid_is_valid(int cid)
1390-
{
1391-
return !(cid & MM_CID_LAZY_PUT);
1392-
}
1393-
1394-
static inline int mm_cid_set_lazy_put(int cid)
1395-
{
1396-
return cid | MM_CID_LAZY_PUT;
1397-
}
1398-
1399-
static inline int mm_cid_clear_lazy_put(int cid)
1400-
{
1401-
return cid & ~MM_CID_LAZY_PUT;
1402-
}
1356+
#define MM_CID_UNSET (~0U)
14031357

14041358
/*
14051359
* mm_cpus_allowed: Union of all mm's threads allowed CPUs.
@@ -1432,11 +1386,8 @@ static inline void mm_init_cid(struct mm_struct *mm, struct task_struct *p)
14321386
struct mm_cid *pcpu_cid = per_cpu_ptr(mm->pcpu_cid, i);
14331387

14341388
pcpu_cid->cid = MM_CID_UNSET;
1435-
pcpu_cid->recent_cid = MM_CID_UNSET;
1436-
pcpu_cid->time = 0;
14371389
}
14381390
mm->nr_cpus_allowed = p->nr_cpus_allowed;
1439-
atomic_set(&mm->max_nr_cid, 0);
14401391
raw_spin_lock_init(&mm->cpus_allowed_lock);
14411392
cpumask_copy(mm_cpus_allowed(mm), &p->cpus_mask);
14421393
cpumask_clear(mm_cidmask(mm));

kernel/fork.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,10 +955,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
955955
#endif
956956

957957
#ifdef CONFIG_SCHED_MM_CID
958-
tsk->mm_cid = -1;
959-
tsk->last_mm_cid = -1;
958+
tsk->mm_cid = MM_CID_UNSET;
959+
tsk->last_mm_cid = MM_CID_UNSET;
960960
tsk->mm_cid_active = 0;
961-
tsk->migrate_from_cpu = -1;
962961
#endif
963962
return tsk;
964963

0 commit comments

Comments
 (0)