Skip to contentSkip to conversation

sched/deadline: don't need to check throttled status when switched to dl

PATCH In review Wanpeng Li 2 participants 5 messages Mar 17, 2015 – Mar 27, 2015 Scheduler

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH v3 1/2 sched/deadline: don't need to check throttled status when switched to dl

After commit 40767b0dc768 ("sched/deadline: Fix deadline parameter modification handling") is merged, deadline task throttled status is cleared each time once switch from dl class, so throttled status always doesn't set when switch back, there is no need to check throttled status, this patch drop the check.

---
v2 -> v3:
* update changelog

 kernel/sched/deadline.c | 8 --------
 1 file changed, 8 deletions(-)
kernel/sched/deadline.c +0 -8
index 27b9381..eed6529 100644
@@ -1722,14 +1722,6 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 {
 	int check_resched = 1;
 
-	/*
-	 * If p is throttled, don't consider the possibility
-	 * of preempting rq->curr, the check will be done right
-	 * after its runtime will get replenished.
-	 */
-	if (unlikely(p->dl.dl_throttled))
-		return;
-
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
 		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 2/2 sched/deadline: fix rt runtime corrupt when dl refuse a smaller bandwidth

Dl class will refuse the bandwidth to be set to some value smaller than the current allocated bandwidth in any of the root_domains through sched_rt_runtime_us and sched_rt_period_us. RT runtime will be set according to sched_rt_runtime_us before dl class verify if the new bandwidth is suitable in the case of !CONFIG_RT_GROUP_SCHED.

However, rt runtime will be corrupted if dl refuse the new bandwidth since there is no undo to reset the rt runtime to the old value.

This patch fix it by verifying new bandwidth for deadline in advance.

---
v2 -> v3:
* update changelog

 kernel/sched/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +3 -3
index 97fe79c..e884909 100644
@@ -7815,7 +7815,7 @@ static int sched_rt_global_constraints(void)
 }
 #endif /* CONFIG_RT_GROUP_SCHED */
 
-static int sched_dl_global_constraints(void)
+static int sched_dl_global_validate(void)
 {
 	u64 runtime = global_rt_runtime();
 	u64 period = global_rt_period();
@@ -7916,11 +7916,11 @@ int sched_rt_handler(struct ctl_table *table, int write,
 		if (ret)
 			goto undo;
 
-		ret = sched_rt_global_constraints();
+		ret = sched_dl_global_validate();
 		if (ret)
 			goto undo;
 
-		ret = sched_dl_global_constraints();
+		ret = sched_rt_global_constraints();
 		if (ret)
 			goto undo;
 
Signature · 1 line
1.9.1
#2 lore raw

[tip:sched/core] sched/deadline: Fix rt runtime corruption when dl fails its global constraints

sched/deadline: Fix rt runtime corruption when dl fails its global constraints
Commit-ID:  a1963b81deec54c113e770b0020e5f1c3188a087
Gitweb:     http://git.kernel.org/tip/a1963b81deec54c113e770b0020e5f1c3188a087
Author:     Wanpeng Li <[email protected]>
AuthorDate: Tue, 17 Mar 2015 19:15:31 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 27 Mar 2015 09:36:15 +0100

sched/deadline: Fix rt runtime corruption when dl fails its global constraints

One version of sched_rt_global_constaints() (the !rt-cgroup one) changes state, therefore if we fail the later sched_dl_global_constraints() call the state is left in an inconsistent state.

Fix this by changing the order of the calls.

---
 kernel/sched/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +3 -3
index 043e2a1..4b3b688 100644
@@ -7804,7 +7804,7 @@ static int sched_rt_global_constraints(void)
 }
 #endif /* CONFIG_RT_GROUP_SCHED */
 
-static int sched_dl_global_constraints(void)
+static int sched_dl_global_validate(void)
 {
 	u64 runtime = global_rt_runtime();
 	u64 period = global_rt_period();
@@ -7905,11 +7905,11 @@ int sched_rt_handler(struct ctl_table *table, int write,
 		if (ret)
 			goto undo;
 
-		ret = sched_rt_global_constraints();
+		ret = sched_dl_global_validate();
 		if (ret)
 			goto undo;
 
-		ret = sched_dl_global_constraints();
+		ret = sched_rt_global_constraints();
 		if (ret)
 			goto undo;
 
author
#3 lore raw
In reply to Wanpeng Li

Hi Ingo, how about these three patches this time, sorry for my bad english.

Quoted 36 lines · Wanpeng Li

After commit 40767b0dc768 ("sched/deadline: Fix deadline parameter modification handling") is merged, deadline task throttled status is cleared each time once switch from dl class, so throttled status always doesn't set when switch back, there is no need to check throttled status, this patch drop the check.

---
v2 -> v3:
* update changelog

kernel/sched/deadline.c | 8 --------

1 file changed, 8 deletions(-)
kernel/sched/deadline.c +0 -8
index 27b9381..eed6529 100644
@@ -1722,14 +1722,6 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 {
 	int check_resched = 1;
 
-	/*
-	 * If p is throttled, don't consider the possibility
-	 * of preempting rq->curr, the check will be done right
-	 * after its runtime will get replenished.
-	 */
-	if (unlikely(p->dl.dl_throttled))
-		return;
-
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
 		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
Signature · 1 line
1.9.1
#4 lore raw

[tip:sched/core] sched/deadline: Avoid a superfluous check

In reply to Wanpeng Li
sched/deadline: Avoid a superfluous check
Commit-ID:  bd4bde14b93cce8fa77765ff709e0be55abdba2c
Gitweb:     http://git.kernel.org/tip/bd4bde14b93cce8fa77765ff709e0be55abdba2c
Author:     Wanpeng Li <[email protected]>
AuthorDate: Tue, 17 Mar 2015 19:15:30 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 27 Mar 2015 09:36:12 +0100

sched/deadline: Avoid a superfluous check

Since commit 40767b0dc768 ("sched/deadline: Fix deadline parameter modification handling") we clear the thottled state when switching from a dl task, therefore we should never find it set in switching to a dl task.

---
 kernel/sched/deadline.c | 8 --------
 1 file changed, 8 deletions(-)
kernel/sched/deadline.c +0 -8
index 0a81a95..24c18dc 100644
@@ -1665,14 +1665,6 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 {
 	int check_resched = 1;
 
-	/*
-	 * If p is throttled, don't consider the possibility
-	 * of preempting rq->curr, the check will be done right
-	 * after its runtime will get replenished.
-	 */
-	if (unlikely(p->dl.dl_throttled))
-		return;
-
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
 		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&