public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] sched fixes and clean-ups
@ 2015-09-02 10:01 Juri Lelli
  2015-09-02 10:01 ` [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug Juri Lelli
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Juri Lelli @ 2015-09-02 10:01 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel, juri.lelli

Hi all,

while trying to come up with 01/04, I collected the following set of fixes.

Patches 02-04/04 are simple refactoring of code and clean-ups.
Patch 01/04 is instead my attempt to fix a problem highlighted some time
back by Wanpeng Li regarding hotplug and the way SCHED_DEADLINE keeps
track of admission control decisions (admitted bandwidth). This patch
is invasive, but it seems to fix the problem (and I couldn't find
cleaner fixes :-/). Please give special attention to it :-).

Thanks!

Best,

- Juri

Juri Lelli (4):
  sched/{cpuset,core}: restore complete root_domain status across
    hotplug
  sched/deadline: unify dl_time_before usage
  locking/rtmutex: fix open coded check in rt_mutex_waiter_less()
  sched/rt: make (do_)balance_runtime() return void

 include/linux/sched.h          |  2 ++
 include/linux/sched/deadline.h |  5 +++++
 kernel/cpuset.c                | 41 +++++++++++++++++++++++++++++++++++++++++
 kernel/locking/rtmutex.c       |  3 ++-
 kernel/sched/core.c            | 17 +++++++++++++++++
 kernel/sched/cpudeadline.c     |  5 -----
 kernel/sched/cpudeadline.h     |  1 +
 kernel/sched/rt.c              | 22 ++++++----------------
 kernel/sched/sched.h           |  5 -----
 9 files changed, 74 insertions(+), 27 deletions(-)

-- 
2.2.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug
  2015-09-02 10:01 [PATCH 0/4] sched fixes and clean-ups Juri Lelli
@ 2015-09-02 10:01 ` Juri Lelli
  2015-09-09 15:11   ` Peter Zijlstra
  2015-09-02 10:01 ` [PATCH 2/4] sched/deadline: unify dl_time_before usage Juri Lelli
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Juri Lelli @ 2015-09-02 10:01 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel, juri.lelli, Li Zefan, cgroups

Hotplug operations are destructive w.r.t data associated with cpuset;
in this case we care about root_domains. SCHED_DEADLINE puts bandwidth
information regarding admitted tasks on root_domains, information that
is gone when an hotplug operation happens. Also, it is not currently
possible to tell to which task(s) the allocated bandwidth belongs, as
this link is lost after sched_setscheduler() succeeds.

This patch forces rebuilding of allocated bandwidth information at
root_domain level after cpuset_hotplug_workfn() callback is done
setting up scheduling and root domains.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: cgroups@vger.kernel.org
Reported-by: Wanpeng Li <wanpeng.li@linux.intel.com>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
---
 include/linux/sched.h |  2 ++
 kernel/cpuset.c       | 41 +++++++++++++++++++++++++++++++++++++++++
 kernel/sched/core.c   | 17 +++++++++++++++++
 3 files changed, 60 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 81bb457..cc02c68 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2175,6 +2175,8 @@ extern int cpuset_cpumask_can_shrink(const struct cpumask *cur,
 				     const struct cpumask *trial);
 extern int task_can_attach(struct task_struct *p,
 			   const struct cpumask *cs_cpus_allowed);
