sched: Remove FIFO priorities from modules
Subsystems (26)
Peter Zijlstra
maintainercover sched: Remove FIFO priorities from modules
After having seen yet another patch that adds a FIFO kernel thread at a random priority, I bit the bullet and implemented the suggestion done a while ago:
Flat out remove the ability to set a specific FIFO priority
As argued in the patches themselves, the kernel has no clue what actual priority it should use for various things, so it is useless (or worse, counter productive) to even try.
Peter Zijlstra
maintainerPATCH 1/23 sched: Provide sched_set_fifo()
SCHED_FIFO (or any static priority scheduler) is a broken scheduler model; it is fundamentally incapable of resource management, the one thing an OS is actually supposed to do.
It is impossible to compose static priority workloads. One cannot take two well designed and functional static priority workloads and mash them together and still expect them to work.
Therefore it doesn't make sense to expose the priority field; the kernel is fundamentally incapable of setting a sensible value, it needs systems knowledge that it doesn't have.
Take away sched_setschedule() / sched_setattr() from modules and replace them with:
- sched_set_fifo(p); create a FIFO task (at prio 50)
- sched_set_fifo_low(p); create a task higher than NORMAL, which ends up being a FIFO task at prio 1.
- sched_set_normal(p, nice); (re)set the task to normal
This stops the proliferation of randomly chosen, and irrelevant, FIFO priorities that dont't really mean anything anyway.
The system administrator/integrator, whoever has insight into the actual system design and requirements (userspace) can set-up appropriate priorities if and when needed.
--- include/linux/sched.h | 3 +++ kernel/sched/core.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)
include/linux/sched.h +3 -0
@@ -1631,6 +1631,9 @@ extern int idle_cpu(int cpu);extern int available_idle_cpu (int cpu);extern int sched_setscheduler (struct task_struct *,int ,const struct sched_param *);extern int sched_setscheduler_nocheck (struct task_struct *,int ,const struct sched_param *); +extern int sched_set_fifo (struct task_struct *p); +extern int sched_set_fifo_low (struct task_struct *p); +extern int sched_set_normal (struct task_struct *p,int nice);extern int sched_setattr (struct task_struct *,const struct sched_attr *);extern int sched_setattr_nocheck (struct task_struct *,const struct sched_attr *);extern struct task_struct *idle_task (int cpu);
kernel/sched/core.c +47 -0
59 lines not on this page · raw message
Paul E. McKenney
maintainerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 20 lines · Peter Zijlstra
SCHED_FIFO(or any static priority scheduler) is a broken scheduler model; it is fundamentally incapable of resource management, the one thing an OS is actually supposed to do.It is impossible to compose static priority workloads. One cannot take two well designed and functional static priority workloads and mash them together and still expect them to work.
Therefore it doesn't make sense to expose the priority field; the kernel is fundamentally incapable of setting a sensible value, it needs systems knowledge that it doesn't have.
Take away
sched_setschedule()/sched_setattr()from modules and replace them with:-
sched_set_fifo(p); create a FIFO task (at prio 50)
-sched_set_fifo_low(p); create a task higher than NORMAL, which ends up being a FIFO task at prio 1.
-sched_set_normal(p, nice); (re)set the task to normal
Quoted 6 lines
This stops the proliferation of randomly chosen, and irrelevant, FIFO priorities that dont't really mean anything anyway.
The system administrator/integrator, whoever has insight into the actual system design and requirements (userspace) can set-up appropriate priorities if and when needed.
The sched_setscheduler_nocheck() calls in rcu_spawn_gp_kthread(), rcu_cpu_kthread_setup(), and rcu_spawn_one_boost_kthread() all stay as is because they all use the rcutree.kthread_prio boot parameter, which is set at boot time by the system administrator (or {who,what}ever, correct?
Or did my email reader eat a patch or two?
Thanx, Paul
Quoted 103 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- include/linux/sched.h | 3 +++ kernel/sched/core.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)include/linux/sched.h +3
-0@@ -1631,6 +1631,9 @@ extern int idle_cpu(int cpu);extern int available_idle_cpu (int cpu);extern int sched_setscheduler (struct task_struct *,int ,const struct sched_param *);extern int sched_setscheduler_nocheck (struct task_struct *,int ,const struct sched_param *); +extern int sched_set_fifo (struct task_struct *p); +extern int sched_set_fifo_low (struct task_struct *p); +extern int sched_set_normal (struct task_struct *p,int nice);extern int sched_setattr (struct task_struct *,const struct sched_attr *);extern int sched_setattr_nocheck (struct task_struct *,const struct sched_attr *);extern struct task_struct *idle_task (int cpu);kernel/sched/core.c +47
-0@@ -5055,6 +5055,8 @@ static int _sched_setscheduler(struct ta* @policy: new policy. * @param: structure containing the new RT priority. * +* Use sched_set_fifo(), read its comment. +* * Return: 0 on success. An error code otherwise. * * NOTE that the task may be already dead. @@ -5097,6 +5099,51 @@ int sched_setscheduler_nocheck(struct ta }EXPORT_SYMBOL_GPL (sched_setscheduler_nocheck); +/* +* SCHED_FIFO is a broken scheduler model; that is, it is fundamentally +* incapable of resource management, which is the one thing an OS really should +* be doing. +* +* This is of course the reason it is limited to privileged users only. +* +* Worse still; it is fundamentally impossible to compose static priority +* workloads. You cannot take two correctly working static prio workloads +* and smash them together and still expect them to work. +* +* For this reason 'all' FIFO tasks the kernel creates are basically at: +* +* MAX_RT_PRIO / 2 +* +* The administrator _MUST_ configure the system, the kernel simply doesn't +* know enough information to make a sensible choice. +*/ +int sched_set_fifo (struct task_struct *p) +{ +struct sched_param sp = { .sched_priority =MAX_RT_PRIO /2 }; +return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +} +EXPORT_SYMBOL_GPL (sched_set_fifo); + +/* +* For when you don't much care about FIFO, but want to be above SCHED_NORMAL. +*/ +int sched_set_fifo_low (struct task_struct *p) +{ +struct sched_param sp = { .sched_priority =1 }; +return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +} +EXPORT_SYMBOL_GPL (sched_set_fifo_low); + +int sched_set_normal (struct task_struct *p,int nice) +{ +struct sched_attr attr = { + .sched_policy =SCHED_NORMAL , + .sched_nice = nice, + }; +return sched_setattr_nocheck (p, &attr); +} +EXPORT_SYMBOL_GPL (sched_set_normal); +static int do_sched_setscheduler (pid_t pid,int policy,struct sched_param __user *param) {
Peter Zijlstra
maintainerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 24 lines · Paul E. McKenney
Quoted 23 lines · Peter Zijlstra
SCHED_FIFO(or any static priority scheduler) is a broken scheduler model; it is fundamentally incapable of resource management, the one thing an OS is actually supposed to do.It is impossible to compose static priority workloads. One cannot take two well designed and functional static priority workloads and mash them together and still expect them to work.
Therefore it doesn't make sense to expose the priority field; the kernel is fundamentally incapable of setting a sensible value, it needs systems knowledge that it doesn't have.
Take away
sched_setschedule()/sched_setattr()from modules and replace them with:-
sched_set_fifo(p); create a FIFO task (at prio 50)
-sched_set_fifo_low(p); create a task higher than NORMAL, which ends up being a FIFO task at prio 1.
-sched_set_normal(p, nice); (re)set the task to normalThis stops the proliferation of randomly chosen, and irrelevant, FIFO priorities that dont't really mean anything anyway.
Quoted 8 lines
Quoted 3 lines
The system administrator/integrator, whoever has insight into the actual system design and requirements (userspace) can set-up appropriate priorities if and when needed.
The
sched_setscheduler_nocheck()calls inrcu_spawn_gp_kthread(),rcu_cpu_kthread_setup(), andrcu_spawn_one_boost_kthread()all stay as is because they all use the rcutree.kthread_prio boot parameter, which is set at boot time by the system administrator (or {who,what}ever, correct?
Correct, also they are not modular afaict, so they escaped the dance ;-)
Paul E. McKenney
maintainerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 29 lines · Peter Zijlstra
Quoted 28 lines · Paul E. McKenney
Quoted 26 lines · Peter Zijlstra
SCHED_FIFO(or any static priority scheduler) is a broken scheduler model; it is fundamentally incapable of resource management, the one thing an OS is actually supposed to do.It is impossible to compose static priority workloads. One cannot take two well designed and functional static priority workloads and mash them together and still expect them to work.
Therefore it doesn't make sense to expose the priority field; the kernel is fundamentally incapable of setting a sensible value, it needs systems knowledge that it doesn't have.
Take away
sched_setschedule()/sched_setattr()from modules and replace them with:-
sched_set_fifo(p); create a FIFO task (at prio 50)
-sched_set_fifo_low(p); create a task higher than NORMAL, which ends up being a FIFO task at prio 1.
-sched_set_normal(p, nice); (re)set the task to normalThis stops the proliferation of randomly chosen, and irrelevant, FIFO priorities that dont't really mean anything anyway.
The system administrator/integrator, whoever has insight into the actual system design and requirements (userspace) can set-up appropriate priorities if and when needed.
Quoted 6 lines
Quoted 4 lines
The
sched_setscheduler_nocheck()calls inrcu_spawn_gp_kthread(),rcu_cpu_kthread_setup(), andrcu_spawn_one_boost_kthread()all stay as is because they all use the rcutree.kthread_prio boot parameter, which is set at boot time by the system administrator (or {who,what}ever, correct?Correct, also they are not modular afaict, so they escaped the dance ;-)
Indeed, an extreme form of insanity would be required to try to make core RCU be a module. Not that such a form of insanity is a bad thing in and of itself, but it might best be directed towards less futile ventures. ;-)
Thanx, Paul
Steven Rostedt
reviewerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 3 lines · On Wed, 22 Apr 2020 08:50:06 -0700 "Paul E. McKenney" <[email protected]>…
Indeed, an extreme form of insanity would be required to try to make core RCU be a module. Not that such a form of insanity is a bad thing in and of itself, but it might best be directed towards less futile ventures. ;-)
That's like making the core of mutexes a module. How would that ever work (without becoming a microkernel).
-- Steve
Paul E. McKenney
maintainerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 9 lines · Steven Rostedt
Quoted 3 lines · On Wed, 22 Apr 2020 08:50:06 -0700 "Paul E. McKenney" <[email protected]>…
Indeed, an extreme form of insanity would be required to try to make core RCU be a module. Not that such a form of insanity is a bad thing in and of itself, but it might best be directed towards less futile ventures. ;-)
That's like making the core of mutexes a module. How would that ever work (without becoming a microkernel).
Someone somewhere has probably done it. Perhaps you really could make mutexes be a module within the Linux kernel using kpatch or similar. Sort of, anyway.
Not saying it is not insane, mind you! ;-)
Thanx, Paul
Steven Rostedt
reviewerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 1 line · On Wed, 22 Apr 2020 09:40:30 -0700 "Paul E. McKenney" <[email protected]>…
Not saying it is not insane, mind you! ;-)
I sometimes wonder about your sanity ;-)
-- Steve
Paul E. McKenney
maintainerRe: [PATCH 01/23] sched: Provide sched_set_fifo()
Quoted 6 lines · Steven Rostedt
Quoted 1 line · On Wed, 22 Apr 2020 09:40:30 -0700 "Paul E. McKenney" <[email protected]>…
Not saying it is not insane, mind you! ;-)
I sometimes wonder about your sanity ;-)
;-) ;-) ;-)
Thanx, Paul
Re: [PATCH 01/23] sched: Provide sched_set_fifo()
In reply to Peter ZijlstraQuoted 40 lines · Peter Zijlstra
SCHED_FIFO(or any static priority scheduler) is a broken scheduler model; it is fundamentally incapable of resource management, the one thing an OS is actually supposed to do.It is impossible to compose static priority workloads. One cannot take two well designed and functional static priority workloads and mash them together and still expect them to work.
Therefore it doesn't make sense to expose the priority field; the kernel is fundamentally incapable of setting a sensible value, it needs systems knowledge that it doesn't have.
Take away
sched_setschedule()/sched_setattr()from modules and replace them with:-
sched_set_fifo(p); create a FIFO task (at prio 50)
-sched_set_fifo_low(p); create a task higher than NORMAL, which ends up being a FIFO task at prio 1.
-sched_set_normal(p, nice); (re)set the task to normalThis stops the proliferation of randomly chosen, and irrelevant, FIFO priorities that dont't really mean anything anyway.
The system administrator/integrator, whoever has insight into the actual system design and requirements (userspace) can set-up appropriate priorities if and when needed.
Quoted 8 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Quoted 82 lines
--- include/linux/sched.h | 3 +++ kernel/sched/core.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)include/linux/sched.h +3
-0@@ -1631,6 +1631,9 @@ extern int idle_cpu(int cpu);extern int available_idle_cpu (int cpu);extern int sched_setscheduler (struct task_struct *,int ,const struct sched_param *);extern int sched_setscheduler_nocheck (struct task_struct *,int ,const struct sched_param *); +extern int sched_set_fifo (struct task_struct *p); +extern int sched_set_fifo_low (struct task_struct *p); +extern int sched_set_normal (struct task_struct *p,int nice);extern int sched_setattr (struct task_struct *,const struct sched_attr *);extern int sched_setattr_nocheck (struct task_struct *,const struct sched_attr *);extern struct task_struct *idle_task (int cpu);kernel/sched/core.c +47
-0@@ -5055,6 +5055,8 @@ static int _sched_setscheduler(struct ta* @policy: new policy. * @param: structure containing the new RT priority. * +* Use sched_set_fifo(), read its comment. +* * Return: 0 on success. An error code otherwise. * * NOTE that the task may be already dead. @@ -5097,6 +5099,51 @@ int sched_setscheduler_nocheck(struct ta }EXPORT_SYMBOL_GPL (sched_setscheduler_nocheck); +/* +* SCHED_FIFO is a broken scheduler model; that is, it is fundamentally +* incapable of resource management, which is the one thing an OS really should +* be doing. +* +* This is of course the reason it is limited to privileged users only. +* +* Worse still; it is fundamentally impossible to compose static priority +* workloads. You cannot take two correctly working static prio workloads +* and smash them together and still expect them to work. +* +* For this reason 'all' FIFO tasks the kernel creates are basically at: +* +* MAX_RT_PRIO / 2 +* +* The administrator _MUST_ configure the system, the kernel simply doesn't +* know enough information to make a sensible choice. +*/ +int sched_set_fifo (struct task_struct *p) +{ +struct sched_param sp = { .sched_priority =MAX_RT_PRIO /2 }; +return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +} +EXPORT_SYMBOL_GPL (sched_set_fifo); + +/* +* For when you don't much care about FIFO, but want to be above SCHED_NORMAL. +*/ +int sched_set_fifo_low (struct task_struct *p) +{ +struct sched_param sp = { .sched_priority =1 }; +return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +} +EXPORT_SYMBOL_GPL (sched_set_fifo_low); + +int sched_set_normal (struct task_struct *p,int nice) +{ +struct sched_attr attr = { + .sched_policy =SCHED_NORMAL , + .sched_nice = nice, + }; +return sched_setattr_nocheck (p, &attr); +} +EXPORT_SYMBOL_GPL (sched_set_normal); +static int do_sched_setscheduler (pid_t pid,int policy,struct sched_param __user *param) {
Re: [PATCH 01/23] sched: Provide sched_set_fifo()
In reply to Peter ZijlstraQuoted 48 lines · Peter Zijlstra
SCHED_FIFO(or any static priority scheduler) is a broken scheduler model; it is fundamentally incapable of resource management, the one thing an OS is actually supposed to do.It is impossible to compose static priority workloads. One cannot take two well designed and functional static priority workloads and mash them together and still expect them to work.
Therefore it doesn't make sense to expose the priority field; the kernel is fundamentally incapable of setting a sensible value, it needs systems knowledge that it doesn't have.
Take away
sched_setschedule()/sched_setattr()from modules and replace them with:-
sched_set_fifo(p); create a FIFO task (at prio 50)
-sched_set_fifo_low(p); create a task higher than NORMAL, which ends up being a FIFO task at prio 1.
-sched_set_normal(p, nice); (re)set the task to normalThis stops the proliferation of randomly chosen, and irrelevant, FIFO priorities that dont't really mean anything anyway.
The system administrator/integrator, whoever has insight into the actual system design and requirements (userspace) can set-up appropriate priorities if and when needed.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Quoted 1 line
---
The random priorities were horrible indeed.
FWIW
Thanks
--
Qais Yousef
Quoted 81 lines
include/linux/sched.h | 3 +++ kernel/sched/core.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)include/linux/sched.h +3
-0@@ -1631,6 +1631,9 @@ extern int idle_cpu(int cpu);extern int available_idle_cpu (int cpu);extern int sched_setscheduler (struct task_struct *,int ,const struct sched_param *);extern int sched_setscheduler_nocheck (struct task_struct *,int ,const struct sched_param *); +extern int sched_set_fifo (struct task_struct *p); +extern int sched_set_fifo_low (struct task_struct *p); +extern int sched_set_normal (struct task_struct *p,int nice);extern int sched_setattr (struct task_struct *,const struct sched_attr *);extern int sched_setattr_nocheck (struct task_struct *,const struct sched_attr *);extern struct task_struct *idle_task (int cpu);kernel/sched/core.c +47
-0@@ -5055,6 +5055,8 @@ static int _sched_setscheduler(struct ta* @policy: new policy. * @param: structure containing the new RT priority. * +* Use sched_set_fifo(), read its comment. +* * Return: 0 on success. An error code otherwise. * * NOTE that the task may be already dead. @@ -5097,6 +5099,51 @@ int sched_setscheduler_nocheck(struct ta }EXPORT_SYMBOL_GPL (sched_setscheduler_nocheck); +/* +* SCHED_FIFO is a broken scheduler model; that is, it is fundamentally +* incapable of resource management, which is the one thing an OS really should +* be doing. +* +* This is of course the reason it is limited to privileged users only. +* +* Worse still; it is fundamentally impossible to compose static priority +* workloads. You cannot take two correctly working static prio workloads +* and smash them together and still expect them to work. +* +* For this reason 'all' FIFO tasks the kernel creates are basically at: +* +* MAX_RT_PRIO / 2 +* +* The administrator _MUST_ configure the system, the kernel simply doesn't +* know enough information to make a sensible choice. +*/ +int sched_set_fifo (struct task_struct *p) +{ +struct sched_param sp = { .sched_priority =MAX_RT_PRIO /2 }; +return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +} +EXPORT_SYMBOL_GPL (sched_set_fifo); + +/* +* For when you don't much care about FIFO, but want to be above SCHED_NORMAL. +*/ +int sched_set_fifo_low (struct task_struct *p) +{ +struct sched_param sp = { .sched_priority =1 }; +return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +} +EXPORT_SYMBOL_GPL (sched_set_fifo_low); + +int sched_set_normal (struct task_struct *p,int nice) +{ +struct sched_attr attr = { + .sched_policy =SCHED_NORMAL , + .sched_nice = nice, + }; +return sched_setattr_nocheck (p, &attr); +} +EXPORT_SYMBOL_GPL (sched_set_normal); +static int do_sched_setscheduler (pid_t pid,int policy,struct sched_param __user *param) {
Peter Zijlstra
maintainerPATCH 2/23 sched,bL_switcher: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
In this case, use fifo_low, because it only cares about being above SCHED_NORMAL. Effectively no change in behaviour.
--- arch/arm/common/bL_switcher.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/common/bL_switcher.c +1 -2
@@ -270,12 +270,11 @@ static struct bL_thread bL_threads[NR_CPstatic int bL_switcher_thread (void *arg) {struct bL_thread *t = arg; -struct sched_param param = { .sched_priority =1 };int cluster;bL_switch_completion_handler completer;void *completer_cookie; -sched_setscheduler_nocheck (current,SCHED_FIFO , ¶m); +sched_set_fifo_low (current);complete (&t->started); do {
Re: [PATCH 02/23] sched,bL_switcher: Convert to sched_set_fifo*()
Quoted 11 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively no change in behaviour.Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Quoted 23 lines
--- arch/arm/common/bL_switcher.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm/common/bL_switcher.c +1
-2@@ -270,12 +270,11 @@ static struct bL_thread bL_threads[NR_CPstatic int bL_switcher_thread (void *arg) {struct bL_thread *t = arg; -struct sched_param param = { .sched_priority =1 };int cluster;bL_switch_completion_handler completer;void *completer_cookie; -sched_setscheduler_nocheck (current,SCHED_FIFO , ¶m); +sched_set_fifo_low (current);complete (&t->started); do {
Peter Zijlstra
maintainerPATCH 3/23 sched,crypto: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Use sched_set_fifo() to request SCHED_FIFO and delegate actual priority selection to userspace. Effectively no change in behaviour.
--- crypto/crypto_engine.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
crypto/crypto_engine.c +1 -2
@@ -396,7 +396,6 @@ EXPORT_SYMBOL_GPL(crypto_engine_stop);*/ struct crypto_engine *crypto_engine_alloc_init (struct device *dev,bool rt) { -struct sched_param param = { .sched_priority =MAX_RT_PRIO /2 };struct crypto_engine *engine;if (!dev)
@@ -428,7 +427,7 @@ struct crypto_engine *crypto_engine_alloif (engine->rt) {dev_info (dev,"will run requests pump with realtime priority\n" ); -sched_setscheduler (engine->kworker->task,SCHED_FIFO , ¶m); +sched_set_fifo (engine->kworker->task); }return engine;
Re: [PATCH 03/23] sched,crypto: Convert to sched_set_fifo*()
Quoted 8 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Use
sched_set_fifo()to requestSCHED_FIFOand delegate actual priority selection to userspace. Effectively no change in behaviour.
Quoted 6 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- crypto/crypto_engine.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Peter Zijlstra
maintainerPATCH 4/23 sched,acpi_pad: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
In this case, use fifo_low, because it only cares about being above SCHED_NORMAL. Effectively no change in behaviour.
XXX: this driver is still complete crap; why isn't it using proper idle injection or at the very least play_idle() ?
--- drivers/acpi/acpi_pad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/acpi_pad.c +1 -2
@@ -136,12 +136,11 @@ static unsigned int idle_pct = 5; /* perstatic unsigned int round_robin_time =1 ;/* second */ static int power_saving_thread (void *data) { -struct sched_param param = {.sched_priority =1 };int do_sleep;unsigned int tsk_index = (unsigned long )data;u64 last_jiffies =0 ; -sched_setscheduler (current,SCHED_RR , ¶m); +sched_set_fifo_low (current);while (!kthread_should_stop ()) {unsigned long expire_time;
Dietmar Eggemann
reviewerRe: [PATCH 04/23] sched,acpi_pad: Convert to sched_set_fifo*()
Quoted 20 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively no change in behaviour.XXX: this driver is still complete crap; why isn't it using proper idle injection or at the very least
play_idle()?Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/acpi/acpi_pad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/acpi_pad.c static unsigned int idle_pct = 5; /* per · line 144
Quoted 9 lines
drivers/acpi/acpi_pad.c +0
-2@@ -136,12 +136,11 @@ static unsigned int idle_pct = 5; /* perstatic unsigned int round_robin_time =1 ;/* second */ static int power_saving_thread (void *data) { -struct sched_param param = {.sched_priority =1 };int do_sleep;unsigned int tsk_index = (unsigned long )data;u64 last_jiffies =0 ; -sched_setscheduler (current,SCHED_RR , ¶m);
I was wondering what happened to the SCHED_RR cases but as I can see now they are handled here and in the next patch.
Quoted 6 lines
drivers/acpi/acpi_pad.c +1
-0+sched_set_fifo_low (current);while (!kthread_should_stop ()) {unsigned long expire_time;
Peter Zijlstra
maintainerRe: [PATCH 04/23] sched,acpi_pad: Convert to sched_set_fifo*()
Quoted 29 lines · Dietmar Eggemann
Quoted 28 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively no change in behaviour.XXX: this driver is still complete crap; why isn't it using proper idle injection or at the very least
play_idle()?Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/acpi/acpi_pad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/acpi/acpi_pad.c +0
-1@@ -136,12 +136,11 @@ static unsigned int idle_pct = 5; /* perstatic unsigned int round_robin_time =1 ;/* second */ static int power_saving_thread (void *data) { -struct sched_param param = {.sched_priority =1 };int do_sleep;unsigned int tsk_index = (unsigned long )data;u64 last_jiffies =0 ;
Quoted 4 lines
drivers/acpi/acpi_pad.c static unsigned int idle_pct = 5; /* per · line 144
Quoted 1 line
drivers/acpi/acpi_pad.c +0
-1-sched_setscheduler (current,SCHED_RR , ¶m);I was wondering what happened to the
SCHED_RRcases but as I can see now they are handled here and in the next patch.
Oh right; I completely forgot to mention that in the Changelog didn't I :-(
In this case, this driver is a broken piece of crap and doing fake idle with RR is just plain idiotic. Also note the WARNs in play_idle().
Also, rjw, what was the point of renmaing play_idle() to play_idle_precise() if there is only one anyway? The changelog talks about adding play_idle_precise() but the patch (rightfully) doesn't add another version but replaces the existing one. But why change the name?!
Peter Zijlstra
maintainerPATCH 5/23 sched,drbd: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
In this case, use fifo_low, because it only cares about being above SCHED_NORMAL. Effectively changes prio from 2 to 1.
--- drivers/block/drbd/drbd_receiver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/drbd/drbd_receiver.c +1 -2
@@ -6020,9 +6020,8 @@ int drbd_ack_receiver(struct drbd_threadunsigned int header_size =drbd_header_size (connection);int expect = header_size;bool ping_timeout_active = false; -struct sched_param param = { .sched_priority =2 }; - rv =sched_setscheduler (current,SCHED_RR , ¶m); + rv =sched_set_fifo_low (current);if (rv <0 )drbd_err (connection,"drbd_ack_receiver: ERROR set priority, ret=%d\n" , rv);
Peter Zijlstra
maintainerRe: [PATCH 05/23] sched,drbd: Convert to sched_set_fifo*()
Quoted 17 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively changes prio from 2 to 1.Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/block/drbd/drbd_receiver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/drbd/drbd_receiver.c int drbd_ack_receiver(struct drbd_thread · line 6024
Quoted 7 lines
drivers/block/drbd/drbd_receiver.c +1
-2@@ -6020,9 +6020,8 @@ int drbd_ack_receiver(struct drbd_threadunsigned int header_size =drbd_header_size (connection);int expect = header_size;bool ping_timeout_active = false; -struct sched_param param = { .sched_priority =2 }; - rv =sched_setscheduler (current,SCHED_RR , ¶m); + rv =sched_set_fifo_low (current);
As noted by Dietmar, I forgot to mention loosing RR in the changelog, bad me.
In this case I'm not actually 100% sure, but there was no comment with it that justified it being RR, and RR-SMP is not optimal (in fact it's rather buggered).
In general RR is even more 'interesting' to get right thatn FIFO and therefore I figured it probably didn't want to be RR, but given there can be multiple of such threads, it might have been an attempt at providing some sort of fairness between the multiple threads.
At the same time, if you're running the threads so hard that RR makes a difference, it's unlikely there is any actual NORMAL time left and things will be unhappy anyway.
Therefore, and me being lazy, make it FIFO.
Peter Zijlstra
maintainerPATCH 6/23 sched,psci: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively changes prio from 99 to 50.
XXX this thing is horrific, it basically open-codes a stop-machine and idle.
--- drivers/firmware/psci/psci_checker.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/firmware/psci/psci_checker.c +2 -9
@@ -272,7 +272,6 @@ static int suspend_test_thread(void *arg {int cpu = (long )arg;int i, nb_suspend =0 , nb_shallow_sleep =0 , nb_err =0 ; -struct sched_param sched_priority = { .sched_priority =MAX_RT_PRIO -1 };struct cpuidle_device *dev;struct cpuidle_driver *drv;/* No need for an actual callback, we just want to wake up the CPU. */
@@ -282,9 +281,8 @@ static int suspend_test_thread(void *argwait_for_completion (&suspend_threads_started);/* Set maximum priority to preempt all other threads on this CPU. */ -if (sched_setscheduler_nocheck (current,SCHED_FIFO , &sched_priority)) -pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , - cpu); +if (sched_set_fifo (current)) +pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , cpu); dev =this_cpu_read (cpuidle_devices); drv =cpuidle_get_cpu_driver (dev);
@@ -349,11 +347,6 @@ static int suspend_test_thread(void *argif (atomic_dec_return_relaxed (&nb_active_threads) ==0 )complete (&suspend_threads_done); -/* Give up on RT scheduling and wait for termination. */ - sched_priority.sched_priority =0 ; -if (sched_setscheduler_nocheck (current,SCHED_NORMAL , &sched_priority)) -pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , - cpu);for (;;) {/* Needs to be set first to avoid missing a wakeup. */ set_current_state (TASK_INTERRUPTIBLE );
Re: [PATCH 06/23] sched,psci: Convert to sched_set_fifo*()
Quoted 9 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
XXX this thing is horrific, it basically open-codes a stop-machine and idle.
I went and tried to clean up the thing. I didn't find a clean way to use stop_machine() + play_idle() (stoppers can't sleep), but I did manage to get something usable with the existing FIFO threads, play_idle_precise() and the cpuidle state usage stats, so the whole homebrewed idle thing can go.
I also just tested it with 50 prio and big surprise it didn't change anything (it ends up being sibling of idle injection). So FWIW:
Quoted 4 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Re: [PATCH 06/23] sched,psci: Convert to sched_set_fifo*()
In reply to Peter ZijlstraQuoted 11 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
XXX this thing is horrific, it basically open-codes a stop-machine and idle.
Tested the PSCI checker pulling the entire series. Continues to work :)
Signature · 2 lines
Regards, Sudeep
Re: [PATCH 06/23] sched,psci: Convert to sched_set_fifo*()
In reply to Peter ZijlstraQuoted 40 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
XXX this thing is horrific, it basically open-codes a stop-machine and idle.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/firmware/psci/psci_checker.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/firmware/psci/psci_checker.c +2
-4@@ -272,7 +272,6 @@ static int suspend_test_thread(void *arg {int cpu = (long )arg;int i, nb_suspend =0 , nb_shallow_sleep =0 , nb_err =0 ; -struct sched_param sched_priority = { .sched_priority =MAX_RT_PRIO -1 };struct cpuidle_device *dev;struct cpuidle_driver *drv;/* No need for an actual callback, we just want to wake up the CPU. */ @@ -282,9 +281,8 @@ static int suspend_test_thread(void *argwait_for_completion (&suspend_threads_started);/* Set maximum priority to preempt all other threads on this CPU. */ -if (sched_setscheduler_nocheck (current,SCHED_FIFO , &sched_priority)) -pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , - cpu); +if (sched_set_fifo (current)) +pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , cpu); dev =this_cpu_read (cpuidle_devices); drv =cpuidle_get_cpu_driver (dev);
drivers/firmware/psci/psci_checker.c static int suspend_test_thread(void *arg · line 356
Quoted 8 lines
drivers/firmware/psci/psci_checker.c +0
-5@@ -349,11 +347,6 @@ static int suspend_test_thread(void *argif (atomic_dec_return_relaxed (&nb_active_threads) ==0 )complete (&suspend_threads_done); -/* Give up on RT scheduling and wait for termination. */ - sched_priority.sched_priority =0 ; -if (sched_setscheduler_nocheck (current,SCHED_NORMAL , &sched_priority)) -pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , - cpu);
No need for sched_set_normal() here before the busy loop?
Thanks
--
Qais Yousef
Quoted 5 lines
drivers/firmware/psci/psci_checker.c +0
-0for (;;) {/* Needs to be set first to avoid missing a wakeup. */ set_current_state (TASK_INTERRUPTIBLE );
Re: [PATCH 06/23] sched,psci: Convert to sched_set_fifo*()
Quoted 5 lines · Qais Yousef
Quoted 5 lines
drv = cpuidle_get_cpu_driver(dev);drivers/firmware/psci/psci_checker.c +0
-0@@ -349,11 +347,6 @@ static int suspend_test_thread(void *argif (atomic_dec_return_relaxed (&nb_active_threads) ==0 )complete (&suspend_threads_done);
Quoted 8 lines
drivers/firmware/psci/psci_checker.c static int suspend_test_thread(void *arg · line 356
Quoted 5 lines
drivers/firmware/psci/psci_checker.c +0
-5-/* Give up on RT scheduling and wait for termination. */ - sched_priority.sched_priority =0 ; -if (sched_setscheduler_nocheck (current,SCHED_NORMAL , &sched_priority)) -pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , - cpu);No need for
sched_set_normal()here before the busy loop?
Given the tasks become TASK_INTERRUPTIBLE, and the only extra thing they'll do is exit (barring the parking weirdness), changing them back to CFS seems superfluous.
Quoted 1 line
Thanks
Peter Zijlstra
maintainerPATCH 7/23 sched,msm: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Use sched_set_fifo(); Effectively changes prio from 16 to 50.
--- drivers/gpu/drm/msm/msm_drv.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +1 -9
@@ -388,7 +388,6 @@ static int msm_drm_init(struct device *dstruct msm_kms *kms;struct msm_mdss *mdss;int ret, i; -struct sched_param param; ddev =drm_dev_alloc (drv, dev);if (IS_ERR (ddev)) {
@@ -494,12 +493,6 @@ static int msm_drm_init(struct device *d ddev->mode_config.funcs = &mode_config_funcs; ddev->mode_config.helper_private = &mode_config_helper_funcs; -/** -* this priority was found during empiric testing to have appropriate -* realtime scheduling to process display updates and interact with -* other real time and normal priority task -*/ - param.sched_priority =16 ;for (i =0 ; i < priv->num_crtcs; i++) {/* initialize event thread */ priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id;
@@ -515,8 +508,7 @@ static int msm_drm_init(struct device *d goto err_msm_uninit; } - ret =sched_setscheduler (priv->event_thread[i].thread, -SCHED_FIFO , ¶m); + ret =sched_set_fifo (priv->event_thread[i].thread);if (ret)dev_warn (dev,"event_thread set priority failed:%d\n" , ret);
Peter Zijlstra
maintainerPATCH 8/23 sched,drm/scheduler: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
In this case, use fifo_low, because it only cares about being above SCHED_NORMAL. Effectively no change in behaviour.
--- drivers/gpu/drm/scheduler/sched_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +1 -2
@@ -760,11 +760,10 @@ static bool drm_sched_blocked(struct drm*/ static int drm_sched_main (void *param) { -struct sched_param sparam = {.sched_priority =1 };struct drm_gpu_scheduler *sched = (struct drm_gpu_scheduler *)param;int r; -sched_setscheduler (current,SCHED_FIFO , &sparam); +sched_set_fifo_low (current);while (!kthread_should_stop ()) {struct drm_sched_entity *entity =NULL ;
Peter Zijlstra
maintainerPATCH 9/23 sched,ivtv: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively changes from 99 to 50.
--- drivers/media/pci/ivtv/ivtv-driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/pci/ivtv/ivtv-driver.c +1 -3
@@ -737,8 +737,6 @@ static void ivtv_process_options(struct*/ static int ivtv_init_struct1 (struct ivtv *itv) { -struct sched_param param = { .sched_priority =99 }; - itv->base_addr =pci_resource_start (itv->pdev,0 ); itv->enc_mbox.max_mbox =2 ;/* the encoder has 3 mailboxes (0-2) */ itv->dec_mbox.max_mbox =1 ;/* the decoder has 2 mailboxes (0-1) */
@@ -758,7 +756,7 @@ static int ivtv_init_struct1(struct ivtvreturn -1 ; }/* must use the FIFO scheduler as it is realtime sensitive */ -sched_setscheduler (itv->irq_worker_task,SCHED_FIFO , ¶m); +sched_set_fifo (itv->irq_worker_task);kthread_init_work (&itv->irq_work, ivtv_irq_work_handler);
Steven Rostedt
reviewerRe: [PATCH 09/23] sched,ivtv: Convert to sched_set_fifo*()
Quoted 5 lines · On Wed, 22 Apr 2020 13:27:28 +0200 Peter Zijlstra <[email protected]> wrote:
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes from 99 to 50.
I wonder for the 99 users, we should have a sched_set_high() that would set the task to something like 75.
That is, above default 50?
-- Steve
Quoted 30 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/media/pci/ivtv/ivtv-driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/media/pci/ivtv/ivtv-driver.c +1
-3@@ -737,8 +737,6 @@ static void ivtv_process_options(struct*/ static int ivtv_init_struct1 (struct ivtv *itv) { -struct sched_param param = { .sched_priority =99 }; - itv->base_addr =pci_resource_start (itv->pdev,0 ); itv->enc_mbox.max_mbox =2 ;/* the encoder has 3 mailboxes (0-2) */ itv->dec_mbox.max_mbox =1 ;/* the decoder has 2 mailboxes (0-1) */ @@ -758,7 +756,7 @@ static int ivtv_init_struct1(struct ivtvreturn -1 ; }/* must use the FIFO scheduler as it is realtime sensitive */ -sched_setscheduler (itv->irq_worker_task,SCHED_FIFO , ¶m); +sched_set_fifo (itv->irq_worker_task);kthread_init_work (&itv->irq_work, ivtv_irq_work_handler);
Peter Zijlstra
maintainerRe: [PATCH 09/23] sched,ivtv: Convert to sched_set_fifo*()
Quoted 7 lines · Steven Rostedt
Quoted 4 lines · On Wed, 22 Apr 2020 13:27:28 +0200 Peter Zijlstra <[email protected]> wrote:
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Quoted 6 lines
Quoted 1 line
Effectively changes from 99 to 50.
I wonder for the 99 users, we should have a
sched_set_high()that would set the task to something like 75.That is, above default 50?
No. If userspace knows, userspace can fix it. We must not bother with priority, simply because we cannot, possibly, say something useful.
Re: [PATCH 09/23] sched,ivtv: Convert to sched_set_fifo*()
In reply to Peter ZijlstraQuoted 10 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes from 99 to 50.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
I didn't see any difference in behavior when I changed the prio from 99 to 50, so it doesn't seem to be a harmful change :-)
Regards,
Hans
Quoted 26 lines
--- drivers/media/pci/ivtv/ivtv-driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/media/pci/ivtv/ivtv-driver.c +1
-3@@ -737,8 +737,6 @@ static void ivtv_process_options(struct*/ static int ivtv_init_struct1 (struct ivtv *itv) { -struct sched_param param = { .sched_priority =99 }; - itv->base_addr =pci_resource_start (itv->pdev,0 ); itv->enc_mbox.max_mbox =2 ;/* the encoder has 3 mailboxes (0-2) */ itv->dec_mbox.max_mbox =1 ;/* the decoder has 2 mailboxes (0-1) */ @@ -758,7 +756,7 @@ static int ivtv_init_struct1(struct ivtvreturn -1 ; }/* must use the FIFO scheduler as it is realtime sensitive */ -sched_setscheduler (itv->irq_worker_task,SCHED_FIFO , ¶m); +sched_set_fifo (itv->irq_worker_task);kthread_init_work (&itv->irq_work, ivtv_irq_work_handler);
Peter Zijlstra
maintainerPATCH 10/23 sched,mmc: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
In this case, use fifo_low, because it only cares about being above SCHED_NORMAL. Effectively no change in behaviour.
--- drivers/mmc/core/sdio_irq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/core/sdio_irq.c +1 -2
@@ -139,11 +139,10 @@ EXPORT_SYMBOL_GPL(sdio_signal_irq);static int sdio_irq_thread (void *_host) {struct mmc_host *host = _host; -struct sched_param param = { .sched_priority =1 };unsigned long period, idle_period;int ret; -sched_setscheduler (current,SCHED_FIFO , ¶m); +sched_set_fifo_low (current);/* * We want to allow for SDIO cards to work even on non SDIO
Re: [PATCH 10/23] sched,mmc: Convert to sched_set_fifo*()
Quoted 11 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively no change in behaviour.Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
FYI: I am slowly moving towards removing the entire kthread for the sdio_irq_thread(). It shouldn't be too far off to be posted, one or two kernel releases or so.
Kind regards
Uffe
Quoted 21 lines
--- drivers/mmc/core/sdio_irq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mmc/core/sdio_irq.c +1
-2@@ -139,11 +139,10 @@ EXPORT_SYMBOL_GPL(sdio_signal_irq);static int sdio_irq_thread (void *_host) {struct mmc_host *host = _host; -struct sched_param param = { .sched_priority =1 };unsigned long period, idle_period;int ret; -sched_setscheduler (current,SCHED_FIFO , ¶m); +sched_set_fifo_low (current);/* * We want to allow for SDIO cards to work even on non SDIO
Peter Zijlstra
maintainerRe: [PATCH 10/23] sched,mmc: Convert to sched_set_fifo*()
Quoted 6 lines · Ulf Hansson
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Quoted 8 lines
Quoted 6 lines
In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively no change in behaviour.Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>Acked-by Ulf Hansson <[email protected]>
Thanks!
Quoted 3 lines
FYI: I am slowly moving towards removing the entire kthread for the
sdio_irq_thread(). It shouldn't be too far off to be posted, one or two kernel releases or so.
Moving over to regular threaded interrupts? Anyway, cool, if these series collide it's easy enough to drop this patch on the floor if it turns out obsolete.
Re: [PATCH 10/23] sched,mmc: Convert to sched_set_fifo*()
Quoted 19 lines · Peter Zijlstra
Quoted 6 lines · Ulf Hansson
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Quoted 8 lines
Quoted 6 lines
In this case, use
fifo_low, because it only cares about being aboveSCHED_NORMAL. Effectively no change in behaviour.Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>Acked-by Ulf Hansson <[email protected]>Thanks!
Quoted 7 lines
Quoted 3 lines
FYI: I am slowly moving towards removing the entire kthread for the
sdio_irq_thread(). It shouldn't be too far off to be posted, one or two kernel releases or so.Moving over to regular threaded interrupts? Anyway, cool, if these series collide it's easy enough to drop this patch on the floor if it turns out obsolete.
In principle, the only reason for the kthread is that we need it for polling - for hosts that don't support SDIO irqs. So, I am thinking of replacing the kthread with a workqueue, as we already have one for hosts that are using non-threaded IRQs.
Kind regards
Uffe
Peter Zijlstra
maintainerPATCH 11/23 sched,spi: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
No effective change.
--- drivers/platform/chrome/cros_ec_spi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/platform/chrome/cros_ec_spi.c +1 -5
@@ -709,9 +709,6 @@ static void cros_ec_spi_high_pri_releasestatic int cros_ec_spi_devm_high_pri_alloc (struct device *dev,struct cros_ec_spi *ec_spi) { -struct sched_param sched_priority = { - .sched_priority =MAX_RT_PRIO /2 , - };int err; ec_spi->high_pri_worker =
@@ -728,8 +725,7 @@ static int cros_ec_spi_devm_high_pri_allif (err)return err; - err =sched_setscheduler_nocheck (ec_spi->high_pri_worker->task, -SCHED_FIFO , &sched_priority); + err =sched_set_fifo (ec_spi->high_pri_worker->task);if (err)dev_err (dev,"Can't set cros_ec high pri priority: %d\n" , err);return err;
drivers/spi/spi.c +1 -3
@@ -1589,11 +1589,9 @@ EXPORT_SYMBOL_GPL(spi_take_timestamp_pos*/ static void spi_set_thread_rt (struct spi_controller *ctlr) { -struct sched_param param = { .sched_priority =MAX_RT_PRIO /2 }; -dev_info (&ctlr->dev,"will run message pump with realtime priority\n" ); -sched_setscheduler (ctlr->kworker_task,SCHED_FIFO , ¶m); +sched_set_fifo (ctlr->kworker_task); }static int spi_init_queue (struct spi_controller *ctlr)
Mark Brown
maintainerRe: [PATCH 11/23] sched,spi: Convert to sched_set_fifo*()
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.No effective change.
Copying Doug who did this change and Guenter who reviewed it. This looks fine to me but I've no particular involvement with the code or platforms that are affected here.
Quoted 46 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/platform/chrome/cros_ec_spi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/platform/chrome/cros_ec_spi.c +1
-5@@ -709,9 +709,6 @@ static void cros_ec_spi_high_pri_releasestatic int cros_ec_spi_devm_high_pri_alloc (struct device *dev,struct cros_ec_spi *ec_spi) { -struct sched_param sched_priority = { - .sched_priority =MAX_RT_PRIO /2 , - };int err; ec_spi->high_pri_worker =@@ -728,8 +725,7 @@ static int cros_ec_spi_devm_high_pri_allif (err)return err; - err =sched_setscheduler_nocheck (ec_spi->high_pri_worker->task, -SCHED_FIFO , &sched_priority); + err =sched_set_fifo (ec_spi->high_pri_worker->task);if (err)dev_err (dev,"Can't set cros_ec high pri priority: %d\n" , err);return err;drivers/spi/spi.c +1
-3@@ -1589,11 +1589,9 @@ EXPORT_SYMBOL_GPL(spi_take_timestamp_pos*/ static void spi_set_thread_rt (struct spi_controller *ctlr) { -struct sched_param param = { .sched_priority =MAX_RT_PRIO /2 }; -dev_info (&ctlr->dev,"will run message pump with realtime priority\n" ); -sched_setscheduler (ctlr->kworker_task,SCHED_FIFO , ¶m); +sched_set_fifo (ctlr->kworker_task); }static int spi_init_queue (struct spi_controller *ctlr)
Doug Anderson
Reviewed-byRe: [PATCH 11/23] sched,spi: Convert to sched_set_fifo*()
Hi,
Quoted 11 lines · Mark Brown
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.No effective change.
Copying Doug who did this change and Guenter who reviewed it. This looks fine to me but I've no particular involvement with the code or platforms that are affected here.
Thanks! Probably the maintainers of cros_ec_spi.c (Benson and Enric) should be aware of it, too. CCing them.
From my point of view, my response is pretty much identical to the one I wrote when the priority was reduced from "MAX_RT_PRIO - 1" to "MAX_RT_PRIO / 2" [1]. Basically, any priority that keeps us from being preempted by tasks that are only high priority for performance reasons (like dm crypt and loopback did when I last analyzed) is fine. Our priority needs to be high not for performance reasons but for correctness reasons (the other side will drop our data if we don't respond in time).
Thus:
[1] https://lore.kernel.org/r/CAD=FV=UsYF1R6+XRfFFFm6PfmkTsEOfxxgCw2JxCnpyu1kGVLQ@mail.gmail.com
Quoted 46 lines
Quoted 46 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/platform/chrome/cros_ec_spi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/platform/chrome/cros_ec_spi.c +1
-5@@ -709,9 +709,6 @@ static void cros_ec_spi_high_pri_releasestatic int cros_ec_spi_devm_high_pri_alloc (struct device *dev,struct cros_ec_spi *ec_spi) { -struct sched_param sched_priority = { - .sched_priority =MAX_RT_PRIO /2 , - };int err; ec_spi->high_pri_worker =@@ -728,8 +725,7 @@ static int cros_ec_spi_devm_high_pri_allif (err)return err; - err =sched_setscheduler_nocheck (ec_spi->high_pri_worker->task, -SCHED_FIFO , &sched_priority); + err =sched_set_fifo (ec_spi->high_pri_worker->task);if (err)dev_err (dev,"Can't set cros_ec high pri priority: %d\n" , err);return err;drivers/spi/spi.c +1
-3@@ -1589,11 +1589,9 @@ EXPORT_SYMBOL_GPL(spi_take_timestamp_pos*/ static void spi_set_thread_rt (struct spi_controller *ctlr) { -struct sched_param param = { .sched_priority =MAX_RT_PRIO /2 }; -dev_info (&ctlr->dev,"will run message pump with realtime priority\n" ); -sched_setscheduler (ctlr->kworker_task,SCHED_FIFO , ¶m); +sched_set_fifo (ctlr->kworker_task); }static int spi_init_queue (struct spi_controller *ctlr)
Guenter Roeck
Reviewed-byRe: [PATCH 11/23] sched,spi: Convert to sched_set_fifo*()
Quoted 19 lines · Doug Anderson
Hi,
Quoted 11 lines · Mark Brown
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.No effective change.
Copying Doug who did this change and Guenter who reviewed it. This looks fine to me but I've no particular involvement with the code or platforms that are affected here.
Thanks! Probably the maintainers of
cros_ec_spi.c(Benson and Enric) should be aware of it, too. CCing them.
Quoted 9 lines
From my point of view, my response is pretty much identical to the one I wrote when the priority was reduced from "
MAX_RT_PRIO- 1" to "MAX_RT_PRIO/ 2" [1]. Basically, any priority that keeps us from being preempted by tasks that are only high priority for performance reasons (like dm crypt and loopback did when I last analyzed) is fine. Our priority needs to be high not for performance reasons but for correctness reasons (the other side will drop our data if we don't respond in time).
The crypto engine ends up running at the same priority level, so I am a bit concerned that this patch series will re-introduce the problem that Doug's initial patch tried to solve. Though I do notice that it already _is_ running at the same priority, so maybe the problem has already been re-introduced with the commit that set the priority to MAX_RT_PRIO / 2, and we just haven't noticed yet. So I guess this patch indeed doesn't make a difference.
Quoted 54 lines
Thus:
Reviewed-by Douglas Anderson <[email protected]>[1] https://lore.kernel.org/r/CAD=FV=UsYF1R6+XRfFFFm6PfmkTsEOfxxgCw2JxCnpyu1kGVLQ@mail.gmail.com
Quoted 46 lines
Quoted 46 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/platform/chrome/cros_ec_spi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/platform/chrome/cros_ec_spi.c +1
-5@@ -709,9 +709,6 @@ static void cros_ec_spi_high_pri_releasestatic int cros_ec_spi_devm_high_pri_alloc (struct device *dev,struct cros_ec_spi *ec_spi) { -struct sched_param sched_priority = { - .sched_priority =MAX_RT_PRIO /2 , - };int err; ec_spi->high_pri_worker =@@ -728,8 +725,7 @@ static int cros_ec_spi_devm_high_pri_allif (err)return err; - err =sched_setscheduler_nocheck (ec_spi->high_pri_worker->task, -SCHED_FIFO , &sched_priority); + err =sched_set_fifo (ec_spi->high_pri_worker->task);if (err)dev_err (dev,"Can't set cros_ec high pri priority: %d\n" , err);return err;drivers/spi/spi.c +1
-3@@ -1589,11 +1589,9 @@ EXPORT_SYMBOL_GPL(spi_take_timestamp_pos*/ static void spi_set_thread_rt (struct spi_controller *ctlr) { -struct sched_param param = { .sched_priority =MAX_RT_PRIO /2 }; -dev_info (&ctlr->dev,"will run message pump with realtime priority\n" ); -sched_setscheduler (ctlr->kworker_task,SCHED_FIFO , ¶m); +sched_set_fifo (ctlr->kworker_task); }static int spi_init_queue (struct spi_controller *ctlr)
Re: [PATCH 11/23] sched,spi: Convert to sched_set_fifo*()
Hi,
Quoted 30 lines · Guenter Roeck
Quoted 19 lines · Doug Anderson
Hi,
Quoted 11 lines · Mark Brown
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.No effective change.
Copying Doug who did this change and Guenter who reviewed it. This looks fine to me but I've no particular involvement with the code or platforms that are affected here.
Thanks! Probably the maintainers of
cros_ec_spi.c(Benson and Enric) should be aware of it, too. CCing them.Quoted 9 lines
From my point of view, my response is pretty much identical to the one I wrote when the priority was reduced from "
MAX_RT_PRIO- 1" to "MAX_RT_PRIO/ 2" [1]. Basically, any priority that keeps us from being preempted by tasks that are only high priority for performance reasons (like dm crypt and loopback did when I last analyzed) is fine. Our priority needs to be high not for performance reasons but for correctness reasons (the other side will drop our data if we don't respond in time).
Quoted 3 lines
The crypto engine ends up running at the same priority level, so I am a bit concerned that this patch series will re-introduce the problem that Doug's initial patch tried to solve.
Do you have a pointer to the code you're looking at? Digging through my old investigation for dm-crypt showed the problem to be the code touched by commit a1b89132dc4f ("dm crypt: useWQ_HIGHPRI for the IO and crypt workqueues"). Interestingly enough, that's been reverted in commit f612b2132db5 ("Revert "dm crypt: use WQ_HIGHPRI for the IO and crypt workqueues"").
Even if something is using WQ_HIGHPRI, last I checked WQ_HIGHPRI was the highest non-relatime priority. Looking quickly I see "HIGHPRI_NICE_LEVEL" which is MIN_NICE. I don't think that implies realtime, but I assume sched_fifo() still does.
-Doug
Re: [PATCH 11/23] sched,spi: Convert to sched_set_fifo*()
Quoted 34 lines · Doug Anderson
Hi,
Quoted 30 lines · Guenter Roeck
Quoted 28 lines · Doug Anderson
Hi,
Quoted 11 lines · Mark Brown
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.No effective change.
Copying Doug who did this change and Guenter who reviewed it. This looks fine to me but I've no particular involvement with the code or platforms that are affected here.
Thanks! Probably the maintainers of
cros_ec_spi.c(Benson and Enric) should be aware of it, too. CCing them.From my point of view, my response is pretty much identical to the one I wrote when the priority was reduced from "
MAX_RT_PRIO- 1" to "MAX_RT_PRIO/ 2" [1]. Basically, any priority that keeps us from being preempted by tasks that are only high priority for performance reasons (like dm crypt and loopback did when I last analyzed) is fine. Our priority needs to be high not for performance reasons but for correctness reasons (the other side will drop our data if we don't respond in time).
Quoted 5 lines
Quoted 3 lines
The crypto engine ends up running at the same priority level, so I am a bit concerned that this patch series will re-introduce the problem that Doug's initial patch tried to solve.
Do you have a pointer to the code you're looking at? Digging through
I was looking at crypto/crypto_engine.c:crypto_engine_alloc_init(). Maybe that is different code and I misunderstand its use, though.
Guenter
Quoted 12 lines
my old investigation for dm-crypt showed the problem to be the code touched by commit
a1b89132dc4f("dm crypt: useWQ_HIGHPRIfor the IO and crypt workqueues"). Interestingly enough, that's been reverted in commitf612b2132db5("Revert "dm crypt: useWQ_HIGHPRIfor the IO and crypt workqueues"").Even if something is using
WQ_HIGHPRI, last I checkedWQ_HIGHPRIwas the highest non-relatime priority. Looking quickly I see "HIGHPRI_NICE_LEVEL" which isMIN_NICE. I don't think that implies realtime, but I assumesched_fifo()still does.-Doug
Peter Zijlstra
maintainerPATCH 12/23 sched,powercap: Convert to sched_set_fifo*()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- drivers/powercap/idle_inject.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/powercap/idle_inject.c +1 -3
@@ -255,9 +255,7 @@ void idle_inject_stop(struct idle_inject*/ static void idle_inject_setup (unsigned int cpu) { -struct sched_param param = { .sched_priority =MAX_USER_RT_PRIO /2 }; - -sched_setscheduler (current,SCHED_FIFO , ¶m); +sched_set_fifo (current); }/**
Peter Zijlstra
maintainerPATCH 13/23 sched,ion: Convert to sched_set_normal()
In reply to Peter ZijlstraIn an attempt to take away sched_setscheduler() from modules, change this into sched_set_normal(.nice = 19).
--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/android/ion/ion_heap.c +1 -3
@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,
@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );return 0 ; }
Vincent Guittot
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 23 lines · Peter Zijlstra
In an attempt to take away
sched_setscheduler()from modules, change this intosched_set_normal(.nice = 19).Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/android/ion/ion_heap.c +0
-2@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,
drivers/staging/android/ion/ion_heap.c int ion_heap_init_deferred_free(struct i · line 256
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +1
-1@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );
Would it make sense to have a sched_set_idle(task) to enable kernel setting SCHED_IDLE task ?
SCHED_NORMAL w/ nice 19 and SCHED_IDLE tasks are not treated in the same way when checking for preemption at wakeup
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +0
-0return 0 ; }
Peter Zijlstra
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 33 lines · Vincent Guittot
Quoted 23 lines · Peter Zijlstra
In an attempt to take away
sched_setscheduler()from modules, change this intosched_set_normal(.nice = 19).Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/android/ion/ion_heap.c +0
-2@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,drivers/staging/android/ion/ion_heap.c int ion_heap_init_deferred_free(struct i · line 256
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +1
-1@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );Would it make sense to have a
sched_set_idle(task)to enable kernel settingSCHED_IDLEtask ?
Quoted 2 lines
SCHED_NORMALw/ nice 19 andSCHED_IDLEtasks are not treated in the same way when checking for preemption at wakeup
Yeah, but does it really matter? I did indeed consider it, but got lazy. Is there a definite need for IDLE?
Vincent Guittot
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 35 lines · Peter Zijlstra
Quoted 33 lines · Vincent Guittot
Quoted 23 lines · Peter Zijlstra
In an attempt to take away
sched_setscheduler()from modules, change this intosched_set_normal(.nice = 19).Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/android/ion/ion_heap.c +0
-2@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,drivers/staging/android/ion/ion_heap.c int ion_heap_init_deferred_free(struct i · line 256
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +1
-1@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );Would it make sense to have a
sched_set_idle(task)to enable kernel settingSCHED_IDLEtask ?
Quoted 5 lines
Quoted 2 lines
SCHED_NORMALw/ nice 19 andSCHED_IDLEtasks are not treated in the same way when checking for preemption at wakeupYeah, but does it really matter? I did indeed consider it, but got lazy. Is there a definite need for IDLE?
John is the best to answer this for this driver but SCHED_IDLE will let other tasks which might be involved in end user interaction like on Android to run first
Peter Zijlstra
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 39 lines · Vincent Guittot
Quoted 38 lines · Peter Zijlstra
Quoted 35 lines · Vincent Guittot
Quoted 23 lines · Peter Zijlstra
In an attempt to take away
sched_setscheduler()from modules, change this intosched_set_normal(.nice = 19).Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/android/ion/ion_heap.c +0
-2@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,drivers/staging/android/ion/ion_heap.c int ion_heap_init_deferred_free(struct i · line 256
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +1
-1@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );Would it make sense to have a
sched_set_idle(task)to enable kernel settingSCHED_IDLEtask ?
SCHED_NORMALw/ nice 19 andSCHED_IDLEtasks are not treated in the same way when checking for preemption at wakeup
Quoted 6 lines
Quoted 2 lines
Yeah, but does it really matter? I did indeed consider it, but got lazy. Is there a definite need for IDLE?
John is the best to answer this for this driver but
SCHED_IDLEwill let other tasks which might be involved in end user interaction like on Android to run first
So I don't much like SCHED_IDLE because it introduces some pretty horrible tail latencies. Consider the IDLE task holding a lock, then the lock waiter will have to wait until the task gets around to running.
It's not unbounded, like a true idle-time scheduler would be, but it can still be pretty horrible. nice19 has some of that too of course, but idle has it worse, esp. also because it begs others to preempt it.
I should get back to proxy execution I suppose...
Vincent Guittot
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 44 lines · Peter Zijlstra
Quoted 42 lines · Vincent Guittot
Quoted 40 lines · Peter Zijlstra
Quoted 33 lines · Vincent Guittot
Quoted 23 lines · Peter Zijlstra
In an attempt to take away
sched_setscheduler()from modules, change this intosched_set_normal(.nice = 19).Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/android/ion/ion_heap.c +0
-2@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,drivers/staging/android/ion/ion_heap.c int ion_heap_init_deferred_free(struct i · line 256
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +1
-1@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );Would it make sense to have a
sched_set_idle(task)to enable kernel settingSCHED_IDLEtask ?Quoted 2 lines
SCHED_NORMALw/ nice 19 andSCHED_IDLEtasks are not treated in the same way when checking for preemption at wakeupYeah, but does it really matter? I did indeed consider it, but got lazy. Is there a definite need for IDLE?
Quoted 7 lines
Quoted 3 lines
John is the best to answer this for this driver but
SCHED_IDLEwill let other tasks which might be involved in end user interaction like on Android to run firstSo I don't much like
SCHED_IDLEbecause it introduces some pretty horrible tail latencies. Consider the IDLE task holding a lock, then the lock waiter will have to wait until the task gets around to running.
Yes one must be careful when using it
Quoted 4 lines
It's not unbounded, like a true idle-time scheduler would be, but it can still be pretty horrible. nice19 has some of that too of course, but idle has it worse, esp. also because it begs others to preempt it.
Yeah... you have to pay the benefit of letting other tasks to preempt faster. But both sched_idle and nice19 have the same weight and as a result they will have the same amount of running time. So I'm not sure that sched-idle will have bigger problems than nice 19 but may be more often
Quoted 2 lines
I should get back to proxy execution I suppose...
Peter Zijlstra
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 6 lines · Vincent Guittot
Quoted 3 lines
It's not unbounded, like a true idle-time scheduler would be, but it can still be pretty horrible. nice19 has some of that too of course, but idle has it worse, esp. also because it begs others to preempt it.
Yeah... you have to pay the benefit of letting other tasks to preempt faster. But both
sched_idleand nice19 have the same weight
#define WEIGHT_IDLEPRIO 3
/* 15 */ 36, 29, 23, 18, 15,
15 != 3
Also, like said elsewhere, idle is much more eager to let itself be preempted.
Vincent Guittot
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 6 lines · Peter Zijlstra
Quoted 4 lines · Vincent Guittot
Quoted 3 lines
It's not unbounded, like a true idle-time scheduler would be, but it can still be pretty horrible. nice19 has some of that too of course, but idle has it worse, esp. also because it begs others to preempt it.
Quoted 8 lines
Quoted 2 lines
Yeah... you have to pay the benefit of letting other tasks to preempt faster. But both
sched_idleand nice19 have the same weight#define
WEIGHT_IDLEPRIO3/* 15 */ 36, 29, 23, 18, 15,
15 != 3
Good point
Don't know why I thought they had same weight
Quoted 3 lines
Also, like said elsewhere, idle is much more eager to let itself be preempted.
Juri Lelli
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
In reply to Peter ZijlstraQuoted 51 lines · Peter Zijlstra
Quoted 39 lines · Vincent Guittot
Quoted 38 lines · Peter Zijlstra
Quoted 35 lines · Vincent Guittot
Quoted 23 lines · Peter Zijlstra
In an attempt to take away
sched_setscheduler()from modules, change this intosched_set_normal(.nice = 19).Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/staging/android/ion/ion_heap.c | 3 --- 1 file changed, 3 deletions(-)drivers/staging/android/ion/ion_heap.c +0
-2@@ -244,8 +244,6 @@ static int ion_heap_deferred_free(void *int ion_heap_init_deferred_free (struct ion_heap *heap) { -struct sched_param param = { .sched_priority =0 }; -INIT_LIST_HEAD (&heap->free_list);init_waitqueue_head (&heap->waitqueue); heap->task = kthread_run(ion_heap_deferred_free, heap,drivers/staging/android/ion/ion_heap.c int ion_heap_init_deferred_free(struct i · line 256
Quoted 5 lines
drivers/staging/android/ion/ion_heap.c +1
-1@@ -255,7 +253,7 @@ int ion_heap_init_deferred_free(struct i __func__);return PTR_ERR_OR_ZERO (heap->task); } -sched_setscheduler (heap->task,SCHED_IDLE , ¶m); +sched_set_normal (heap->task,19 );Would it make sense to have a
sched_set_idle(task)to enable kernel settingSCHED_IDLEtask ?
SCHED_NORMALw/ nice 19 andSCHED_IDLEtasks are not treated in the same way when checking for preemption at wakeupQuoted 6 lines
Quoted 2 lines
Yeah, but does it really matter? I did indeed consider it, but got lazy. Is there a definite need for IDLE?
John is the best to answer this for this driver but
SCHED_IDLEwill let other tasks which might be involved in end user interaction like on Android to run firstSo I don't much like
SCHED_IDLEbecause it introduces some pretty horrible tail latencies. Consider the IDLE task holding a lock, then the lock waiter will have to wait until the task gets around to running.
Quoted 5 lines
It's not unbounded, like a true idle-time scheduler would be, but it can still be pretty horrible. nice19 has some of that too of course, but idle has it worse, esp. also because it begs others to preempt it.
I should get back to proxy execution I suppose...
Huh, so you really think proxy exec should be default on for kernel mutexes...
Peter Zijlstra
maintainerRe: [PATCH 13/23] sched,ion: Convert to sched_set_normal()
Quoted 6 lines · Juri Lelli
Quoted 1 line · Peter Zijlstra
I should get back to proxy execution I suppose...
Huh, so you really think proxy exec should be default on for kernel mutexes...
We'll see, ideally yes, but even if not, then you have something to give to people who run into trouble.
It would also allow a true idle time class, although I'm not sure we'd actually want to go there.
Peter Zijlstra
maintainerPATCH 14/23 sched,powerclamp: Convert to sched_set_fifo()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- drivers/thermal/intel/intel_powerclamp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +1 -4
@@ -70,9 +70,6 @@ static unsigned int control_cpu; /* The*/ static bool clamping; -static const struct sched_param sparam = { - .sched_priority =MAX_USER_RT_PRIO /2 , -};struct powerclamp_worker_data {struct kthread_worker *worker;struct kthread_work balancing_work;
@@ -488,7 +485,7 @@ static void start_power_clamp_worker(uns w_data->cpu = cpu; w_data->clamping = true;set_bit (cpu, cpu_clamping_mask); -sched_setscheduler (worker->task,SCHED_FIFO , &sparam); +sched_set_fifo (worker->task);kthread_init_work (&w_data->balancing_work, clamp_balancing_func);kthread_init_delayed_work (&w_data->idle_injection_work, clamp_idle_injection_func);
Peter Zijlstra
maintainerPATCH 15/23 sched,serial: Convert to sched_set_fifo()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- drivers/tty/serial/sc16is7xx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/sc16is7xx.c +1 -2
@@ -1178,7 +1178,6 @@ static int sc16is7xx_probe(struct deviceconst struct sc16is7xx_devtype *devtype, struct regmap *regmap, int irq, unsigned long flags) { - struct sched_param sched_param = { .sched_priority = MAX_RT_PRIO / 2 }; unsigned long freq = 0, *pfreq = dev_get_platdata(dev);u32 uartclk =0 ;int i, ret;
@@ -1228,7 +1227,7 @@ static int sc16is7xx_probe(struct device ret =PTR_ERR (s->kworker_task); goto out_clk; } -sched_setscheduler (s->kworker_task,SCHED_FIFO , &sched_param); +sched_set_fifo (s->kworker_task);#ifdef CONFIG_GPIOLIB if (devtype->nr_gpio) {
Peter Zijlstra
maintainerPATCH 16/23 sched,watchdog: Convert to sched_set_fifo()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively changes prio from 99 to 50.
--- drivers/watchdog/watchdog_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/watchdog/watchdog_dev.c +1 -2
@@ -1144,14 +1144,13 @@ void watchdog_dev_unregister(struct watcint __init watchdog_dev_init (void ) {int err; -struct sched_param param = {.sched_priority =MAX_RT_PRIO -1 ,}; watchdog_kworker =kthread_create_worker (0 ,"watchdogd" );if (IS_ERR (watchdog_kworker)) {pr_err ("Failed to create watchdog kworker\n" );return PTR_ERR (watchdog_kworker); } -sched_setscheduler (watchdog_kworker->task,SCHED_FIFO , ¶m); +sched_set_fifo (watchdog_kworker->task); err =class_register (&watchdog_class);if (err <0 ) {
Steven Rostedt
reviewerRe: [PATCH 16/23] sched,watchdog: Convert to sched_set_fifo()
Quoted 5 lines · On Wed, 22 Apr 2020 13:27:35 +0200 Peter Zijlstra <[email protected]> wrote:
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
Hmm, this being a watchdog, and looking at commit 38a1222ae4f364d ("watchdog: core: make sure the watchdog worker always works")
I wonder if we should add a sched_set_high(), or have some other kind of watchdog handler that is guaranteed to trigger.
-- Steve
Quoted 27 lines
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>--- drivers/watchdog/watchdog_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/watchdog/watchdog_dev.c +1
-2@@ -1144,14 +1144,13 @@ void watchdog_dev_unregister(struct watcint __init watchdog_dev_init (void ) {int err; -struct sched_param param = {.sched_priority =MAX_RT_PRIO -1 ,}; watchdog_kworker =kthread_create_worker (0 ,"watchdogd" );if (IS_ERR (watchdog_kworker)) {pr_err ("Failed to create watchdog kworker\n" );return PTR_ERR (watchdog_kworker); } -sched_setscheduler (watchdog_kworker->task,SCHED_FIFO , ¶m); +sched_set_fifo (watchdog_kworker->task); err =class_register (&watchdog_class);if (err <0 ) {
Peter Zijlstra
maintainerRe: [PATCH 16/23] sched,watchdog: Convert to sched_set_fifo()
Quoted 7 lines · Steven Rostedt
Quoted 4 lines · On Wed, 22 Apr 2020 13:27:35 +0200 Peter Zijlstra <[email protected]> wrote:
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Quoted 7 lines
Quoted 1 line
Effectively changes prio from 99 to 50.
Hmm, this being a watchdog, and looking at commit
38a1222ae4f364d("watchdog: core: make sure the watchdog worker always works")I wonder if we should add a
sched_set_high(), or have some other kind of watchdog handler that is guaranteed to trigger.
It's FIFO, it'll never win from either a deadline or a stop-task. After that it doesn't matter.
fifo_high() is most definitely a bad idea, because then we're back into the whole 'fifo priority' has meaning -- it does not. At least, it doesn't until you've got system design information.
Maybe we should rename fifo_low to get away from that. I just drew a blank on a better name there.
Re: [PATCH 16/23] sched,watchdog: Convert to sched_set_fifo()
Hi Peter,
Le 22/04/2020 à 15:24, Peter Zijlstra a écrit :
Quoted 10 lines · Steven Rostedt
Quoted 9 lines
Quoted 5 lines · On Wed, 22 Apr 2020 13:27:35 +0200 Peter Zijlstra <[email protected]> wrote:
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
Quoted 8 lines
Quoted 5 lines
Hmm, this being a watchdog, and looking at commit
38a1222ae4f364d("watchdog: core: make sure the watchdog worker always works")I wonder if we should add a
sched_set_high(), or have some other kind of watchdog handler that is guaranteed to trigger.It's FIFO, it'll never win from either a deadline or a stop-task. After that it doesn't matter.
It does matter. I didn't realise it when you sent out this patch five years ago, but today I'm facing an issue due to that patch. On powerpc 8xx the watchdog must be woken up every second, the HW is not able to take a higher timeout. I have process that is running at SCHED_FIFO prio 90. From time to time it keeps running for a bit more than one second, leading to a watchdog reset. This didn't happen before your patch.
Why having arbitrary selected prio 50 and not kept it at the highest possible priority ?
What would be the solution to fix this unexpected watchdog reset ?
Quoted 4 lines
fifo_high()is most definitely a bad idea, because then we're back into the whole 'fifo priority' has meaning -- it does not. At least, it doesn't until you've got system design information.
I don't understand why it has no meaning. When I have a user app at FIFO prio 90 and one at FIFO 89 I know the one at 90 will immediatly preempt the one at 89 when receiving data, and that's the behaviour I expect. What am I missing here ?
Christophe
Peter Zijlstra
maintainerRe: [PATCH 16/23] sched,watchdog: Convert to sched_set_fifo()
Quoted 29 lines · Christophe Leroy
Hi Peter,
Le 22/04/2020 à 15:24, Peter Zijlstra a écrit :
Quoted 10 lines · Steven Rostedt
Quoted 9 lines
Quoted 5 lines · On Wed, 22 Apr 2020 13:27:35 +0200 Peter Zijlstra <[email protected]> wrote:
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
Quoted 8 lines
Quoted 5 lines
Hmm, this being a watchdog, and looking at commit
38a1222ae4f364d("watchdog: core: make sure the watchdog worker always works")I wonder if we should add a
sched_set_high(), or have some other kind of watchdog handler that is guaranteed to trigger.It's FIFO, it'll never win from either a deadline or a stop-task. After that it doesn't matter.
It does matter. I didn't realise it when you sent out this patch five years ago, but today I'm facing an issue due to that patch. On powerpc 8xx the watchdog must be woken up every second, the HW is not able to take a higher timeout. I have process that is running at
SCHED_FIFOprio 90. From time to time it keeps running for a bit more than one second, leading to a watchdog reset. This didn't happen before your patch.
Quoted 2 lines
Why having arbitrary selected prio 50 and not kept it at the highest possible priority ?
Because if your random program of choice would have had a prio-90 task that was super duper more important -- like stopping the saw from taking off your fingers that had a runtime of mere milliseconds, then having the watchdog thread delay that could be catastrophic, no?
Quoted 11 lines
What would be the solution to fix this unexpected watchdog reset ?
Quoted 4 lines
fifo_high()is most definitely a bad idea, because then we're back into the whole 'fifo priority' has meaning -- it does not. At least, it doesn't until you've got system design information.I don't understand why it has no meaning. When I have a user app at FIFO prio 90 and one at FIFO 89 I know the one at 90 will immediatly preempt the one at 89 when receiving data, and that's the behaviour I expect. What am I missing here ?
The 'until you've got system design information' bit. Not until you have the domain expertise of all possible runnable tasks on your system, can you determine FIFO priorities.
The thing is; you cannot design two programs that use FIFO in isolation and blindly smash them together and expect it to work. FIFO is fundamentally non-composable.
Someone has to go and set the priority of every FIFO task on the system, otherwise things will not work. This very much includes the watchdog thread.
So the solution is to know your setup and do your setup, including the watchdog thread priority.
Peter Zijlstra
maintainerPATCH 17/23 sched,irq: Convert to sched_set_fifo()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- kernel/irq/manage.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/irq/manage.c +1 -5
@@ -1271,9 +1271,6 @@ static int setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) { struct task_struct *t; -struct sched_param param = { - .sched_priority =MAX_USER_RT_PRIO /2 , - }; if (!secondary) { t = kthread_create(irq_thread, new, "irq/%d-%s", irq,
@@ -1281,13 +1278,12 @@ setup_irq_thread(struct irqaction *new, }else { t =kthread_create (irq_thread, new,"irq/%d-s-%s" , irq, new->name); - param.sched_priority -=1 ; }if (IS_ERR (t))return PTR_ERR (t); -sched_setscheduler_nocheck (t,SCHED_FIFO , ¶m); +sched_set_fifo (t);/* * We keep the reference to the task struct even if
Peter Zijlstra
maintainerRe: [PATCH 17/23] sched,irq: Convert to sched_set_fifo()
Quoted 5 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively no change.
That's ofcourse a flat out lie; I wrote this before I noticed that -1 thing. It most definitely changes that. I also only noticed this while reading through my own copy after sending :-/
Quoted 6 lines
kernel/irq/manage.c +0
-1@@ -1281,13 +1278,12 @@ setup_irq_thread(struct irqaction *new, }else { t =kthread_create (irq_thread, new,"irq/%d-s-%s" , irq, new->name); - param.sched_priority -=1 ; }
Peter Zijlstra
maintainerPATCH 18/23 sched,locktorture: Convert to sched_set_fifo()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively changes prio from 99 to 50.
--- kernel/locking/locktorture.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
kernel/locking/locktorture.c +2 -8
@@ -436,8 +436,6 @@ static int torture_rtmutex_lock(void) __static void torture_rtmutex_boost (struct torture_random_state *trsp) { -int policy; -struct sched_param param;const unsigned int factor =50000 ;/* yes, quite arbitrary */ if (!rt_task (current)) {
@@ -448,8 +446,7 @@ static void torture_rtmutex_boost(struct*/ if (trsp && !(torture_random (trsp) % (cxt.nrealwriters_stress * factor))) { - policy =SCHED_FIFO ; - param.sched_priority =MAX_RT_PRIO -1 ; +sched_set_fifo (current); }else /* common case, do nothing */ return ; }else {
@@ -462,13 +459,10 @@ static void torture_rtmutex_boost(struct*/ if (!trsp || !(torture_random (trsp) % (cxt.nrealwriters_stress * factor *2 ))) { - policy =SCHED_NORMAL ; - param.sched_priority =0 ; +sched_set_normal (current,0 ); }else /* common case, do nothing */ return ; } - -sched_setscheduler_nocheck (current, policy, ¶m); }static void torture_rtmutex_delay (struct torture_random_state *trsp)
Re: [PATCH 18/23] sched,locktorture: Convert to sched_set_fifo()
Quoted 9 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively changes prio from 99 to 50.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Quoted 42 lines
--- kernel/locking/locktorture.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)kernel/locking/locktorture.c +2
-8@@ -436,8 +436,6 @@ static int torture_rtmutex_lock(void) __static void torture_rtmutex_boost (struct torture_random_state *trsp) { -int policy; -struct sched_param param;const unsigned int factor =50000 ;/* yes, quite arbitrary */ if (!rt_task (current)) {@@ -448,8 +446,7 @@ static void torture_rtmutex_boost(struct*/ if (trsp && !(torture_random (trsp) % (cxt.nrealwriters_stress * factor))) { - policy =SCHED_FIFO ; - param.sched_priority =MAX_RT_PRIO -1 ; +sched_set_fifo (current); }else /* common case, do nothing */ return ; }else {@@ -462,13 +459,10 @@ static void torture_rtmutex_boost(struct*/ if (!trsp || !(torture_random (trsp) % (cxt.nrealwriters_stress * factor *2 ))) { - policy =SCHED_NORMAL ; - param.sched_priority =0 ; +sched_set_normal (current,0 ); }else /* common case, do nothing */ return ; } - -sched_setscheduler_nocheck (current, policy, ¶m); }static void torture_rtmutex_delay (struct torture_random_state *trsp)
Peter Zijlstra
maintainerPATCH 19/23 sched,rcuperf: Convert to sched_set_fifo_low()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- kernel/rcu/rcuperf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/rcu/rcuperf.c +2 -6
@@ -353,7 +353,6 @@ rcu_perf_writer(void *arg)int i_max;long me = (long )arg;struct rcu_head *rhp =NULL ; -struct sched_param sp;bool started = false, done = false, alldone = false;u64 t;u64 *wdp;
@@ -362,8 +361,7 @@ rcu_perf_writer(void *arg)VERBOSE_PERFOUT_STRING ("rcu_perf_writer task started" );WARN_ON (!wdpp);set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids)); - sp.sched_priority =1 ; -sched_setscheduler_nocheck (current,SCHED_FIFO , &sp); +sched_set_fifo_low (current);if (holdoff)schedule_timeout_uninterruptible (holdoff *HZ );
@@ -419,9 +417,7 @@ rcu_perf_writer(void *arg) started = true;if (!done && i >=MIN_MEAS ) { done = true; - sp.sched_priority =0 ; -sched_setscheduler_nocheck (current, -SCHED_NORMAL , &sp); +sched_set_normal (current,0 );pr_alert ("%s%s rcu_perf_writer %ld has %d measurements\n" , perf_type,PERF_FLAG , me,MIN_MEAS ); if (atomic_inc_return(&n_rcu_perf_writer_finished) >=
Re: [PATCH 19/23] sched,rcuperf: Convert to sched_set_fifo_low()
Quoted 9 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively no change.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Quoted 37 lines
--- kernel/rcu/rcuperf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)kernel/rcu/rcuperf.c +2
-6@@ -353,7 +353,6 @@ rcu_perf_writer(void *arg)int i_max;long me = (long )arg;struct rcu_head *rhp =NULL ; -struct sched_param sp;bool started = false, done = false, alldone = false;u64 t;u64 *wdp;@@ -362,8 +361,7 @@ rcu_perf_writer(void *arg)VERBOSE_PERFOUT_STRING ("rcu_perf_writer task started" );WARN_ON (!wdpp);set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids)); - sp.sched_priority =1 ; -sched_setscheduler_nocheck (current,SCHED_FIFO , &sp); +sched_set_fifo_low (current);if (holdoff)schedule_timeout_uninterruptible (holdoff *HZ );@@ -419,9 +417,7 @@ rcu_perf_writer(void *arg) started = true;if (!done && i >=MIN_MEAS ) { done = true; - sp.sched_priority =0 ; -sched_setscheduler_nocheck (current, -SCHED_NORMAL , &sp); +sched_set_normal (current,0 );pr_alert ("%s%s rcu_perf_writer %ld has %d measurements\n" , perf_type,PERF_FLAG , me,MIN_MEAS ); if (atomic_inc_return(&n_rcu_perf_writer_finished) >=
Peter Zijlstra
maintainerPATCH 20/23 sched,rcutorture: Convert to sched_set_fifo_low()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- kernel/rcu/rcutorture.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/rcu/rcutorture.c +1 -3
@@ -802,13 +802,11 @@ static int rcu_torture_boost(void *arg)unsigned long endtime;unsigned long oldstarttime;struct rcu_boost_inflight rbi = { .inflight =0 }; -struct sched_param sp;VERBOSE_TOROUT_STRING ("rcu_torture_boost started" );/* Set real-time priority. */ - sp.sched_priority =1 ; -if (sched_setscheduler (current,SCHED_FIFO , &sp) <0 ) { +if (sched_set_fifo_low (current) <0 ) {VERBOSE_TOROUT_STRING ("rcu_torture_boost RT prio failed!" ); n_rcu_torture_boost_rterror++; }
Re: [PATCH 20/23] sched,rcutorture: Convert to sched_set_fifo_low()
Quoted 9 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively no change.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Quoted 23 lines
--- kernel/rcu/rcutorture.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/rcutorture.c +1
-3@@ -802,13 +802,11 @@ static int rcu_torture_boost(void *arg)unsigned long endtime;unsigned long oldstarttime;struct rcu_boost_inflight rbi = { .inflight =0 }; -struct sched_param sp;VERBOSE_TOROUT_STRING ("rcu_torture_boost started" );/* Set real-time priority. */ - sp.sched_priority =1 ; -if (sched_setscheduler (current,SCHED_FIFO , &sp) <0 ) { +if (sched_set_fifo_low (current) <0 ) {VERBOSE_TOROUT_STRING ("rcu_torture_boost RT prio failed!" ); n_rcu_torture_boost_rterror++; }
Peter Zijlstra
maintainerPATCH 21/23 sched,psi: Convert to sched_set_fifo_low()
In reply to Peter ZijlstraBecause SCHED_FIFO is a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.
Effectively no change.
--- kernel/sched/psi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/sched/psi.c +1 -4
@@ -1100,9 +1100,6 @@ struct psi_trigger *psi_trigger_create(smutex_lock (&group->trigger_lock);if (!rcu_access_pointer (group->poll_kworker)) { -struct sched_param param = { - .sched_priority =1 , - };struct kthread_worker *kworker; kworker =kthread_create_worker (0 ,"psimon" );
@@ -1111,7 +1108,7 @@ struct psi_trigger *psi_trigger_create(smutex_unlock (&group->trigger_lock);return ERR_CAST (kworker); } -sched_setscheduler_nocheck (kworker->task,SCHED_FIFO , ¶m); +sched_set_fifo_low (kworker->task);kthread_init_delayed_work (&group->poll_work, psi_poll_work);rcu_assign_pointer (group->poll_kworker, kworker);
Re: [PATCH 21/23] sched,psi: Convert to sched_set_fifo_low()
Quoted 9 lines · Peter Zijlstra
Because
SCHED_FIFOis a broken scheduler model (see previous patches) take away the priority field, the kernel can't possibly make an informed decision.Effectively no change.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Ingo Molnar <[email protected]>
Peter Zijlstra
maintainerPATCH 22/23 sched: Remove sched_setscheduler*() EXPORTs
In reply to Peter ZijlstraNow that nothing (modular) still uses sched_setscheduler(), remove the exports.
--- kernel/sched/core.c | 3 --- 1 file changed, 3 deletions(-)
kernel/sched/core.c +0 -3
@@ -5066,13 +5066,11 @@ int sched_setscheduler(struct task_struc {return _sched_setscheduler (p, policy, param, true); } -EXPORT_SYMBOL_GPL (sched_setscheduler);int sched_setattr (struct task_struct *p,const struct sched_attr *attr) {return __sched_setscheduler (p, attr, true, true); } -EXPORT_SYMBOL_GPL (sched_setattr);int sched_setattr_nocheck (struct task_struct *p,const struct sched_attr *attr) {
@@ -5097,7 +5095,6 @@ int sched_setscheduler_nocheck(struct ta {return _sched_setscheduler (p, policy, param, false); } -EXPORT_SYMBOL_GPL (sched_setscheduler_nocheck);/* * SCHED_FIFO is a broken scheduler model; that is, it is fundamentally
Peter Zijlstra
maintainerPATCH 23/23 sched: Remove sched_set_*() return value
In reply to Peter ZijlstraIngo suggested that since the new sched_set_*() functions are implemented using the 'nocheck' variants, they really shouldn't ever fail, so remove the return value.
--- drivers/block/drbd/drbd_receiver.c | 4 +--- drivers/firmware/psci/psci_checker.c | 3 +-- drivers/gpu/drm/msm/msm_drv.c | 5 +---- drivers/platform/chrome/cros_ec_spi.c | 7 +++---- include/linux/sched.h | 6 +++--- kernel/rcu/rcutorture.c | 5 +---- kernel/sched/core.c | 12 ++++++------ 7 files changed, 16 insertions(+), 26 deletions(-)
drivers/block/drbd/drbd_receiver.c +1 -3
@@ -6021,9 +6021,7 @@ int drbd_ack_receiver(struct drbd_threadint expect = header_size;bool ping_timeout_active = false; - rv =sched_set_fifo_low (current); -if (rv <0 ) -drbd_err (connection,"drbd_ack_receiver: ERROR set priority, ret=%d\n" , rv); +sched_set_fifo_low (current);while (get_t_state (thi) ==RUNNING ) {drbd_thread_current_set_cpu (thi);
drivers/firmware/psci/psci_checker.c +1 -2
@@ -281,8 +281,7 @@ static int suspend_test_thread(void *argwait_for_completion (&suspend_threads_started);/* Set maximum priority to preempt all other threads on this CPU. */ -if (sched_set_fifo (current)) -pr_warn ("Failed to set suspend thread scheduler on CPU %d\n" , cpu); +sched_set_fifo (current); dev =this_cpu_read (cpuidle_devices); drv =cpuidle_get_cpu_driver (dev);
drivers/gpu/drm/msm/msm_drv.c +1 -4
@@ -508,10 +508,7 @@ static int msm_drm_init(struct device *d goto err_msm_uninit; } - ret =sched_set_fifo (priv->event_thread[i].thread); -if (ret) -dev_warn (dev,"event_thread set priority failed:%d\n" , - ret); +sched_set_fifo (priv->event_thread[i].thread); } ret =drm_vblank_init (ddev, priv->num_crtcs);
drivers/platform/chrome/cros_ec_spi.c +3 -4
@@ -725,10 +725,9 @@ static int cros_ec_spi_devm_high_pri_allif (err)return err; - err =sched_set_fifo (ec_spi->high_pri_worker->task); -if (err) -dev_err (dev,"Can't set cros_ec high pri priority: %d\n" , err); -return err; +sched_set_fifo (ec_spi->high_pri_worker->task); + +return 0 ; }static int cros_ec_spi_probe (struct spi_device *spi)
include/linux/sched.h +3 -3
@@ -1631,9 +1631,9 @@ extern int idle_cpu(int cpu);extern int available_idle_cpu (int cpu);extern int sched_setscheduler (struct task_struct *,int ,const struct sched_param *);extern int sched_setscheduler_nocheck (struct task_struct *,int ,const struct sched_param *); -extern int sched_set_fifo (struct task_struct *p); -extern int sched_set_fifo_low (struct task_struct *p); -extern int sched_set_normal (struct task_struct *p,int nice); +extern void sched_set_fifo (struct task_struct *p); +extern void sched_set_fifo_low (struct task_struct *p); +extern void sched_set_normal (struct task_struct *p,int nice);extern int sched_setattr (struct task_struct *,const struct sched_attr *);extern int sched_setattr_nocheck (struct task_struct *,const struct sched_attr *);extern struct task_struct *idle_task (int cpu);
kernel/rcu/rcutorture.c +1 -4
@@ -806,10 +806,7 @@ static int rcu_torture_boost(void *arg)VERBOSE_TOROUT_STRING ("rcu_torture_boost started" );/* Set real-time priority. */ -if (sched_set_fifo_low (current) <0 ) { -VERBOSE_TOROUT_STRING ("rcu_torture_boost RT prio failed!" ); - n_rcu_torture_boost_rterror++; - } +sched_set_fifo_low (current);init_rcu_head_on_stack (&rbi.rcu);/* Each pass through the following loop does one boost-test cycle. */
kernel/sched/core.c +6 -6
@@ -5114,30 +5114,30 @@ int sched_setscheduler_nocheck(struct ta* The administrator _MUST_ configure the system, the kernel simply doesn't * know enough information to make a sensible choice. */ -int sched_set_fifo (struct task_struct *p) +void sched_set_fifo (struct task_struct *p) {struct sched_param sp = { .sched_priority =MAX_RT_PRIO /2 }; -return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +WARN_ON_ONCE (sched_setscheduler_nocheck (p,SCHED_FIFO , &sp) !=0 ); }EXPORT_SYMBOL_GPL (sched_set_fifo);/* * For when you don't much care about FIFO, but want to be above SCHED_NORMAL. */ -int sched_set_fifo_low (struct task_struct *p) +void sched_set_fifo_low (struct task_struct *p) {struct sched_param sp = { .sched_priority =1 }; -return sched_setscheduler_nocheck (p,SCHED_FIFO , &sp); +WARN_ON_ONCE (sched_setscheduler_nocheck (p,SCHED_FIFO , &sp) !=0 ); }EXPORT_SYMBOL_GPL (sched_set_fifo_low); -int sched_set_normal (struct task_struct *p,int nice) +void sched_set_normal (struct task_struct *p,int nice) {struct sched_attr attr = { .sched_policy =SCHED_NORMAL , .sched_nice = nice, }; -return sched_setattr_nocheck (p, &attr); +WARN_ON_ONCE (sched_setattr_nocheck (p, &attr) !=0 ); }EXPORT_SYMBOL_GPL (sched_set_normal);
Re: [PATCH 23/23] sched: Remove sched_set_*() return value
Quoted 4 lines · Peter Zijlstra
Ingo suggested that since the new sched_set_*() functions are implemented using the 'nocheck' variants, they really shouldn't ever fail, so remove the return value.
Quoted 8 lines
Suggested-by Ingo Molnar <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Thanks,
Ingo
Paul E. McKenney
maintainerRe: [PATCH 23/23] sched: Remove sched_set_*() return value
In reply to Peter ZijlstraQuoted 12 lines · Peter Zijlstra
Ingo suggested that since the new sched_set_*() functions are implemented using the 'nocheck' variants, they really shouldn't ever fail, so remove the return value.
Suggested-by Ingo Molnar <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Quoted 9 lines
--- drivers/block/drbd/drbd_receiver.c | 4 +--- drivers/firmware/psci/psci_checker.c | 3 +-- drivers/gpu/drm/msm/msm_drv.c | 5 +---- drivers/platform/chrome/cros_ec_spi.c | 7 +++---- include/linux/sched.h | 6 +++--- kernel/rcu/rcutorture.c | 5 +---- kernel/sched/core.c | 12 ++++++------ 7 files changed, 16 insertions(+), 26 deletions(-)
[ . . . ]
Quoted 4 lines
kernel/rcu/rcutorture.c +0
-0@@ -806,10 +806,7 @@ static int rcu_torture_boost(void *arg)VERBOSE_TOROUT_STRING ("rcu_torture_boost started" );
kernel/rcu/rcutorture.c static int rcu_torture_boost(void *arg) · line 812
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-4/* Set real-time priority. */ -if (sched_set_fifo_low (current) <0 ) { -VERBOSE_TOROUT_STRING ("rcu_torture_boost RT prio failed!" ); - n_rcu_torture_boost_rterror++; - } +sched_set_fifo_low (current);init_rcu_head_on_stack (&rbi.rcu);/* Each pass through the following loop does one boost-test cycle. */
This is the only update of n_rcu_torture_boost_rterror, so it can be eliminated entirely, for example as shown below.
Other than that, looks good to me!
Thanx, Paul
------------------------------------------------------------------------
kernel/rcu/rcutorture.c +4 -12
@@ -171,7 +171,6 @@ static atomic_t n_rcu_torture_mberror;static atomic_t n_rcu_torture_error;static long n_rcu_torture_barrier_error;static long n_rcu_torture_boost_ktrerror; -static long n_rcu_torture_boost_rterror;static long n_rcu_torture_boost_failure;static long n_rcu_torture_boosts;static atomic_long_t n_rcu_torture_timers;
@@ -893,10 +892,7 @@ static int rcu_torture_boost(void *arg)VERBOSE_TOROUT_STRING ("rcu_torture_boost started" );/* Set real-time priority. */ -if (sched_set_fifo_low (current) <0 ) { -VERBOSE_TOROUT_STRING ("rcu_torture_boost RT prio failed!" ); - n_rcu_torture_boost_rterror++; - } +sched_set_fifo_low (current);init_rcu_head_on_stack (&rbi.rcu);/* Each pass through the following loop does one boost-test cycle. */
@@ -1527,11 +1523,10 @@ rcu_torture_stats_print(void)atomic_read (&n_rcu_torture_alloc),atomic_read (&n_rcu_torture_alloc_fail), atomic_read(&n_rcu_torture_free)); -pr_cont ("rtmbe: %d rtbe: %ld rtbke: %ld rtbre: %ld " , +pr_cont ("rtmbe: %d rtbe: %ld rtbke: %ld " ,atomic_read (&n_rcu_torture_mberror), n_rcu_torture_barrier_error, - n_rcu_torture_boost_ktrerror, - n_rcu_torture_boost_rterror); + n_rcu_torture_boost_ktrerror); pr_cont("rtbf: %ld rtb: %ld nt: %ld ", n_rcu_torture_boost_failure, n_rcu_torture_boosts,
@@ -1545,14 +1540,12 @@ rcu_torture_stats_print(void)pr_alert ("%s%s " , torture_type,TORTURE_FLAG );if (atomic_read (&n_rcu_torture_mberror) || n_rcu_torture_barrier_error || n_rcu_torture_boost_ktrerror || - n_rcu_torture_boost_rterror || n_rcu_torture_boost_failure || - i >1 ) { + n_rcu_torture_boost_failure || i >1 ) {pr_cont ("%s" ,"!!! " );atomic_inc (&n_rcu_torture_error);WARN_ON_ONCE (atomic_read (&n_rcu_torture_mberror));WARN_ON_ONCE (n_rcu_torture_barrier_error);// rcu_barrier() WARN_ON_ONCE (n_rcu_torture_boost_ktrerror);// no boost kthread -WARN_ON_ONCE (n_rcu_torture_boost_rterror);// can't set RT prio WARN_ON_ONCE (n_rcu_torture_boost_failure);// RCU boost failed WARN_ON_ONCE (i >1 );// Too-short grace period }
@@ -2569,7 +2562,6 @@ rcu_torture_init(void)atomic_set (&n_rcu_torture_error,0 ); n_rcu_torture_barrier_error =0 ; n_rcu_torture_boost_ktrerror =0 ; - n_rcu_torture_boost_rterror =0 ; n_rcu_torture_boost_failure =0 ; n_rcu_torture_boosts =0 ;for (i =0 ; i <RCU_TORTURE_PIPE_LEN +1 ; i++)