* [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotp @ 2016-08-30 13:09 ` Jeehong Kim 0 siblings, 0 replies; 10+ messages in thread From: Jeehong Kim @ 2016-08-30 13:09 UTC (permalink / raw) To: mingo; +Cc: peterz, linux-kernel, kernel-janitors, ezjjilong, Jeehong Kim In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on and tasks in bandwidth controlled task group run on hotplug core, the tasks are not controlled by cfs_b->quota when hotplug core is offline and then online. The remaining tasks in task group consume all of cfs_b->quota on other cores. The cause of this problem is described as below: 1. When hotplug core is offline while tasks in task group run on hotplug core, unregister_fair_sched_group() deletes leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. 2. Then, when hotplug core is online, update_runtime_enabled() registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq on runqueue. However, because this is before enqueue_entity() adds &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, cfs->quota is not register on cfs_rq->runtime_enabled. To resolve this problem, this patch makes update_runtime_enabled() registers cfs_b->quota by using walk_tg_tree_from(). Signed-off-by: Jeehong Kim <jhez.kim@samsung.com> --- kernel/sched/fair.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6488815..63b376d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4373,17 +4373,27 @@ static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b) hrtimer_cancel(&cfs_b->slack_timer); } -static void __maybe_unused update_runtime_enabled(struct rq *rq) +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) { - struct cfs_rq *cfs_rq; + struct rq *rq = data; + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; - for_each_leaf_cfs_rq(rq, cfs_rq) { - struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; + raw_spin_lock(&cfs_b->lock); + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; + raw_spin_unlock(&cfs_b->lock); - raw_spin_lock(&cfs_b->lock); - cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; - raw_spin_unlock(&cfs_b->lock); - } + return 0; +} + +static void __maybe_unused update_runtime_enabled(struct rq *rq) +{ + struct cfs_rq *cfs_rq = &rq->cfs; + + /* register cfs_b->quota on the whole tg tree */ + rcu_read_lock(); + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); + rcu_read_unlock(); } -- ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online. @ 2016-08-30 13:09 ` Jeehong Kim 0 siblings, 0 replies; 10+ messages in thread From: Jeehong Kim @ 2016-08-30 13:09 UTC (permalink / raw) To: mingo; +Cc: peterz, linux-kernel, kernel-janitors, ezjjilong, Jeehong Kim In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on and tasks in bandwidth controlled task group run on hotplug core, the tasks are not controlled by cfs_b->quota when hotplug core is offline and then online. The remaining tasks in task group consume all of cfs_b->quota on other cores. The cause of this problem is described as below: 1. When hotplug core is offline while tasks in task group run on hotplug core, unregister_fair_sched_group() deletes leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. 2. Then, when hotplug core is online, update_runtime_enabled() registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq on runqueue. However, because this is before enqueue_entity() adds &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, cfs->quota is not register on cfs_rq->runtime_enabled. To resolve this problem, this patch makes update_runtime_enabled() registers cfs_b->quota by using walk_tg_tree_from(). Signed-off-by: Jeehong Kim <jhez.kim@samsung.com> --- kernel/sched/fair.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6488815..63b376d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4373,17 +4373,27 @@ static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b) hrtimer_cancel(&cfs_b->slack_timer); } -static void __maybe_unused update_runtime_enabled(struct rq *rq) +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) { - struct cfs_rq *cfs_rq; + struct rq *rq = data; + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; - for_each_leaf_cfs_rq(rq, cfs_rq) { - struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; + raw_spin_lock(&cfs_b->lock); + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; + raw_spin_unlock(&cfs_b->lock); - raw_spin_lock(&cfs_b->lock); - cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; - raw_spin_unlock(&cfs_b->lock); - } + return 0; +} + +static void __maybe_unused update_runtime_enabled(struct rq *rq) +{ + struct cfs_rq *cfs_rq = &rq->cfs; + + /* register cfs_b->quota on the whole tg tree */ + rcu_read_lock(); + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); + rcu_read_unlock(); } -- ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotp @ 2016-08-30 13:12 ` Jeehong Kim 0 siblings, 0 replies; 10+ messages in thread From: Jeehong Kim @ 2016-08-30 13:12 UTC (permalink / raw) To: mingo; +Cc: peterz, linux-kernel, kernel-janitors, ezjjilong, Jeehong Kim In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on and tasks in bandwidth controlled task group run on hotplug core, the tasks are not controlled by cfs_b->quota when hotplug core is offline and then online. The remaining tasks in task group consume all of cfs_b->quota on other cores. The cause of this problem is described as below: 1. When hotplug core is offline while tasks in task group run on hotplug core, unregister_fair_sched_group() deletes leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. 2. Then, when hotplug core is online, update_runtime_enabled() registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq on runqueue. However, because this is before enqueue_entity() adds &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, cfs->quota is not register on cfs_rq->runtime_enabled. To resolve this problem, this patch makes update_runtime_enabled() registers cfs_b->quota by using walk_tg_tree_from(). Signed-off-by: Jeehong Kim <jhez.kim@samsung.com> --- V2: update_runtime_enabled() walks the whole tg tree, instead of register quota on every enqueue. kernel/sched/fair.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6488815..63b376d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4373,17 +4373,27 @@ static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b) hrtimer_cancel(&cfs_b->slack_timer); } -static void __maybe_unused update_runtime_enabled(struct rq *rq) +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) { - struct cfs_rq *cfs_rq; + struct rq *rq = data; + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; - for_each_leaf_cfs_rq(rq, cfs_rq) { - struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; + raw_spin_lock(&cfs_b->lock); + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; + raw_spin_unlock(&cfs_b->lock); - raw_spin_lock(&cfs_b->lock); - cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; - raw_spin_unlock(&cfs_b->lock); - } + return 0; +} + +static void __maybe_unused update_runtime_enabled(struct rq *rq) +{ + struct cfs_rq *cfs_rq = &rq->cfs; + + /* register cfs_b->quota on the whole tg tree */ + rcu_read_lock(); + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); + rcu_read_unlock(); } -- ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online. @ 2016-08-30 13:12 ` Jeehong Kim 0 siblings, 0 replies; 10+ messages in thread From: Jeehong Kim @ 2016-08-30 13:12 UTC (permalink / raw) To: mingo; +Cc: peterz, linux-kernel, kernel-janitors, ezjjilong, Jeehong Kim In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on and tasks in bandwidth controlled task group run on hotplug core, the tasks are not controlled by cfs_b->quota when hotplug core is offline and then online. The remaining tasks in task group consume all of cfs_b->quota on other cores. The cause of this problem is described as below: 1. When hotplug core is offline while tasks in task group run on hotplug core, unregister_fair_sched_group() deletes leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. 2. Then, when hotplug core is online, update_runtime_enabled() registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq on runqueue. However, because this is before enqueue_entity() adds &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, cfs->quota is not register on cfs_rq->runtime_enabled. To resolve this problem, this patch makes update_runtime_enabled() registers cfs_b->quota by using walk_tg_tree_from(). Signed-off-by: Jeehong Kim <jhez.kim@samsung.com> --- V2: update_runtime_enabled() walks the whole tg tree, instead of register quota on every enqueue. kernel/sched/fair.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6488815..63b376d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4373,17 +4373,27 @@ static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b) hrtimer_cancel(&cfs_b->slack_timer); } -static void __maybe_unused update_runtime_enabled(struct rq *rq) +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) { - struct cfs_rq *cfs_rq; + struct rq *rq = data; + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; - for_each_leaf_cfs_rq(rq, cfs_rq) { - struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; + raw_spin_lock(&cfs_b->lock); + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; + raw_spin_unlock(&cfs_b->lock); - raw_spin_lock(&cfs_b->lock); - cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; - raw_spin_unlock(&cfs_b->lock); - } + return 0; +} + +static void __maybe_unused update_runtime_enabled(struct rq *rq) +{ + struct cfs_rq *cfs_rq = &rq->cfs; + + /* register cfs_b->quota on the whole tg tree */ + rcu_read_lock(); + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); + rcu_read_unlock(); } -- ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when 2016-08-30 13:12 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Jeehong Kim @ 2016-09-01 11:01 ` Peter Zijlstra -1 siblings, 0 replies; 10+ messages in thread From: Peter Zijlstra @ 2016-09-01 11:01 UTC (permalink / raw) To: Jeehong Kim; +Cc: mingo, linux-kernel, kernel-janitors, ezjjilong, Ben Segall You forgot to Cc Ben, who gave you feedback on v1, which is rather poor style. Also, I don't see how kernel-janitors is relevant to this patch. This is very much not a janitorial thing. (also, why send it twice?) On Tue, Aug 30, 2016 at 10:12:40PM +0900, Jeehong Kim wrote: > In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on > and tasks in bandwidth controlled task group run on hotplug core, > the tasks are not controlled by cfs_b->quota when hotplug core is offline > and then online. The remaining tasks in task group consume all of > cfs_b->quota on other cores. > > The cause of this problem is described as below: > > 1. When hotplug core is offline while tasks in task group run > on hotplug core, unregister_fair_sched_group() deletes > leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. > > 2. Then, when hotplug core is online, update_runtime_enabled() > registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq > on runqueue. However, because this is before enqueue_entity() adds > &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, > cfs->quota is not register on cfs_rq->runtime_enabled. > > To resolve this problem, this patch makes update_runtime_enabled() > registers cfs_b->quota by using walk_tg_tree_from(). > +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) > { > + struct rq *rq = data; > + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; > + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; > > + raw_spin_lock(&cfs_b->lock); > + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; > + raw_spin_unlock(&cfs_b->lock); > > + return 0; > +} > + > +static void __maybe_unused update_runtime_enabled(struct rq *rq) > +{ > + struct cfs_rq *cfs_rq = &rq->cfs; > + > + /* register cfs_b->quota on the whole tg tree */ > + rcu_read_lock(); > + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); > + rcu_read_unlock(); > } Looks ok, performance on hotplug doesn't really matter. Ben, you happy with this? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online. @ 2016-09-01 11:01 ` Peter Zijlstra 0 siblings, 0 replies; 10+ messages in thread From: Peter Zijlstra @ 2016-09-01 11:01 UTC (permalink / raw) To: Jeehong Kim; +Cc: mingo, linux-kernel, kernel-janitors, ezjjilong, Ben Segall You forgot to Cc Ben, who gave you feedback on v1, which is rather poor style. Also, I don't see how kernel-janitors is relevant to this patch. This is very much not a janitorial thing. (also, why send it twice?) On Tue, Aug 30, 2016 at 10:12:40PM +0900, Jeehong Kim wrote: > In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on > and tasks in bandwidth controlled task group run on hotplug core, > the tasks are not controlled by cfs_b->quota when hotplug core is offline > and then online. The remaining tasks in task group consume all of > cfs_b->quota on other cores. > > The cause of this problem is described as below: > > 1. When hotplug core is offline while tasks in task group run > on hotplug core, unregister_fair_sched_group() deletes > leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. > > 2. Then, when hotplug core is online, update_runtime_enabled() > registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq > on runqueue. However, because this is before enqueue_entity() adds > &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, > cfs->quota is not register on cfs_rq->runtime_enabled. > > To resolve this problem, this patch makes update_runtime_enabled() > registers cfs_b->quota by using walk_tg_tree_from(). > +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) > { > + struct rq *rq = data; > + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; > + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; > > + raw_spin_lock(&cfs_b->lock); > + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; > + raw_spin_unlock(&cfs_b->lock); > > + return 0; > +} > + > +static void __maybe_unused update_runtime_enabled(struct rq *rq) > +{ > + struct cfs_rq *cfs_rq = &rq->cfs; > + > + /* register cfs_b->quota on the whole tg tree */ > + rcu_read_lock(); > + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); > + rcu_read_unlock(); > } Looks ok, performance on hotplug doesn't really matter. Ben, you happy with this? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when 2016-09-01 11:01 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Peter Zijlstra @ 2016-09-01 11:52 ` Jeehong Kim -1 siblings, 0 replies; 10+ messages in thread From: Jeehong Kim @ 2016-09-01 11:52 UTC (permalink / raw) To: Peter Zijlstra Cc: mingo, linux-kernel, kernel-janitors, ezjjilong, Ben Segall Hello, First of all, thanks for review. And I am sorry that I forgot to CC Ben. The reason why I sent last mail twice is that I forgot including the comments for changes from PATCH V1. Thanks and BR. On 2016년 09월 01일 20:01, Peter Zijlstra wrote: > You forgot to Cc Ben, who gave you feedback on v1, which is rather poor > style. Also, I don't see how kernel-janitors is relevant to this patch. > This is very much not a janitorial thing. > > (also, why send it twice?) > > On Tue, Aug 30, 2016 at 10:12:40PM +0900, Jeehong Kim wrote: >> In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on >> and tasks in bandwidth controlled task group run on hotplug core, >> the tasks are not controlled by cfs_b->quota when hotplug core is offline >> and then online. The remaining tasks in task group consume all of >> cfs_b->quota on other cores. >> >> The cause of this problem is described as below: >> >> 1. When hotplug core is offline while tasks in task group run >> on hotplug core, unregister_fair_sched_group() deletes >> leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. >> >> 2. Then, when hotplug core is online, update_runtime_enabled() >> registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq >> on runqueue. However, because this is before enqueue_entity() adds >> &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, >> cfs->quota is not register on cfs_rq->runtime_enabled. >> >> To resolve this problem, this patch makes update_runtime_enabled() >> registers cfs_b->quota by using walk_tg_tree_from(). > >> +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) >> { >> + struct rq *rq = data; >> + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; >> + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; >> >> + raw_spin_lock(&cfs_b->lock); >> + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; >> + raw_spin_unlock(&cfs_b->lock); >> >> + return 0; >> +} >> + >> +static void __maybe_unused update_runtime_enabled(struct rq *rq) >> +{ >> + struct cfs_rq *cfs_rq = &rq->cfs; >> + >> + /* register cfs_b->quota on the whole tg tree */ >> + rcu_read_lock(); >> + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); >> + rcu_read_unlock(); >> } > Looks ok, performance on hotplug doesn't really matter. Ben, you happy > with this? > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online. @ 2016-09-01 11:52 ` Jeehong Kim 0 siblings, 0 replies; 10+ messages in thread From: Jeehong Kim @ 2016-09-01 11:52 UTC (permalink / raw) To: Peter Zijlstra Cc: mingo, linux-kernel, kernel-janitors, ezjjilong, Ben Segall Hello, First of all, thanks for review. And I am sorry that I forgot to CC Ben. The reason why I sent last mail twice is that I forgot including the comments for changes from PATCH V1. Thanks and BR. On 2016년 09월 01일 20:01, Peter Zijlstra wrote: > You forgot to Cc Ben, who gave you feedback on v1, which is rather poor > style. Also, I don't see how kernel-janitors is relevant to this patch. > This is very much not a janitorial thing. > > (also, why send it twice?) > > On Tue, Aug 30, 2016 at 10:12:40PM +0900, Jeehong Kim wrote: >> In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on >> and tasks in bandwidth controlled task group run on hotplug core, >> the tasks are not controlled by cfs_b->quota when hotplug core is offline >> and then online. The remaining tasks in task group consume all of >> cfs_b->quota on other cores. >> >> The cause of this problem is described as below: >> >> 1. When hotplug core is offline while tasks in task group run >> on hotplug core, unregister_fair_sched_group() deletes >> leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. >> >> 2. Then, when hotplug core is online, update_runtime_enabled() >> registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq >> on runqueue. However, because this is before enqueue_entity() adds >> &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, >> cfs->quota is not register on cfs_rq->runtime_enabled. >> >> To resolve this problem, this patch makes update_runtime_enabled() >> registers cfs_b->quota by using walk_tg_tree_from(). > >> +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) >> { >> + struct rq *rq = data; >> + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; >> + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; >> >> + raw_spin_lock(&cfs_b->lock); >> + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; >> + raw_spin_unlock(&cfs_b->lock); >> >> + return 0; >> +} >> + >> +static void __maybe_unused update_runtime_enabled(struct rq *rq) >> +{ >> + struct cfs_rq *cfs_rq = &rq->cfs; >> + >> + /* register cfs_b->quota on the whole tg tree */ >> + rcu_read_lock(); >> + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); >> + rcu_read_unlock(); >> } > Looks ok, performance on hotplug doesn't really matter. Ben, you happy > with this? > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when 2016-09-01 11:01 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Peter Zijlstra @ 2016-09-01 17:23 ` bsegall -1 siblings, 0 replies; 10+ messages in thread From: bsegall @ 2016-09-01 17:23 UTC (permalink / raw) To: Peter Zijlstra Cc: Jeehong Kim, mingo, linux-kernel, kernel-janitors, ezjjilong Peter Zijlstra <peterz@infradead.org> writes: > You forgot to Cc Ben, who gave you feedback on v1, which is rather poor > style. Also, I don't see how kernel-janitors is relevant to this patch. > This is very much not a janitorial thing. > > (also, why send it twice?) > > On Tue, Aug 30, 2016 at 10:12:40PM +0900, Jeehong Kim wrote: >> In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on >> and tasks in bandwidth controlled task group run on hotplug core, >> the tasks are not controlled by cfs_b->quota when hotplug core is offline >> and then online. The remaining tasks in task group consume all of >> cfs_b->quota on other cores. >> >> The cause of this problem is described as below: >> >> 1. When hotplug core is offline while tasks in task group run >> on hotplug core, unregister_fair_sched_group() deletes >> leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. >> >> 2. Then, when hotplug core is online, update_runtime_enabled() >> registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq >> on runqueue. However, because this is before enqueue_entity() adds >> &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, >> cfs->quota is not register on cfs_rq->runtime_enabled. >> >> To resolve this problem, this patch makes update_runtime_enabled() >> registers cfs_b->quota by using walk_tg_tree_from(). > > >> +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) >> { >> + struct rq *rq = data; >> + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; >> + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; >> >> + raw_spin_lock(&cfs_b->lock); >> + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; >> + raw_spin_unlock(&cfs_b->lock); >> >> + return 0; >> +} >> + >> +static void __maybe_unused update_runtime_enabled(struct rq *rq) >> +{ >> + struct cfs_rq *cfs_rq = &rq->cfs; >> + >> + /* register cfs_b->quota on the whole tg tree */ >> + rcu_read_lock(); >> + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); >> + rcu_read_unlock(); >> } > > Looks ok, performance on hotplug doesn't really matter. Ben, you happy > with this? I'm not 100% sure about the exact timings and mechanics of hotplug, but cfs-bandwidth wise this is ok. We may still have runtime_remaining = 1, or we may have < 0 and yet be unthrottled, but either case is ok, even if hotplug allows tasks to have migrated here already (I'm not sure, looking at the code). Now that I check again you can just loop over the list of tgs rather than the hierarchical walk_tg_tree_from, but there's certainly no harm in it. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online. @ 2016-09-01 17:23 ` bsegall 0 siblings, 0 replies; 10+ messages in thread From: bsegall @ 2016-09-01 17:23 UTC (permalink / raw) To: Peter Zijlstra Cc: Jeehong Kim, mingo, linux-kernel, kernel-janitors, ezjjilong Peter Zijlstra <peterz@infradead.org> writes: > You forgot to Cc Ben, who gave you feedback on v1, which is rather poor > style. Also, I don't see how kernel-janitors is relevant to this patch. > This is very much not a janitorial thing. > > (also, why send it twice?) > > On Tue, Aug 30, 2016 at 10:12:40PM +0900, Jeehong Kim wrote: >> In case that CONFIG_HOTPLUG_CPU and CONFIG_CFS_BANDWIDTH is turned on >> and tasks in bandwidth controlled task group run on hotplug core, >> the tasks are not controlled by cfs_b->quota when hotplug core is offline >> and then online. The remaining tasks in task group consume all of >> cfs_b->quota on other cores. >> >> The cause of this problem is described as below: >> >> 1. When hotplug core is offline while tasks in task group run >> on hotplug core, unregister_fair_sched_group() deletes >> leaf_cfs_rq_list of tg->cfs_rq[cpu] from &rq_of(cfs_rq)->leaf_cfs_rq_list. >> >> 2. Then, when hotplug core is online, update_runtime_enabled() >> registers cfs_b->quota on cfs_rq->runtime_enabled of all leaf cfs_rq >> on runqueue. However, because this is before enqueue_entity() adds >> &cfs_rq->leaf_cfs_rq_list on &rq_of(cfs_rq)->leaf_cfs_rq_list, >> cfs->quota is not register on cfs_rq->runtime_enabled. >> >> To resolve this problem, this patch makes update_runtime_enabled() >> registers cfs_b->quota by using walk_tg_tree_from(). > > >> +static int __maybe_unused __update_runtime_enabled(struct task_group *tg, void *data) >> { >> + struct rq *rq = data; >> + struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; >> + struct cfs_bandwidth *cfs_b = &cfs_rq->tg->cfs_bandwidth; >> >> + raw_spin_lock(&cfs_b->lock); >> + cfs_rq->runtime_enabled = cfs_b->quota != RUNTIME_INF; >> + raw_spin_unlock(&cfs_b->lock); >> >> + return 0; >> +} >> + >> +static void __maybe_unused update_runtime_enabled(struct rq *rq) >> +{ >> + struct cfs_rq *cfs_rq = &rq->cfs; >> + >> + /* register cfs_b->quota on the whole tg tree */ >> + rcu_read_lock(); >> + walk_tg_tree_from(cfs_rq->tg, __update_runtime_enabled, tg_nop, (void *)rq); >> + rcu_read_unlock(); >> } > > Looks ok, performance on hotplug doesn't really matter. Ben, you happy > with this? I'm not 100% sure about the exact timings and mechanics of hotplug, but cfs-bandwidth wise this is ok. We may still have runtime_remaining = 1, or we may have < 0 and yet be unthrottled, but either case is ok, even if hotplug allows tasks to have migrated here already (I'm not sure, looking at the code). Now that I check again you can just loop over the list of tgs rather than the hierarchical walk_tg_tree_from, but there's certainly no harm in it. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-09-01 21:14 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-08-30 13:09 [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotp Jeehong Kim 2016-08-30 13:09 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Jeehong Kim 2016-08-30 13:12 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotp Jeehong Kim 2016-08-30 13:12 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Jeehong Kim 2016-09-01 11:01 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when Peter Zijlstra 2016-09-01 11:01 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Peter Zijlstra 2016-09-01 11:52 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when Jeehong Kim 2016-09-01 11:52 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online Jeehong Kim 2016-09-01 17:23 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when bsegall 2016-09-01 17:23 ` [PATCH V2] sched/fair: Fix that tasks are not constrained by cfs_b->quota on hotplug core, when hotplug core is offline and then online bsegall
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.