+void sched_restore_dl_bw(struct task_struct *task,
+			 const struct cpumask *new_mask);
 #ifdef CONFIG_SMP
 extern void do_set_cpus_allowed(struct task_struct *p,
 			       const struct cpumask *new_mask);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index ee14e3a..d3962ea 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2221,6 +2221,45 @@ retry:
 }
 
 /**
+ * update_tasks_rd - Update tasks' root_domains status.
+ * @cs: the cpuset to which each task's root_domain belongs
+ *
+ * Iterate through each task of @cs updating state of its related
+ * root_domain.
+ */
+static void update_tasks_rd(struct cpuset *cs)
+{
+	struct css_task_iter it;
+	struct task_struct *task;
+
+	css_task_iter_start(&cs->css, &it);
+	while ((task = css_task_iter_next(&it)))
+		sched_restore_dl_bw(task, cs->effective_cpus);
+	css_task_iter_end(&it);
+}
+
+static void cpuset_hotplug_update_rd(void)
+{
+	struct cpuset *cs;
+	struct cgroup_subsys_state *pos_css;
+
+	mutex_lock(&cpuset_mutex);
+	rcu_read_lock();
+	cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) {
+		if (!css_tryget_online(&cs->css))
+			continue;
+		rcu_read_unlock();
+
+		update_tasks_rd(cs);
+
+		rcu_read_lock();
+		css_put(&cs->css);
+	}
+	rcu_read_unlock();
+	mutex_unlock(&cpuset_mutex);
+}
+
+/**
  * cpuset_hotplug_workfn - handle CPU/memory hotunplug for a cpuset
  *
  * This function is called after either CPU or memory configuration has
@@ -2296,6 +2335,8 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
 	/* rebuild sched domains if cpus_allowed has changed */
 	if (cpus_updated)
 		rebuild_sched_domains();
+
+	cpuset_hotplug_update_rd();
 }
 
 void cpuset_update_active_cpus(bool cpu_online)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9917c96..c747e86 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2284,6 +2284,23 @@ static inline int dl_bw_cpus(int i)
 }
 #endif
 
+void sched_restore_dl_bw(struct task_struct *task,
+			 const struct cpumask *new_mask)
+{
+	struct dl_bw *dl_b;
+	unsigned long flags;
+
+	if (!task_has_dl_policy(task))
+		return;
+
+	rcu_read_lock_sched();
+	dl_b = dl_bw_of(cpumask_any(new_mask));
+	raw_spin_lock_irqsave(&dl_b->lock, flags);
+	dl_b->total_bw += task->dl.dl_bw;
+	raw_spin_unlock_irqrestore(&dl_b->lock, flags);
+	rcu_read_unlock_sched();
+}
+
 /*
  * We must be sure that accepting a new task (or allowing changing the
  * parameters of an existing one) is consistent with the bandwidth
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] sched/deadline: unify dl_time_before usage
  2015-09-02 10:01 [PATCH 0/4] sched fixes and clean-ups Juri Lelli
  2015-09-02 10:01 ` [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug Juri Lelli
@ 2015-09-02 10:01 ` Juri Lelli
  2015-09-23  8:46   ` [tip:sched/core] sched/deadline: Unify dl_time_before() usage tip-bot for Juri Lelli
  2015-09-02 10:01 ` [PATCH 3/4] locking/rtmutex: fix open coded check in rt_mutex_waiter_less() Juri Lelli
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Juri Lelli @ 2015-09-02 10:01 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel, juri.lelli

Move dl_time_before static definition in include/linux/sched/deadline.h
so that it can be used by different parties without being re-defined.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reported-by: Luca Abeni <luca.abeni@unitn.it>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
---
 include/linux/sched/deadline.h | 5 +++++
 kernel/sched/cpudeadline.c     | 5 -----
 kernel/sched/cpudeadline.h     | 1 +
 kernel/sched/sched.h           | 5 -----
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h
index 9d303b8..9089a2a 100644
--- a/include/linux/sched/deadline.h
+++ b/include/linux/sched/deadline.h
@@ -21,4 +21,9 @@ static inline int dl_task(struct task_struct *p)
 	return dl_prio(p->prio);
 }
 
+static inline bool dl_time_before(u64 a, u64 b)
+{
+	return (s64)(a - b) < 0;
+}
+
 #endif /* _SCHED_DEADLINE_H */
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index c6acb07..5a75b08 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -31,11 +31,6 @@ static inline int right_child(int i)
 	return (i << 1) + 2;
 }
 
