mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] sched: make policy-testing consistent in core
       [not found] <1440078842-8009-1-git-send-email-henrik@austad.us>
@ 2015-09-09  9:32 ` Henrik Austad
  2015-09-09 13:31   ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Henrik Austad @ 2015-09-09  9:32 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2832 bytes --]

As per-irc request

*prod*

thanks!
-Henrik

On Thu, Aug 20, 2015 at 03:54:02PM +0200, Henrik Austad wrote:
> Most of the policy-tests are done via the <class>_policy() helpers with
> the notable exception of idle. A new wrapper for valid_policy() has also
> been added to improve readability  in set_load_weight().
> 
> This commit does not change the logical behavior of the scheduler core.
> 
> Signed-off-by: Henrik Austad <henrik@austad.us>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: linux-kernel@vger.kernel.org
> ---
>  kernel/sched/core.c  | 9 +++------
>  kernel/sched/sched.h | 9 +++++++++
>  2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 78b4bad10081..476a30e5632a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -816,7 +816,7 @@ static void set_load_weight(struct task_struct *p)
>  	/*
>  	 * SCHED_IDLE tasks get minimal weight:
>  	 */
> -	if (p->policy == SCHED_IDLE) {
> +	if (idle_policy(p->policy)) {
>  		load->weight = scale_load(WEIGHT_IDLEPRIO);
>  		load->inv_weight = WMULT_IDLEPRIO;
>  		return;
> @@ -3684,10 +3684,7 @@ recheck:
>  	} else {
>  		reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK);
>  
> -		if (policy != SCHED_DEADLINE &&
> -				policy != SCHED_FIFO && policy != SCHED_RR &&
> -				policy != SCHED_NORMAL && policy != SCHED_BATCH &&
> -				policy != SCHED_IDLE)
> +		if (!valid_policy(policy))
>  			return -EINVAL;
>  	}
>  
> @@ -3743,7 +3740,7 @@ recheck:
>  		 * Treat SCHED_IDLE as nice 20. Only allow a switch to
>  		 * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
>  		 */
> -		if (p->policy == SCHED_IDLE && policy != SCHED_IDLE) {
> +		if (idle_policy(p->policy) && !idle_policy(policy)) {
>  			if (!can_nice(p, task_nice(p)))
>  				return -EPERM;
>  		}
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 84d48790bb6d..fe7cb34cc55b 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -84,6 +84,10 @@ static inline void update_cpu_load_active(struct rq *this_rq) { }
>   */
>  #define RUNTIME_INF	((u64)~0ULL)
>  
> +static inline int idle_policy(int policy)
> +{
> +	return policy == SCHED_IDLE;
> +}
>  static inline int fair_policy(int policy)
>  {
>  	return policy == SCHED_NORMAL || policy == SCHED_BATCH;
> @@ -98,6 +102,11 @@ static inline int dl_policy(int policy)
>  {
>  	return policy == SCHED_DEADLINE;
>  }
> +static inline bool valid_policy(int policy)
> +{
> +	return idle_policy(policy) || fair_policy(policy) ||
> +		rt_policy(policy) || dl_policy(policy);
> +}
>  
>  static inline int task_has_rt_policy(struct task_struct *p)
>  {
> -- 
> 1.9.1
> 

-- 
Henrik Austad

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH] sched: make policy-testing consistent in core
  2015-09-09  9:32 ` [PATCH] sched: make policy-testing consistent in core Henrik Austad
@ 2015-09-09 13:31   ` Peter Zijlstra
  2015-09-09 15:00     ` Henrik Austad
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2015-09-09 13:31 UTC (permalink / raw)
  To: Henrik Austad; +Cc: Ingo Molnar, linux-kernel

On Wed, Sep 09, 2015 at 11:32:43AM +0200, Henrik Austad wrote:
> As per-irc request
> 
> *prod*

I see no objection to his; but it appears I never actually received the
original patch. Do you mind resending so I can apply?



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

