sched/deadline: cpuset: Rework DEADLINE bandwidth restoration
Subsystems (3)
Juri Lelli
maintainercover sched/deadline: cpuset: Rework DEADLINE bandwidth restoration
Qais reported [1] that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume). He proposed we skip rebuilding root domains for certain operations, but that approach seemed arch specific and possibly prone to errors, as paths that ultimately trigger a rebuild might be quite convoluted (thanks Qais for spending time on this!).
To fix the problem I instead would propose we
1 - Bring back cpuset_mutex (so that we have write access to cpusets
from scheduler operations - and we also fix some problems associated to percpu_cpuset_rwsem)
2 - Keep track of the number of DEADLINE tasks belonging to each cpuset 3 - Use this information to only perform the costly iteration if
DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt
This set is also available from
https://github.com/jlelli/linux.git deadline/rework-cpusets
Feedback is more than welcome.
Best,
Juri
Juri Lelli (3):
sched/cpuset: Bring back cpuset_mutex sched/cpuset: Keep track of SCHED_DEADLINE task in cpusets cgroup/cpuset: Iterate only if DEADLINE tasks are present
include/linux/cpuset.h | 12 ++- kernel/cgroup/cgroup.c | 4 + kernel/cgroup/cpuset.c | 175 +++++++++++++++++++++++------------------ kernel/sched/core.c | 32 ++++++-- 4 files changed, 137 insertions(+), 86 deletions(-)
Signature · 1 line
2.39.2
Juri Lelli
maintainerRFC PATCH 1/3 sched/cpuset: Bring back cpuset_mutex
Turns out percpu_cpuset_rwsem - commit 1243dc518c9d ("cgroup/cpuset:
Convert cpuset_mutex to percpu_rwsem") - wasn't such a brilliant idea, as it has been reported to cause slowdowns in workloads that need to change cpuset configuration frequently and it is also not implementing priority inheritance (which causes troubles with realtime workloads).
Convert percpu_cpuset_rwsem back to regular cpuset_mutex. Also grab it only for SCHED_DEADLINE tasks (other policies don't care about stable cpusets anyway).
--- include/linux/cpuset.h | 8 +-- kernel/cgroup/cpuset.c | 147 ++++++++++++++++++++--------------------- kernel/sched/core.c | 22 ++++-- 3 files changed, 91 insertions(+), 86 deletions(-)
include/linux/cpuset.h +4 -4
@@ -71,8 +71,8 @@ extern void cpuset_init_smp(void);extern void cpuset_force_rebuild (void );extern void cpuset_update_active_cpus (void );extern void cpuset_wait_for_hotplug (void ); -extern void cpuset_read_lock (void ); -extern void cpuset_read_unlock (void ); +extern void cpuset_lock (void ); +extern void cpuset_unlock (void );extern void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask);extern bool cpuset_cpus_allowed_fallback (struct task_struct *p);extern nodemask_t cpuset_mems_allowed (struct task_struct *p);
@@ -196,8 +196,8 @@ static inline void cpuset_update_active_cpus(void)static inline void cpuset_wait_for_hotplug (void ) { } -static inline void cpuset_read_lock (void ) { } -static inline void cpuset_read_unlock (void ) { } +static inline void cpuset_lock (void ) { } +static inline void cpuset_unlock (void ) { }static inline void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask)
kernel/cgroup/cpuset.c +72 -75
494 lines not on this page · raw message
kernel/sched/core.c +15 -7
@@ -7535,6 +7535,7 @@ static int __sched_setscheduler(struct task_struct *p,int reset_on_fork;int queue_flags =DEQUEUE_SAVE |DEQUEUE_MOVE |DEQUEUE_NOCLOCK ;struct rq *rq; +bool cpuset_locked = false;/* The pi code expects interrupts enabled */ BUG_ON (pi &&in_interrupt ());
@@ -7584,8 +7585,14 @@ static int __sched_setscheduler(struct task_struct *p,return retval; } -if (pi) -cpuset_read_lock (); +/* +* SCHED_DEADLINE bandwidth accounting relies on stable cpusets +* information. +*/ +if (dl_policy (policy) ||dl_policy (p->policy)) { + cpuset_locked = true; +cpuset_lock (); + }/* * Make sure no PI-waiters arrive (or leave) while we are
@@ -7661,8 +7668,8 @@ static int __sched_setscheduler(struct task_struct *p,if (unlikely (oldpolicy !=-1 && oldpolicy != p->policy)) { policy = oldpolicy =-1 ;task_rq_unlock (rq, p, &rf); -if (pi) -cpuset_read_unlock (); +if (cpuset_locked) +cpuset_unlock (); goto recheck; }
@@ -7729,7 +7736,8 @@ static int __sched_setscheduler(struct task_struct *p,task_rq_unlock (rq, p, &rf);if (pi) { -cpuset_read_unlock (); +if (cpuset_locked) +cpuset_unlock ();rt_mutex_adjust_pi (p); }
@@ -7741,8 +7749,8 @@ static int __sched_setscheduler(struct task_struct *p, unlock:task_rq_unlock (rq, p, &rf); -if (pi) -cpuset_read_unlock (); +if (cpuset_locked) +cpuset_unlock ();return retval; }
Signature · 1 line
2.39.2
Juri Lelli
maintainerRFC PATCH 2/3 sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
In reply to Juri LelliQais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
--- include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)
include/linux/cpuset.h +4 -0
@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void);extern void cpuset_force_rebuild (void );extern void cpuset_update_active_cpus (void );extern void cpuset_wait_for_hotplug (void ); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task);extern void cpuset_lock (void );extern void cpuset_unlock (void );extern void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask);
@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void)static inline void cpuset_wait_for_hotplug (void ) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { }static inline void cpuset_lock (void ) { }static inline void cpuset_unlock (void ) { }
kernel/cgroup/cgroup.c +4 -0
@@ -57,6 +57,7 @@#include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h>
@@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk)list_add_tail (&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; +if (dl_task (tsk)) +dec_dl_tasks_cs (tsk); +WARN_ON_ONCE (cgroup_task_frozen (tsk));if (unlikely (!(tsk->flags &PF_KTHREAD ) &&test_bit (CGRP_FREEZE , &task_dfl_cgroup (tsk)->flags)))
kernel/cgroup/cpuset.c +25 -0
@@ -193,6 +193,12 @@ struct cpuset {int use_parent_ecpus;int child_ecpus_count; +/* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we +* know when to rebuild associated root domain bandwidth information. +*/ +int nr_deadline_tasks; +/* Invalid partition error code, not lock protected */ enum prs_errcode prs_err;
@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs)return css_cs (cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks--; +} +/* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,
@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret =security_task_setscheduler (task);if (ret) goto out_unlock; + +if (dl_task (task)) { + cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--; + } }/*
kernel/sched/core.c +10 -0
@@ -7683,6 +7683,16 @@ static int __sched_setscheduler(struct task_struct *p, goto unlock; } +/* +* In case a task is setscheduled to SCHED_DEADLINE, or if a task is +* moved to a different sched policy, we need to keep track of that on +* its cpuset (for correct bandwidth tracking). +*/ +if (dl_policy (policy) && !dl_task (p)) +inc_dl_tasks_cs (p); +else if (dl_task (p) && !dl_policy (policy)) +dec_dl_tasks_cs (p); + p->sched_reset_on_fork = reset_on_fork; oldprio = p->prio;
Signature · 1 line
2.39.2
Re: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
Quoted 81 lines · Juri Lelli
Qais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
Reported-by Qais Yousef <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)include/linux/cpuset.h +4
-0@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void);extern void cpuset_force_rebuild (void );extern void cpuset_update_active_cpus (void );extern void cpuset_wait_for_hotplug (void ); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task);extern void cpuset_lock (void );extern void cpuset_unlock (void );extern void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask);@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void)static inline void cpuset_wait_for_hotplug (void ) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { }static inline void cpuset_lock (void ) { }static inline void cpuset_unlock (void ) { }kernel/cgroup/cgroup.c +4
-0@@ -57,6 +57,7 @@#include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h> @@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk)list_add_tail (&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; +if (dl_task (tsk)) +dec_dl_tasks_cs (tsk); +WARN_ON_ONCE (cgroup_task_frozen (tsk));if (unlikely (!(tsk->flags &PF_KTHREAD ) &&test_bit (CGRP_FREEZE , &task_dfl_cgroup (tsk)->flags)))kernel/cgroup/cpuset.c +6
-0@@ -193,6 +193,12 @@ struct cpuset {int use_parent_ecpus;int child_ecpus_count; +/* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we +* know when to rebuild associated root domain bandwidth information. +*/ +int nr_deadline_tasks; +/* Invalid partition error code, not lock protected */ enum prs_errcode prs_err;
kernel/cgroup/cpuset.c static inline struct cpuset *parent_cs(struct cpuset *cs) · line 256
Quoted 6 lines
kernel/cgroup/cpuset.c +3
-0@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs)return css_cs (cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p);
nit:
I *think* task_cs() assumes rcu_read_lock() is held, right?
Would it make sense to WARN_ON(!rcu_read_lock_held()) to at least annotate the deps?
Or maybe task_cs() should do that..
kernel/cgroup/cpuset.c static inline struct cpuset *parent_cs(struct cpuset *cs) · line 263
Quoted 7 lines
kernel/cgroup/cpuset.c +7
-0+ + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p);
nit: ditto
Quoted 27 lines
kernel/cgroup/cpuset.c +9
-0+ + cs->nr_deadline_tasks--; +} +/* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret =security_task_setscheduler (task);if (ret) goto out_unlock; + +if (dl_task (task)) { + cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--; + } }/* kernel/sched/core.c +0
-0@@ -7683,6 +7683,16 @@ static int __sched_setscheduler(struct task_struct *p, goto unlock; }
kernel/sched/core.c static int __sched_setscheduler(struct task_struct *p, · line 7695
Quoted 10 lines
kernel/sched/core.c +10
-0+/* +* In case a task is setscheduled to SCHED_DEADLINE, or if a task is +* moved to a different sched policy, we need to keep track of that on +* its cpuset (for correct bandwidth tracking). +*/ +if (dl_policy (policy) && !dl_task (p)) +inc_dl_tasks_cs (p); +else if (dl_task (p) && !dl_policy (policy)) +dec_dl_tasks_cs (p); +
Would it be better to use switched_to_dl()/switched_from_dl() instead to inc/dec_dl_tasks_cs()?
Thanks!
Juri Lelli
maintainerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
Quoted 1 line · Qais Yousef
On 03/15/23 12:18, Juri Lelli wrote:
...
Quoted 10 lines
kernel/cgroup/cpuset.c static inline struct cpuset *parent_cs(struct cpuset *cs) · line 256
Quoted 3 lines
kernel/cgroup/cpuset.c +3
-0+void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p);nit:
I *think*
task_cs()assumesrcu_read_lock()is held, right?Would it make sense to WARN_ON(!rcu_read_lock_held()) to at least annotate the deps?
Think we have that check in task_css_set_check()?
Quoted 16 lines
Or maybe
task_cs()should do that..kernel/cgroup/cpuset.c static inline struct cpuset *parent_cs(struct cpuset *cs) · line 263
Quoted 7 lines
kernel/cgroup/cpuset.c +7
-0+ + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p);nit: ditto
Quoted 4 lines
kernel/cgroup/cpuset.c +4
-0+ + cs->nr_deadline_tasks--; +} +
...
Quoted 8 lines
Quoted 8 lines
kernel/sched/core.c +0
-0@@ -7683,6 +7683,16 @@ static int __sched_setscheduler(struct task_struct *p, goto unlock; }
Quoted 13 lines
kernel/sched/core.c static int __sched_setscheduler(struct task_struct *p, · line 7695
Quoted 10 lines
kernel/sched/core.c +10
-0+/* +* In case a task is setscheduled to SCHED_DEADLINE, or if a task is +* moved to a different sched policy, we need to keep track of that on +* its cpuset (for correct bandwidth tracking). +*/ +if (dl_policy (policy) && !dl_task (p)) +inc_dl_tasks_cs (p); +else if (dl_task (p) && !dl_policy (policy)) +dec_dl_tasks_cs (p); +Would it be better to use switched_to_dl()/switched_from_dl() instead to inc/dec_dl_tasks_cs()?
Ah, makes sense. I'll play with this.
Thanks,
Juri
Re: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
Quoted 11 lines · Juri Lelli
Quoted 1 line · Qais Yousef
On 03/15/23 12:18, Juri Lelli wrote:
...
Quoted 6 lines
kernel/cgroup/cpuset.c static inline struct cpuset *parent_cs(struct cpuset *cs) · line 256
Quoted 3 lines
kernel/cgroup/cpuset.c +3
-0+void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p);nit:
Quoted 6 lines
Quoted 4 lines
I *think*
task_cs()assumesrcu_read_lock()is held, right?Would it make sense to WARN_ON(!rcu_read_lock_held()) to at least annotate the deps?
Think we have that check in
task_css_set_check()?
Yes you're right, I didn't go forward enough in the call stack.
It seems to depend on PROVE_RCU, which sounds irrelevant, but I see PROVE_RCU is actually an alias for PROVE_LOCKING.
Cheers
Waiman Long
maintainerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
In reply to Juri LelliQuoted 102 lines · Juri Lelli
Qais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
Reported-by Qais Yousef <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)include/linux/cpuset.h +4
-0@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void);extern void cpuset_force_rebuild (void );extern void cpuset_update_active_cpus (void );extern void cpuset_wait_for_hotplug (void ); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task);extern void cpuset_lock (void );extern void cpuset_unlock (void );extern void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask);@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void)static inline void cpuset_wait_for_hotplug (void ) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { }static inline void cpuset_lock (void ) { }static inline void cpuset_unlock (void ) { }kernel/cgroup/cgroup.c +4
-0@@ -57,6 +57,7 @@#include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h> @@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk)list_add_tail (&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; +if (dl_task (tsk)) +dec_dl_tasks_cs (tsk); +WARN_ON_ONCE (cgroup_task_frozen (tsk));if (unlikely (!(tsk->flags &PF_KTHREAD ) &&test_bit (CGRP_FREEZE , &task_dfl_cgroup (tsk)->flags)))kernel/cgroup/cpuset.c +20
-0@@ -193,6 +193,12 @@ struct cpuset {int use_parent_ecpus;int child_ecpus_count; +/* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we +* know when to rebuild associated root domain bandwidth information. +*/ +int nr_deadline_tasks; +/* Invalid partition error code, not lock protected */ enum prs_errcode prs_err;@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs)return css_cs (cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks--; +} +/* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 9 lines
kernel/cgroup/cpuset.c +5
-0@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret =security_task_setscheduler (task);if (ret) goto out_unlock; + +if (dl_task (task)) { + cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--; + } }
Any one of the tasks in the cpuset can cause the test to fail and abort the attachment. I would suggest that you keep a deadline task transfer count in the loop and then update cs and cpouset_attach_old_cs only after all the tasks have been iterated successfully.
Cheers,
Longman
Juri Lelli
maintainerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
Quoted 102 lines · Waiman Long
Quoted 100 lines · Juri Lelli
Qais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
Reported-by Qais Yousef <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)include/linux/cpuset.h +4
-0@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void);extern void cpuset_force_rebuild (void );extern void cpuset_update_active_cpus (void );extern void cpuset_wait_for_hotplug (void ); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task);extern void cpuset_lock (void );extern void cpuset_unlock (void );extern void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask);@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void)static inline void cpuset_wait_for_hotplug (void ) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { }static inline void cpuset_lock (void ) { }static inline void cpuset_unlock (void ) { }kernel/cgroup/cgroup.c +4
-0@@ -57,6 +57,7 @@#include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h> @@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk)list_add_tail (&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; +if (dl_task (tsk)) +dec_dl_tasks_cs (tsk); +WARN_ON_ONCE (cgroup_task_frozen (tsk));if (unlikely (!(tsk->flags &PF_KTHREAD ) &&test_bit (CGRP_FREEZE , &task_dfl_cgroup (tsk)->flags)))kernel/cgroup/cpuset.c +23
-0@@ -193,6 +193,12 @@ struct cpuset {int use_parent_ecpus;int child_ecpus_count; +/* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we +* know when to rebuild associated root domain bandwidth information. +*/ +int nr_deadline_tasks; +/* Invalid partition error code, not lock protected */ enum prs_errcode prs_err;@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs)return css_cs (cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks--; +} +/* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret =security_task_setscheduler (task);if (ret) goto out_unlock; + +if (dl_task (task)) { + cs->nr_deadline_tasks++;
Quoted 8 lines
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 3 lines
kernel/cgroup/cpuset.c +2
-0+ cpuset_attach_old_cs->nr_deadline_tasks--; + } }Any one of the tasks in the cpuset can cause the test to fail and abort the attachment. I would suggest that you keep a deadline task transfer count in the loop and then update cs and
cpouset_attach_old_csonly after all the tasks have been iterated successfully.
Right, Dietmar I think commented pointing out something along these lines. Think though we already have this problem with current task_can_attach -> dl_cpu_busy which reserves bandwidth for each tasks in the destination cs. Will need to look into that. Do you know which sort of operation would move multiple tasks at once?
Waiman Long
maintainerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
Quoted 109 lines · Juri Lelli
Quoted 100 lines · Waiman Long
Quoted 99 lines · Juri Lelli
Qais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
Reported-by Qais Yousef <[email protected]>Signed-off-by Juri Lelli <[email protected]>--- include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)include/linux/cpuset.h +4
-0@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void);extern void cpuset_force_rebuild (void );extern void cpuset_update_active_cpus (void );extern void cpuset_wait_for_hotplug (void ); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task);extern void cpuset_lock (void );extern void cpuset_unlock (void );extern void cpuset_cpus_allowed (struct task_struct *p,struct cpumask *mask);@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void)static inline void cpuset_wait_for_hotplug (void ) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { }static inline void cpuset_lock (void ) { }static inline void cpuset_unlock (void ) { }kernel/cgroup/cgroup.c +4
-0@@ -57,6 +57,7 @@#include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h> @@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk)list_add_tail (&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; +if (dl_task (tsk)) +dec_dl_tasks_cs (tsk); +WARN_ON_ONCE (cgroup_task_frozen (tsk));if (unlikely (!(tsk->flags &PF_KTHREAD ) &&test_bit (CGRP_FREEZE , &task_dfl_cgroup (tsk)->flags)))kernel/cgroup/cpuset.c +22
-0@@ -193,6 +193,12 @@ struct cpuset {int use_parent_ecpus;int child_ecpus_count; +/* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we +* know when to rebuild associated root domain bandwidth information. +*/ +int nr_deadline_tasks; +/* Invalid partition error code, not lock protected */ enum prs_errcode prs_err;@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs)return css_cs (cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ +struct cpuset *cs =task_cs (p); + + cs->nr_deadline_tasks--; +} +/* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret =security_task_setscheduler (task);if (ret) goto out_unlock; + +if (dl_task (task)) {Quoted 8 lines
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 4 lines
kernel/cgroup/cpuset.c +3
-0+ cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--; + } }Any one of the tasks in the cpuset can cause the test to fail and abort the attachment. I would suggest that you keep a deadline task transfer count in the loop and then update cs and
cpouset_attach_old_csonly after all the tasks have been iterated successfully.
Quoted 5 lines
Right, Dietmar I think commented pointing out something along these lines. Think though we already have this problem with current
task_can_attach->dl_cpu_busywhich reserves bandwidth for each tasks in the destination cs. Will need to look into that. Do you know which sort of operation would move multiple tasks at once?
Actually, what I said previously may not be enough. There can be multiple controllers attached to a cgroup. If any of thier can_attach() calls fails, the whole transaction is aborted and cancel_attach() will be called. My new suggestion is to add a new deadline task transfer count into the cpuset structure and store the information there temporarily. If cpuset_attach() is called, it means all the can_attach calls succeed. You can then update the dl task count accordingly and clear the temporary transfer count.
I guess you may have to do something similar with dl_cpu_busy().
My 2 cents.
Cheers,
Longman
Waiman Long
maintainerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
Quoted 121 lines · Waiman Long
Quoted 113 lines · Juri Lelli
Quoted 104 lines · Waiman Long
Quoted 103 lines · Juri Lelli
Qais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
Reported-by Qais Yousef <[email protected]>Signed-off-by Juri Lelli <[email protected]>---
include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)include/linux/cpuset.h +4
-0@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void); extern void cpuset_force_rebuild(void); extern void cpuset_update_active_cpus(void); extern void cpuset_wait_for_hotplug(void); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task); extern void cpuset_lock(void); extern void cpuset_unlock(void); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void) static inline void cpuset_wait_for_hotplug(void) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { } static inline void cpuset_lock(void) { } static inline void cpuset_unlock(void) { }kernel/cgroup/cgroup.c +4
-0@@ -57,6 +57,7 @@ #include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h>@@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk) list_add_tail(&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; + if (dl_task(tsk)) + dec_dl_tasks_cs(tsk); + WARN_ON_ONCE(cgroup_task_frozen(tsk));if (
unlikely(!(tsk->flags & PF_KTHREAD) && test_bit(CGRP_FREEZE, &task_dfl_cgroup(tsk)->flags)))kernel/cgroup/cpuset.c +2
-0@@ -193,6 +193,12 @@ struct cpuset { int use_parent_ecpus; int child_ecpus_count; + /* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we
+ * know when to rebuild associated root domain bandwidth information.
+ */
+ intnr_deadline_tasks;
+
/* Invalid partition error code, not lock protected */ enumprs_errcodeprs_err;kernel/cgroup/cpuset.c +16
-0@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs) return css_cs(cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ + struct cpuset *cs = task_cs(p); + + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ + struct cpuset *cs = task_cs(p); + + cs->nr_deadline_tasks--; +} + /* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret = security_task_setscheduler(task); if (ret) goto out_unlock; + + if (dl_task(task)) {Quoted 8 lines
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 4 lines
kernel/cgroup/cpuset.c +3
-0+ cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--; + } }Any one of the tasks in the cpuset can cause the test to fail and abort the attachment. I would suggest that you keep a deadline task transfer count in the loop and then update cs and
cpouset_attach_old_csonly after all the tasks have been iterated successfully.Quoted 5 lines
Right, Dietmar I think commented pointing out something along these lines. Think though we already have this problem with current
task_can_attach->dl_cpu_busywhich reserves bandwidth for each tasks in the destination cs. Will need to look into that. Do you know which sort of operation would move multiple tasks at once?
Quoted 5 lines
Actually, what I said previously may not be enough. There can be multiple controllers attached to a cgroup. If any of thier
can_attach()calls fails, the whole transaction is aborted andcancel_attach()will be called. My new suggestion is to add a new deadline task transfer count into the cpuset structure and store the information there temporarily. Ifcpuset_attach()is called, it means all thecan_attachcalls succeed. You can then update the dl task count accordingly and clear the temporary transfer count.I guess you may have to do something similar with
dl_cpu_busy().My 2 cents.
Alternatively, you can do the nr_deadline_tasks update in cpuset_attach(). However, there is an optimization to skip the task iteration if the cpu and memory list haven't changed. You will have to skip that optimization if there are DL tasks in the cpuset.
Cheers,
Longman
Waiman Long
maintainerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
In reply to Waiman LongQuoted 121 lines · Waiman Long
Quoted 113 lines · Juri Lelli
Quoted 104 lines · Waiman Long
Quoted 103 lines · Juri Lelli
Qais reported that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume).
To fix the problem keep track of the number of DEADLINE tasks belonging to each cpuset and then use this information (followup patch) to only perform the above iteration if DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt.
Reported-by Qais Yousef <[email protected]>Signed-off-by Juri Lelli <[email protected]>---
include/linux/cpuset.h | 4 ++++ kernel/cgroup/cgroup.c | 4 ++++ kernel/cgroup/cpuset.c | 25 +++++++++++++++++++++++++ kernel/sched/core.c | 10 ++++++++++ 4 files changed, 43 insertions(+)include/linux/cpuset.h +4
-0@@ -71,6 +71,8 @@ extern void cpuset_init_smp(void); extern void cpuset_force_rebuild(void); extern void cpuset_update_active_cpus(void); extern void cpuset_wait_for_hotplug(void); +extern void inc_dl_tasks_cs (struct task_struct *task); +extern void dec_dl_tasks_cs (struct task_struct *task); extern void cpuset_lock(void); extern void cpuset_unlock(void); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);@@ -196,6 +198,8 @@ static inline void cpuset_update_active_cpus(void) static inline void cpuset_wait_for_hotplug(void) { } +static inline void inc_dl_tasks_cs (struct task_struct *task) { } +static inline void dec_dl_tasks_cs (struct task_struct *task) { } static inline void cpuset_lock(void) { } static inline void cpuset_unlock(void) { }kernel/cgroup/cgroup.c +4
-0@@ -57,6 +57,7 @@ #include <linux/file.h> #include <linux/fs_parser.h> #include <linux/sched/cputime.h> +#include <linux/sched/deadline.h> #include <linux/psi.h> #include <net/sock.h>@@ -6673,6 +6674,9 @@ void cgroup_exit(struct task_struct *tsk) list_add_tail(&tsk->cg_list, &cset->dying_tasks); cset->nr_tasks--; + if (dl_task(tsk)) + dec_dl_tasks_cs(tsk); + WARN_ON_ONCE(cgroup_task_frozen(tsk));if (
unlikely(!(tsk->flags & PF_KTHREAD) && test_bit(CGRP_FREEZE, &task_dfl_cgroup(tsk)->flags)))kernel/cgroup/cpuset.c +2
-0@@ -193,6 +193,12 @@ struct cpuset { int use_parent_ecpus; int child_ecpus_count; + /* +* number of SCHED_DEADLINE tasks attached to this cpuset, so that we
+ * know when to rebuild associated root domain bandwidth information.
+ */
+ intnr_deadline_tasks;
+
/* Invalid partition error code, not lock protected */ enumprs_errcodeprs_err;kernel/cgroup/cpuset.c +16
-0@@ -245,6 +251,20 @@ static inline struct cpuset *parent_cs(struct cpuset *cs) return css_cs(cs->css.parent); } +void inc_dl_tasks_cs (struct task_struct *p) +{ + struct cpuset *cs = task_cs(p); + + cs->nr_deadline_tasks++; +} + +void dec_dl_tasks_cs (struct task_struct *p) +{ + struct cpuset *cs = task_cs(p); + + cs->nr_deadline_tasks--; +} + /* bits in struct cpuset flags field */ typedef enum { CS_ONLINE,@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret = security_task_setscheduler(task); if (ret) goto out_unlock; + + if (dl_task(task)) {Quoted 8 lines
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 4 lines
kernel/cgroup/cpuset.c +3
-0+ cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--; + } }Any one of the tasks in the cpuset can cause the test to fail and abort the attachment. I would suggest that you keep a deadline task transfer count in the loop and then update cs and
cpouset_attach_old_csonly after all the tasks have been iterated successfully.Quoted 5 lines
Right, Dietmar I think commented pointing out something along these lines. Think though we already have this problem with current
task_can_attach->dl_cpu_busywhich reserves bandwidth for each tasks in the destination cs. Will need to look into that. Do you know which sort of operation would move multiple tasks at once?
Quoted 3 lines
Actually, what I said previously may not be enough. There can be multiple controllers attached to a cgroup. If any of thier
can_attach()calls fails, the whole transaction is aborted andcancel_attach()will be called. My new suggestion is to add a new deadline task transfer count into the cpuset structure and store the information there temporarily. Ifcpuset_attach()is called, it means all thecan_attachcalls succeed. You can then update the dl task count accordingly and clear the temporary transfer count.I guess you may have to do something similar with
dl_cpu_busy().
Another possibility is that you may record the cpu where the new DL bandwidth is allocated from in the task_struct. Then in cpuset_cancel_attach(), you can revert the dl_cpu_busy() change if DL tasks are in the css_set to be transferred. That will likely require having a DL task transfer count in the cpuset and iterating all the tasks to look for ones with a previously recorded cpu # if the transfer count is non-zero.
Cheers,
Longman
Dietmar Eggemann
reviewerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
In reply to Waiman LongQuoted 4 lines · Waiman Long
Quoted 2 lines · Juri Lelli
Quoted 1 line · Waiman Long
On 3/15/23 08:18, Juri Lelli wrote:
[...]
Quoted 32 lines
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
kernel/cgroup/cpuset.c +4
-0@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret = security_task_setscheduler(task); if (ret) goto out_unlock; + + if (dl_task(task)) { + cs->nr_deadline_tasks++; + cpuset_attach_old_cs->nr_deadline_tasks--;Quoted 8 lines
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 2 lines
kernel/cgroup/cpuset.c +1
-0+ } }Any one of the tasks in the cpuset can cause the test to fail and abort the
attachment. I would suggest that you keep a deadline task transfer count in
the loop and then update cs andcpouset_attach_old_csonly after all the tasks have been iterated successfully.Quoted 5 lines
Right, Dietmar I think commented pointing out something along these lines. Think though we already have this problem with current
task_can_attach->dl_cpu_busywhich reserves bandwidth for each tasks in the destination cs. Will need to look into that. Do you know which sort of operation would move multiple tasks at once?Actually, what I said previously may not be enough. There can be multiple controllers attached to a cgroup. If any of thier
can_attach()calls fails, the whole transaction is aborted andcancel_attach()will be called. My new suggestion is to add a new deadline task transfer count into the cpuset structure and store the information there temporarily. Ifcpuset_attach()is called, it means all thecan_attachcalls succeed. You can then update the dl task count accordingly and clear the temporary transfer count.
Quoted 1 line
I guess you may have to do something similar with
dl_cpu_busy().
I gave it a shot:
https://lkml.kernel.org/r/20230322135959.1998790-1-dietmar.eggemann-5wv7dgnIgG8@public.gmane.org
Dietmar Eggemann
reviewerRe: [RFC PATCH 2/3] sched/cpuset: Keep track of SCHED_DEADLINE tasks in cpusets
In reply to Juri LelliQuoted 3 lines · Juri Lelli
Quoted 2 lines · Waiman Long
On 3/15/23 08:18, Juri Lelli wrote:
[...]
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
kernel/cgroup/cpuset.c +3
-0@@ -2472,6 +2492,11 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) ret =security_task_setscheduler (task);if (ret) goto out_unlock; + +if (dl_task (task)) { + cs->nr_deadline_tasks++;Quoted 8 lines
kernel/cgroup/cpuset.c static int cpuset_can_attach(struct cgroup_taskset *tset) · line 2500
Quoted 3 lines
kernel/cgroup/cpuset.c +2
-0+ cpuset_attach_old_cs->nr_deadline_tasks--; + } }Any one of the tasks in the cpuset can cause the test to fail and abort the attachment. I would suggest that you keep a deadline task transfer count in the loop and then update cs and
cpouset_attach_old_csonly after all the tasks have been iterated successfully.
Quoted 5 lines
Right, Dietmar I think commented pointing out something along these lines. Think though we already have this problem with current
task_can_attach->dl_cpu_busywhich reserves bandwidth for each tasks in the destination cs. Will need to look into that. Do you know which sort of operation would move multiple tasks at once?
Moving the process instead of the individual tasks makes cpuset_can_attach() have to deal with multiple tasks.
# ps2 | grep DLN 1614 1615 140 0 - DLN thread0-0 1614 1616 140 0 - DLN thread0-1 1614 1617 140 0 - DLN thread0-2
# echo 1614 > /sys/fs/cgroup/cpuset/cs2/cgroup.procs
Juri Lelli
maintainerRFC PATCH 3/3 cgroup/cpuset: Iterate only if DEADLINE tasks are present
In reply to Juri Lelliupdate_tasks_root_domain currently iterates over all tasks even if no DEADLINE task is present on the cpuset/root domain for which bandwidth accounting is being rebuilt. This has been reported to introduce 10+ ms delays on suspend-resume operations.
Skip the costly iteration for cpusets that don't contain DEADLINE tasks.
--- kernel/cgroup/cpuset.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/cgroup/cpuset.c +3 -0
@@ -1090,6 +1090,9 @@ static void update_tasks_root_domain(struct cpuset *cs)struct css_task_iter it;struct task_struct *task; +if (cs->nr_deadline_tasks ==0 ) +return ; +css_task_iter_start (&cs->css,0 , &it);while ((task =css_task_iter_next (&it)))
Signature · 1 line
2.39.2
Quoted 7 lines · Juri Lelli
Qais reported [1] that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume). He proposed we skip rebuilding root domains for certain operations, but that approach seemed arch specific and possibly prone to errors, as paths that ultimately trigger a rebuild might be quite convoluted (thanks Qais for spending time on this!).
Thanks a lot for this! And sorry I couldn't provide something better.
Quoted 10 lines
To fix the problem I instead would propose we
1 - Bring back
cpuset_mutex(so that we have write access to cpusets
from scheduler operations - and we also fix some problems associated topercpu_cpuset_rwsem)
2 - Keep track of the number of DEADLINE tasks belonging to each cpuset 3 - Use this information to only perform the costly iteration if
DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt
nit:
Would you consider adding another patch to rename the functions? rebuild_root_domains() and update_tasks_root_domain() are deadline accounting specific functions and don't actually rebuild root domains.
Thanks!
Juri Lelli
maintainerQuoted 10 lines · Qais Yousef
Quoted 7 lines · Juri Lelli
Qais reported [1] that iterating over all tasks when rebuilding root domains for finding out which ones are DEADLINE and need their bandwidth correctly restored on such root domains can be a costly operation (10+ ms delays on suspend-resume). He proposed we skip rebuilding root domains for certain operations, but that approach seemed arch specific and possibly prone to errors, as paths that ultimately trigger a rebuild might be quite convoluted (thanks Qais for spending time on this!).
Thanks a lot for this! And sorry I couldn't provide something better.
Ah, no worries. Actually still have to convice myself what I have it's actually better. :)
Quoted 11 lines
Quoted 10 lines
To fix the problem I instead would propose we
1 - Bring back
cpuset_mutex(so that we have write access to cpusets
from scheduler operations - and we also fix some problems associated topercpu_cpuset_rwsem)
2 - Keep track of the number of DEADLINE tasks belonging to each cpuset 3 - Use this information to only perform the costly iteration if
DEADLINE tasks are actually present in the cpuset for which a corresponding root domain is being rebuilt
Quoted 5 lines
nit:
Would you consider adding another patch to rename the functions?
rebuild_root_domains()andupdate_tasks_root_domain()are deadline accounting specific functions and don't actually rebuild root domains.
Yep, can do.
Thanks,
Juri