-static inline int dl_time_before(u64 a, u64 b)
-{
-	return (s64)(a - b) < 0;
-}
-
 static void cpudl_exchange(struct cpudl *cp, int a, int b)
 {
 	int cpu_a = cp->elements[a].cpu, cpu_b = cp->elements[b].cpu;
diff --git a/kernel/sched/cpudeadline.h b/kernel/sched/cpudeadline.h
index 1a0a6ef..fcbdf83 100644
--- a/kernel/sched/cpudeadline.h
+++ b/kernel/sched/cpudeadline.h
@@ -2,6 +2,7 @@
 #define _LINUX_CPUDL_H
 
 #include <linux/sched.h>
+#include <linux/sched/deadline.h>
 
 #define IDX_INVALID     -1
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 68cda11..7cfc3cd 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -109,11 +109,6 @@ static inline int task_has_dl_policy(struct task_struct *p)
 	return dl_policy(p->policy);
 }
 
-static inline bool dl_time_before(u64 a, u64 b)
-{
-	return (s64)(a - b) < 0;
-}
-
 /*
  * Tells if entity @a should preempt entity @b.
  */
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] locking/rtmutex: fix open coded check in rt_mutex_waiter_less()
  2015-09-02 10:01 [PATCH 0/4] sched fixes and clean-ups Juri Lelli
  2015-09-02 10:01 ` [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug Juri Lelli
  2015-09-02 10:01 ` [PATCH 2/4] sched/deadline: unify dl_time_before usage Juri Lelli
@ 2015-09-02 10:01 ` Juri Lelli
  2015-09-23  8:47   ` [tip:sched/core] sched/deadline, locking/rtmutex: Fix " tip-bot for Juri Lelli
  2015-09-02 10:01 ` [PATCH 4/4] sched/rt: make (do_)balance_runtime() return void Juri Lelli
  2015-09-18  9:02 ` [PATCH 0/4] sched fixes and clean-ups Juri Lelli
  4 siblings, 1 reply; 11+ messages in thread
From: Juri Lelli @ 2015-09-02 10:01 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel, juri.lelli

rt_mutex_waiter_less() check of tasks deadlines is open coded. Since this
is subject to wraparound issues, make it use the correct helper.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reported-by: Luca Abeni <luca.abeni@unitn.it>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
---
 kernel/locking/rtmutex.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 5674b07..74e072f 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -158,7 +158,8 @@ rt_mutex_waiter_less(struct rt_mutex_waiter *left,
 	 * then right waiter has a dl_prio() too.
 	 */
 	if (dl_prio(left->prio))
-		return (left->task->dl.deadline < right->task->dl.deadline);
+		return dl_time_before(left->task->dl.deadline,
+				      right->task->dl.deadline);
 
 	return 0;
 }
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] sched/rt: make (do_)balance_runtime() return void
  2015-09-02 10:01 [PATCH 0/4] sched fixes and clean-ups Juri Lelli
                   ` (2 preceding siblings ...)
  2015-09-02 10:01 ` [PATCH 3/4] locking/rtmutex: fix open coded check in rt_mutex_waiter_less() Juri Lelli