* [PATCH] sched: make policy-testing consistent in core
  2015-09-09 13:31   ` Peter Zijlstra
@ 2015-09-09 15:00     ` Henrik Austad
  2015-09-18  8:48       ` [tip:sched/core] sched/core: Make policy-testing consistent tip-bot for Henrik Austad
  0 siblings, 1 reply; 4+ messages in thread
From: Henrik Austad @ 2015-09-09 15:00 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel, Henrik Austad, Ingo Molnar

Most of the policy-tests are done via the <class>_policy() helpers with
the notable exception of idle. A new wrapper for valid_policy() has also
been added to improve readability  in set_load_weight().

This commit does not change the logical behavior of the scheduler core.

Signed-off-by: Henrik Austad <henrik@austad.us>
CC: Ingo Molnar <mingo@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
CC: linux-kernel@vger.kernel.org
---
 kernel/sched/core.c  | 9 +++------
 kernel/sched/sched.h | 9 +++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3595403921bd..889ce337a83a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -814,7 +814,7 @@ static void set_load_weight(struct task_struct *p)
 	/*
 	 * SCHED_IDLE tasks get minimal weight:
 	 */
-	if (p->policy == SCHED_IDLE) {
+	if (idle_policy(p->policy)) {
 		load->weight = scale_load(WEIGHT_IDLEPRIO);
 		load->inv_weight = WMULT_IDLEPRIO;
 		return;
@@ -3736,10 +3736,7 @@ recheck:
 	} else {
 		reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK);
 
-		if (policy != SCHED_DEADLINE &&
-				policy != SCHED_FIFO && policy != SCHED_RR &&
-				policy != SCHED_NORMAL && policy != SCHED_BATCH &&
-				policy != SCHED_IDLE)
+		if (!valid_policy(policy))
 			return -EINVAL;
 	}
 
@@ -3795,7 +3792,7 @@ recheck:
 		 * Treat SCHED_IDLE as nice 20. Only allow a switch to
 		 * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
 		 */
-		if (p->policy == SCHED_IDLE && policy != SCHED_IDLE) {
+		if (idle_policy(p->policy) && !idle_policy(policy)) {
 			if (!can_nice(p, task_nice(p)))
 				return -EPERM;
 		}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 68cda117574c..597349055c3a 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -84,6 +84,10 @@ static inline void update_cpu_load_active(struct rq *this_rq) { }
  */
 #define RUNTIME_INF	((u64)~0ULL)
 
+static inline int idle_policy(int policy)
+{
+	return policy == SCHED_IDLE;
+}
 static inline int fair_policy(int policy)
 {
 	return policy == SCHED_NORMAL || policy == SCHED_BATCH;
@@ -98,6 +102,11 @@ static inline int dl_policy(int policy)
 {
 	return policy == SCHED_DEADLINE;
 }
+static inline bool valid_policy(int policy)
+{
+	return idle_policy(policy) || fair_policy(policy) ||
+		rt_policy(policy) || dl_policy(policy);
+}
 
 static inline int task_has_rt_policy(struct task_struct *p)
 {
-- 
1.9.1


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

* [tip:sched/core] sched/core: Make policy-testing consistent
  2015-09-09 15:00     ` Henrik Austad
@ 2015-09-18  8:48       ` tip-bot for Henrik Austad
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Henrik Austad @ 2015-09-18  8:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: henrik, linux-kernel, hpa, peterz, mingo, tglx, torvalds

Commit-ID:  20f9cd2acb1d74a8bf4b4087267f586e6ecdbc03
Gitweb:     http://git.kernel.org/tip/20f9cd2acb1d74a8bf4b4087267f586e6ecdbc03
Author:     Henrik Austad <henrik@austad.us>
AuthorDate: Wed, 9 Sep 2015 17:00:41 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 18 Sep 2015 09:23:13 +0200

sched/core: Make policy-testing consistent

Most of the policy-tests are done via the <class>_policy() helpers with
the notable exception of idle. A new wrapper for valid_policy() has also
been added to improve readability  in set_load_weight().

This commit does not change the logical behavior of the scheduler core.

Signed-off-by: Henrik Austad <henrik@austad.us>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1441810841-4756-1-git-send-email-henrik@austad.us
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/core.c  | 9 +++------
 kernel/sched/sched.h | 9 +++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6ab415a..1b30b5b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -817,7 +817,7 @@ static void set_load_weight(struct task_struct *p)
 	/*
 	 * SCHED_IDLE tasks get minimal weight:
 	 */
-	if (p->policy == SCHED_IDLE) {
+	if (idle_policy(p->policy)) {
 		load->weight = scale_load(WEIGHT_IDLEPRIO);
 		load->inv_weight = WMULT_IDLEPRIO;
 		return;
@@ -3733,10 +3733,7 @@ recheck:
 	} else {
 		reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK);
 
-		if (policy != SCHED_DEADLINE &&
-				policy != SCHED_FIFO && policy != SCHED_RR &&
-				policy != SCHED_NORMAL && policy != SCHED_BATCH &&
-				policy != SCHED_IDLE)
+		if (!valid_policy(policy))
 			return -EINVAL;
 	}
 
@@ -3792,7 +3789,7 @@ recheck:
 		 * Treat SCHED_IDLE as nice 20. Only allow a switch to
 		 * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
 		 */
-		if (p->policy == SCHED_IDLE && policy != SCHED_IDLE) {
+		if (idle_policy(p->policy) && !idle_policy(policy)) {
 			if (!can_nice(p, task_nice(p)))
 				return -EPERM;
 		}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 167ab48..3845a71 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -84,6 +84,10 @@ static inline void update_cpu_load_active(struct rq *this_rq) { }
  */
 #define RUNTIME_INF	((u64)~0ULL)
 
+static inline int idle_policy(int policy)
+{
+	return policy == SCHED_IDLE;
+}
 static inline int fair_policy(int policy)
 {
 	return policy == SCHED_NORMAL || policy == SCHED_BATCH;
@@ -98,6 +102,11 @@ static inline int dl_policy(int policy)
 {
 	return policy == SCHED_DEADLINE;
 }
+static inline bool valid_policy(int policy)
+{
+	return idle_policy(policy) || fair_policy(policy) ||
+		rt_policy(policy) || dl_policy(policy);
+}
 
 static inline int task_has_rt_policy(struct task_struct *p)
 {

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1440078842-8009-1-git-send-email-henrik@austad.us>
2015-09-09  9:32 ` [PATCH] sched: make policy-testing consistent in core Henrik Austad
2015-09-09 13:31   ` Peter Zijlstra
2015-09-09 15:00     ` Henrik Austad
2015-09-18  8:48       ` [tip:sched/core] sched/core: Make policy-testing consistent tip-bot for Henrik Austad

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

all inboxes | Powered by JetHome®