Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1221340

Re: [PATCH] sched: make policy-testing consistent in core

From Henrik Austad <henrik@austad.us>
Newsgroups linux.kernel
Subject Re: [PATCH] sched: make policy-testing consistent in core
Date 2015-09-09 11:40 +0200
Message-ID <q6K1b-7xZ-15@gated-at.bofh.it> (permalink)
References <q6K1b-7xZ-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] sched: make policy-testing consistent in core Henrik Austad <henrik@austad.us> - 2015-09-09 11:40 +0200
  Re: [PATCH] sched: make policy-testing consistent in core Peter Zijlstra <peterz@infradead.org> - 2015-09-09 15:40 +0200
    [PATCH] sched: make policy-testing consistent in core Henrik Austad <henrik@austad.us> - 2015-09-09 17:10 +0200
      [tip:sched/core] sched/core: Make policy-testing consistent tip-bot for Henrik Austad <tipbot@zytor.com> - 2015-09-18 10:50 +0200

csiph-web