@ 2015-09-02 10:01 ` Juri Lelli
  2015-09-23  8:47   ` [tip:sched/core] sched/rt: Make " tip-bot for Juri Lelli
  2015-09-18  9:02 ` [PATCH 0/4] sched fixes and clean-ups Juri Lelli
  4 siblings, 1 reply; 11+ messages in thread
From: Juri Lelli @ 2015-09-02 10:01 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel, juri.lelli

The return value of (do_)balance_runtime() is not consumed by anybody.
Make them return void.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
---
 kernel/sched/rt.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index d2ea593..e3cc163 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -635,11 +635,11 @@ bool sched_rt_bandwidth_account(struct rt_rq *rt_rq)
 /*
  * We ran out of runtime, see if we can borrow some from our neighbours.
  */
-static int do_balance_runtime(struct rt_rq *rt_rq)
+static void do_balance_runtime(struct rt_rq *rt_rq)
 {
 	struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
 	struct root_domain *rd = rq_of_rt_rq(rt_rq)->rd;
-	int i, weight, more = 0;
+	int i, weight;
 	u64 rt_period;
 
 	weight = cpumask_weight(rd->span);
@@ -673,7 +673,6 @@ static int do_balance_runtime(struct rt_rq *rt_rq)
 				diff = rt_period - rt_rq->rt_runtime;
 			iter->rt_runtime -= diff;
 			rt_rq->rt_runtime += diff;
-			more = 1;
 			if (rt_rq->rt_runtime == rt_period) {
 				raw_spin_unlock(&iter->rt_runtime_lock);
 				break;
@@ -683,8 +682,6 @@ next:
 		raw_spin_unlock(&iter->rt_runtime_lock);
 	}
 	raw_spin_unlock(&rt_b->rt_runtime_lock);
-
-	return more;
 }
 
 /*
@@ -796,26 +793,19 @@ static void __enable_runtime(struct rq *rq)
 	}
 }
 
-static int balance_runtime(struct rt_rq *rt_rq)
+static void balance_runtime(struct rt_rq *rt_rq)
 {
-	int more = 0;
-
 	if (!sched_feat(RT_RUNTIME_SHARE))
-		return more;
+		return;
 
 	if (rt_rq->rt_time > rt_rq->rt_runtime) {
 		raw_spin_unlock(&rt_rq->rt_runtime_lock);
-		more = do_balance_runtime(rt_rq);
+		do_balance_runtime(rt_rq);
 		raw_spin_lock(&rt_rq->rt_runtime_lock);
 	}
-
-	return more;
 }
 #else /* !CONFIG_SMP */
-static inline int balance_runtime(struct rt_rq *rt_rq)
-{
-	return 0;
-}
+static inline void balance_runtime(struct rt_rq *rt_rq) {}
 #endif /* CONFIG_SMP */
 
 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug
  2015-09-02 10:01 ` [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug Juri Lelli
@ 2015-09-09 15:11   ` Peter Zijlstra
  2015-09-10  9:03     ` Juri Lelli
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2015-09-09 15:11 UTC (permalink / raw)
  To: Juri Lelli; +Cc: mingo, linux-kernel, Li Zefan, cgroups

On Wed, Sep 02, 2015 at 11:01:33AM +0100, Juri Lelli wrote:
> Hotplug operations are destructive w.r.t data associated with cpuset;
> in this case we care about root_domains. SCHED_DEADLINE puts bandwidth
> information regarding admitted tasks on root_domains, information that
> is gone when an hotplug operation happens. Also, it is not currently
> possible to tell to which task(s) the allocated bandwidth belongs, as
> this link is lost after sched_setscheduler() succeeds.
> 
> This patch forces rebuilding of allocated bandwidth information at
> root_domain level after cpuset_hotplug_workfn() callback is done
> setting up scheduling and root domains.

> +static void cpuset_hotplug_update_rd(void)
> +{
> +	struct cpuset *cs;
> +	struct cgroup_subsys_state *pos_css;
> +
> +	mutex_lock(&cpuset_mutex);
> +	rcu_read_lock();
> +	cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) {
> +		if (!css_tryget_online(&cs->css))
> +			continue;
> +		rcu_read_unlock();
> +
> +		update_tasks_rd(cs);
> +
> +		rcu_read_lock();
> +		css_put(&cs->css);
> +	}
> +	rcu_read_unlock();
> +	mutex_unlock(&cpuset_mutex);
> +}
> +
> +/**
>   * cpuset_hotplug_workfn - handle CPU/memory hotunplug for a cpuset
>   *
>   * This function is called after either CPU or memory configuration has
> @@ -2296,6 +2335,8 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
>  	/* rebuild sched domains if cpus_allowed has changed */
>  	if (cpus_updated)
>  		rebuild_sched_domains();
> +
> +	cpuset_hotplug_update_rd();
>  }

