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


Groups > linux.kernel > #1654388

Re: [6/7] sched/rt: make it configurable

From Rob Herring <robh@kernel.org>
Newsgroups linux.kernel
Subject Re: [6/7] sched/rt: make it configurable
Date 2017-05-31 18:10 +0200
Message-ID <tNem5-73N-3@gated-at.bofh.it> (permalink)
References <tMAeZ-5J1-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, May 29, 2017 at 05:03:01PM -0400, Nicolas Pitre wrote:
> On most small systems where user space is tightly controlled, the realtime
> scheduling class can often be dispensed with to reduce the kernel footprint.
> Let's make it configurable.
> 
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
> ---

>  static inline int rt_prio(int prio)
>  {
> -	if (unlikely(prio < MAX_RT_PRIO))
> +	if (IS_ENABLED(CONFIG_SCHED_RT) && unlikely(prio < MAX_RT_PRIO))
>  		return 1;
>  	return 0;
>  }

>  #ifdef CONFIG_PREEMPT_NOTIFIERS
>  	INIT_HLIST_HEAD(&p->preempt_notifiers);
> @@ -3716,13 +3720,18 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
>  		p->sched_class = &dl_sched_class;
>  	} else
>  #endif
> +#ifdef CONFIG_SCHED_RT
>  	if (rt_prio(prio)) {

This ifdef is not necessary since rt_prio is conditioned on 
CONFIG_SCHED_RT already.

>  		if (oldprio < prio)
>  			queue_flag |= ENQUEUE_HEAD;
>  		p->sched_class = &rt_sched_class;
> -	} else {
> +	} else
> +#endif
> +	{
> +#ifdef CONFIG_SCHED_RT
>  		if (rt_prio(oldprio))
>  			p->rt.timeout = 0;
> +#endif
>  		p->sched_class = &fair_sched_class;
>  	}
>  
> @@ -3997,6 +4006,23 @@ static int __sched_setscheduler(struct task_struct *p,
>  
>  	/* May grab non-irq protected spin_locks: */
>  	BUG_ON(in_interrupt());
> +
> +	/*
> +	 * When the RT scheduling class is disabled, let's make sure kernel threads
> +	 * wanting RT still get lowest nice value to give them highest available
> +	 * priority rather than simply returning an error. Obviously we can't test
> +	 * rt_policy() here as it is always false in that case.
> +	 */
> +	if (!IS_ENABLED(CONFIG_SCHED_RT) && !user &&
> +	    (policy == SCHED_FIFO || policy == SCHED_RR)) {
> +		static const struct sched_attr k_attr = {
> +			.sched_policy = SCHED_NORMAL,
> +			.sched_nice = MIN_NICE,
> +		};
> +		attr = &k_attr;
> +		policy = SCHED_NORMAL;
> +	}
> +
>  recheck:
>  	/* Double check policy once rq lock held: */
>  	if (policy < 0) {
> @@ -5726,7 +5752,9 @@ void __init sched_init_smp(void)
>  	sched_init_granularity();
>  	free_cpumask_var(non_isolated_cpus);
>  
> +#ifdef CONFIG_SCHED_RT
>  	init_sched_rt_class();
> +#endif

You can do an empty inline function for !CONFIG_SCHED_RT.

>  #ifdef CONFIG_SCHED_DL
>  	init_sched_dl_class();
>  #endif

And here in the earlier patch.

> @@ -5832,7 +5860,9 @@ void __init sched_init(void)
>  	}
>  #endif /* CONFIG_CPUMASK_OFFSTACK */
>  
> +#ifdef CONFIG_SCHED_RT
>  	init_rt_bandwidth(&def_rt_bandwidth, global_rt_period(), global_rt_runtime());
> +#endif

And so on...

Rob

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


Thread

[PATCH 6/7] sched/rt: make it configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2017-05-29 23:20 +0200
  Re: [PATCH 6/7] sched/rt: make it configurable Peter Zijlstra <peterz@infradead.org> - 2017-05-30 10:50 +0200
    Re: [PATCH 6/7] sched/rt: make it configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2017-05-30 14:20 +0200
      Re: [PATCH 6/7] sched/rt: make it configurable Peter Zijlstra <peterz@infradead.org> - 2017-05-30 14:40 +0200
        Re: [PATCH 6/7] sched/rt: make it configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2017-05-31 04:20 +0200
        Re: [PATCH 6/7] sched/rt: make it configurable Daniel Bristot de Oliveira <bristot@redhat.com> - 2017-05-31 12:00 +0200
          Re: [PATCH 6/7] sched/rt: make it configurable Peter Zijlstra <peterz@infradead.org> - 2017-05-31 12:50 +0200
  Re: [6/7] sched/rt: make it configurable Rob Herring <robh@kernel.org> - 2017-05-31 18:10 +0200
    Re: [6/7] sched/rt: make it configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2017-05-31 18:30 +0200

csiph-web