So the problem is that rebuild_sched_domains() destroys rd->dl_bw ? I
worry the above is racy in that you do not restore under the same
cpuset_mutex instance as you rebuild.

That is, what will stop a new task from joining the cpuset and
overloading the bandwidth between the root-domain getting rebuild and
restoring the bandwidth?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug
  2015-09-09 15:11   ` Peter Zijlstra
@ 2015-09-10  9:03     ` Juri Lelli
  0 siblings, 0 replies; 11+ messages in thread
From: Juri Lelli @ 2015-09-10  9:03 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Li Zefan,
	cgroups@vger.kernel.org

Hi Peter,

On 09/09/15 16:11, Peter Zijlstra wrote:
> On Wed, Sep 02, 2015 at 11:01:33AM +0100, Juri Lelli wrote:
>> Hotplug operations are destructive w.r.t data associated with cpuset;
>> in this case we care about root_domains. SCHED_DEADLINE puts bandwidth
>> information regarding admitted tasks on root_domains, information that
>> is gone when an hotplug operation happens. Also, it is not currently
>> possible to tell to which task(s) the allocated bandwidth belongs, as
>> this link is lost after sched_setscheduler() succeeds.
>>
>> This patch forces rebuilding of allocated bandwidth information at
>> root_domain level after cpuset_hotplug_workfn() callback is done
>> setting up scheduling and root domains.
> 
>> +static void cpuset_hotplug_update_rd(void)
>> +{
>> +	struct cpuset *cs;
>> +	struct cgroup_subsys_state *pos_css;
>> +
>> +	mutex_lock(&cpuset_mutex);
>> +	rcu_read_lock();
>> +	cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) {
>> +		if (!css_tryget_online(&cs->css))
>> +			continue;
>> +		rcu_read_unlock();
>> +
>> +		update_tasks_rd(cs);
>> +
>> +		rcu_read_lock();
>> +		css_put(&cs->css);
>> +	}
>> +	rcu_read_unlock();
>> +	mutex_unlock(&cpuset_mutex);
>> +}
>> +
>> +/**
>>   * cpuset_hotplug_workfn - handle CPU/memory hotunplug for a cpuset
>>   *
>>   * This function is called after either CPU or memory configuration has
>> @@ -2296,6 +2335,8 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
>>  	/* rebuild sched domains if cpus_allowed has changed */
>>  	if (cpus_updated)
>>  		rebuild_sched_domains();
>> +
>> +	cpuset_hotplug_update_rd();
>>  }
> 
> So the problem is that rebuild_sched_domains() destroys rd->dl_bw ? I
> worry the above is racy in that you do not restore under the same
> cpuset_mutex instance as you rebuild.
>

Yes, problem is that root_domain is gone after rebuild_sched_domains().
We store admitted bandwidth information there, so we loose it during
hotplug. Problem also is that only other information about which task
has been admitted, in which cpuset, resides in cpusets themselves.

> That is, what will stop a new task from joining the cpuset and
> overloading the bandwidth between the root-domain getting rebuild and
> restoring the bandwidth?
> 

Right, this is broken. At first, I tried to fix this somewhere in
rebuild_sched_domains_locked() (for example via rq_{on,off}line_dl),
but I failed since, as I say above, we don't have required information
on rqs. I sort of remember I came up with a working-ish solution
saving bw in partition_sched_domains() across destroy and build, but
that was uglier that this patch :-/.

I'll keep thinking, just wanted to keep the problem known and share
what I have (not much indeed).

Thanks,

- Juri


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] sched fixes and clean-ups
  2015-09-02 10:01 [PATCH 0/4] sched fixes and clean-ups Juri Lelli
                   ` (3 preceding siblings ...)
  2015-09-02 10:01 ` [PATCH 4/4] sched/rt: make (do_)balance_runtime() return void Juri Lelli
@ 2015-09-18  9:02 ` Juri Lelli
  4 siblings, 0 replies; 11+ messages in thread
From: Juri Lelli @ 2015-09-18  9:02 UTC (permalink / raw)
  To: peterz@infradead.org, mingo@redhat.com; +Cc: linux-kernel@vger.kernel.org

Hi Peter,

On 02/09/15 11:01, Juri Lelli wrote:
> Hi all,
> 
> while trying to come up with 01/04, I collected the following set of fixes.
> 
> Patches 02-04/04 are simple refactoring of code and clean-ups.
> Patch 01/04 is instead my attempt to fix a problem highlighted some time
> back by Wanpeng Li regarding hotplug and the way SCHED_DEADLINE keeps
> track of admission control decisions (admitted bandwidth). This patch
> is invasive, but it seems to fix the problem (and I couldn't find
> cleaner fixes :-/). Please give special attention to it :-).
> 

What about the other three fixes?

Thanks!

- Juri

> Thanks!
> 
> Best,
> 
> - Juri
> 
> Juri Lelli (4):
>   sched/{cpuset,core}: restore complete root_domain status across
>     hotplug
>   sched/deadline: unify dl_time_before usage
>   locking/rtmutex: fix open coded check in rt_mutex_waiter_less()
>   sched/rt: make (do_)balance_runtime() return void
> 
>  include/linux/sched.h          |  2 ++
>  include/linux/sched/deadline.h |  5 +++++
>  kernel/cpuset.c                | 41 +++++++++++++++++++++++++++++++++++++++++
>  kernel/locking/rtmutex.c       |  3 ++-
>  kernel/sched/core.c            | 17 +++++++++++++++++
>  kernel/sched/cpudeadline.c     |  5 -----
>  kernel/sched/cpudeadline.h     |  1 +
>  kernel/sched/rt.c              | 22 ++++++----------------
>  kernel/sched/sched.h           |  5 -----
>  9 files changed, 74 insertions(+), 27 deletions(-)
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tip:sched/core] sched/deadline: Unify dl_time_before() usage
  2015-09-02 10:01 ` [PATCH 2/4] sched/deadline: unify dl_time_before usage Juri Lelli
@ 2015-09-23  8:46   ` tip-bot for Juri Lelli
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Juri Lelli @ 2015-09-23  8:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, torvalds, luca.abeni, efault, linux-kernel, juri.lelli,
	peterz, tglx, mingo

Commit-ID:  2726d6ce389788c7fe724961a6e1bfe569560088
Gitweb:     http://git.kernel.org/tip/2726d6ce389788c7fe724961a6e1bfe569560088
Author:     Juri Lelli <juri.lelli@arm.com>
AuthorDate: Wed, 2 Sep 2015 11:01:34 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 23 Sep 2015 09:51:25 +0200

sched/deadline: Unify dl_time_before() usage

Move dl_time_before() static definition in include/linux/sched/deadline.h
so that it can be used by different parties without being re-defined.

Reported-by: Luca Abeni <luca.abeni@unitn.it>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1441188096-23021-3-git-send-email-juri.lelli@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/deadline.h | 5 +++++
 kernel/sched/cpudeadline.c     | 5 -----
 kernel/sched/cpudeadline.h     | 1 +
 kernel/sched/sched.h           | 5 -----
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h
index 9d303b8..9089a2a 100644
--- a/include/linux/sched/deadline.h
+++ b/include/linux/sched/deadline.h
@@ -21,4 +21,9 @@ static inline int dl_task(struct task_struct *p)
 	return dl_prio(p->prio);
 }
 
+static inline bool dl_time_before(u64 a, u64 b)
+{
+	return (s64)(a - b) < 0;
+}
+
 #endif /* _SCHED_DEADLINE_H */
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index c6acb07..5a75b08 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -31,11 +31,6 @@ static inline int right_child(int i)
 	return (i << 1) + 2;
 }
 
-static inline int dl_time_before(u64 a, u64 b)
-{
-	return (s64)(a - b) < 0;
-}
-
 static void cpudl_exchange(struct cpudl *cp, int a, int b)
 {
 	int cpu_a = cp->elements[a].cpu, cpu_b = cp->elements[b].cpu;
diff --git a/kernel/sched/cpudeadline.h b/kernel/sched/cpudeadline.h
index 1a0a6ef..fcbdf83 100644
--- a/kernel/sched/cpudeadline.h
+++ b/kernel/sched/cpudeadline.h
@@ -2,6 +2,7 @@
 #define _LINUX_CPUDL_H
 
 #include <linux/sched.h>
+#include <linux/sched/deadline.h>
 
 #define IDX_INVALID     -1
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 3845a71..af6f252 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -118,11 +118,6 @@ static inline int task_has_dl_policy(struct task_struct *p)
 	return dl_policy(p->policy);
 }
 
-static inline bool dl_time_before(u64 a, u64 b)
-{
-	return (s64)(a - b) < 0;
-}
-
 /*
  * Tells if entity @a should preempt entity @b.
  */

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [tip:sched/core] sched/deadline, locking/rtmutex: Fix open coded check in rt_mutex_waiter_less()
  2015-09-02 10:01 ` [PATCH 3/4] locking/rtmutex: fix open coded check in rt_mutex_waiter_less() Juri Lelli
@ 2015-09-23  8:47   ` tip-bot for Juri Lelli
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Juri Lelli @ 2015-09-23  8:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, hpa, torvalds, efault, luca.abeni, linux-kernel, mingo,
	juri.lelli, tglx

Commit-ID:  f52405757e4e9bddd868d6b8ca501d58f292969f
Gitweb:     http://git.kernel.org/tip/f52405757e4e9bddd868d6b8ca501d58f292969f
Author:     Juri Lelli <juri.lelli@arm.com>
AuthorDate: Wed, 2 Sep 2015 11:01:35 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 23 Sep 2015 09:51:25 +0200

sched/deadline, locking/rtmutex: Fix open coded check in rt_mutex_waiter_less()

rt_mutex_waiter_less() check of task deadlines is open coded. Since this
is subject to wraparound bugs, make it use the correct helper.

Reported-by: Luca Abeni <luca.abeni@unitn.it>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1441188096-23021-4-git-send-email-juri.lelli@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/locking/rtmutex.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 7781d80..35e9bfc 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -158,7 +158,8 @@ rt_mutex_waiter_less(struct rt_mutex_waiter *left,
 	 * then right waiter has a dl_prio() too.
 	 */
 	if (dl_prio(left->prio))
-		return (left->task->dl.deadline < right->task->dl.deadline);
+		return dl_time_before(left->task->dl.deadline,
+				      right->task->dl.deadline);
 
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [tip:sched/core] sched/rt: Make (do_)balance_runtime() return void
  2015-09-02 10:01 ` [PATCH 4/4] sched/rt: make (do_)balance_runtime() return void Juri Lelli
@ 2015-09-23  8:47   ` tip-bot for Juri Lelli
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Juri Lelli @ 2015-09-23  8:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: efault, peterz, linux-kernel, mingo, torvalds, juri.lelli, tglx,
	hpa

Commit-ID:  269b26a5ef2b10bf15f66524fa47d81c1b4dc1a1
Gitweb:     http://git.kernel.org/tip/269b26a5ef2b10bf15f66524fa47d81c1b4dc1a1
Author:     Juri Lelli <juri.lelli@arm.com>
AuthorDate: Wed, 2 Sep 2015 11:01:36 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 23 Sep 2015 09:51:26 +0200

sched/rt: Make (do_)balance_runtime() return void

The return value of (do_)balance_runtime() is not consumed by anybody.
Make them return void.

Signed-off-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1441188096-23021-5-git-send-email-juri.lelli@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/rt.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index d2ea593..e3cc163 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -635,11 +635,11 @@ bool sched_rt_bandwidth_account(struct rt_rq *rt_rq)
 /*
  * We ran out of runtime, see if we can borrow some from our neighbours.
  */
-static int do_balance_runtime(struct rt_rq *rt_rq)
+static void do_balance_runtime(struct rt_rq *rt_rq)
 {
 	struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
 	struct root_domain *rd = rq_of_rt_rq(rt_rq)->rd;
-	int i, weight, more = 0;
+	int i, weight;
 	u64 rt_period;
 
 	weight = cpumask_weight(rd->span);
@@ -673,7 +673,6 @@ static int do_balance_runtime(struct rt_rq *rt_rq)
 				diff = rt_period - rt_rq->rt_runtime;
 			iter->rt_runtime -= diff;
 			rt_rq->rt_runtime += diff;
-			more = 1;
 			if (rt_rq->rt_runtime == rt_period) {
 				raw_spin_unlock(&iter->rt_runtime_lock);
 				break;
@@ -683,8 +682,6 @@ next:
 		raw_spin_unlock(&iter->rt_runtime_lock);
 	}
 	raw_spin_unlock(&rt_b->rt_runtime_lock);
-
-	return more;
 }
 
 /*
@@ -796,26 +793,19 @@ static void __enable_runtime(struct rq *rq)
 	}
 }
 
-static int balance_runtime(struct rt_rq *rt_rq)
+static void balance_runtime(struct rt_rq *rt_rq)
 {
-	int more = 0;
-
 	if (!sched_feat(RT_RUNTIME_SHARE))
-		return more;
+		return;
 
 	if (rt_rq->rt_time > rt_rq->rt_runtime) {
 		raw_spin_unlock(&rt_rq->rt_runtime_lock);
-		more = do_balance_runtime(rt_rq);
+		do_balance_runtime(rt_rq);
 		raw_spin_lock(&rt_rq->rt_runtime_lock);
 	}
-
-	return more;
 }
 #else /* !CONFIG_SMP */
-static inline int balance_runtime(struct rt_rq *rt_rq)
-{
-	return 0;
-}
+static inline void balance_runtime(struct rt_rq *rt_rq) {}
 #endif /* CONFIG_SMP */
 
 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-09-23  8:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-02 10:01 [PATCH 0/4] sched fixes and clean-ups Juri Lelli
2015-09-02 10:01 ` [PATCH 1/4] sched/{cpuset,core}: restore complete root_domain status across hotplug Juri Lelli
2015-09-09 15:11   ` Peter Zijlstra
2015-09-10  9:03     ` Juri Lelli
2015-09-02 10:01 ` [PATCH 2/4] sched/deadline: unify dl_time_before usage Juri Lelli
2015-09-23  8:46   ` [tip:sched/core] sched/deadline: Unify dl_time_before() usage tip-bot for Juri Lelli
2015-09-02 10:01 ` [PATCH 3/4] locking/rtmutex: fix open coded check in rt_mutex_waiter_less() Juri Lelli
2015-09-23  8:47   ` [tip:sched/core] sched/deadline, locking/rtmutex: Fix " tip-bot for Juri Lelli
2015-09-02 10:01 ` [PATCH 4/4] sched/rt: make (do_)balance_runtime() return void Juri Lelli
2015-09-23  8:47   ` [tip:sched/core] sched/rt: Make " tip-bot for Juri Lelli
2015-09-18  9:02 ` [PATCH 0/4] sched fixes and clean-ups Juri Lelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox