Merge tag 'sched-fifo-2020-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull sched/fifo updates from Ingo Molnar: "This adds the sched_set_fifo*() encapsulation APIs to remove static priority level knowledge from non-scheduler code. The three APIs for non-scheduler code to set SCHED_FIFO are: - sched_set_fifo() - sched_set_fifo_low() - sched_set_normal() These are two FIFO priority levels: default (high), and a 'low' priority level, plus sched_set_normal() to set the policy back to non-SCHED_FIFO. Since the changes affect a lot of non-scheduler code, we kept this in a separate tree" * tag 'sched-fifo-2020-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits) sched,tracing: Convert to sched_set_fifo() sched: Remove sched_set_*() return value sched: Remove sched_setscheduler*() EXPORTs sched,psi: Convert to sched_set_fifo_low() sched,rcutorture: Convert to sched_set_fifo_low() sched,rcuperf: Convert to sched_set_fifo_low() sched,locktorture: Convert to sched_set_fifo() sched,irq: Convert to sched_set_fifo() sched,watchdog: Convert to sched_set_fifo() sched,serial: Convert to sched_set_fifo() sched,powerclamp: Convert to sched_set_fifo() sched,ion: Convert to sched_set_normal() sched,powercap: Convert to sched_set_fifo*() sched,spi: Convert to sched_set_fifo*() sched,mmc: Convert to sched_set_fifo*() sched,ivtv: Convert to sched_set_fifo*() sched,drm/scheduler: Convert to sched_set_fifo*() sched,msm: Convert to sched_set_fifo*() sched,psci: Convert to sched_set_fifo*() sched,drbd: Convert to sched_set_fifo*() ...
This commit is contained in:
@@ -5496,6 +5496,8 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
|
||||
* @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.
|
||||
@@ -5505,13 +5507,11 @@ int sched_setscheduler(struct task_struct *p, int policy,
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -5536,7 +5536,51 @@ int sched_setscheduler_nocheck(struct task_struct *p, int policy,
|
||||
{
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
void sched_set_fifo(struct task_struct *p)
|
||||
{
|
||||
struct sched_param sp = { .sched_priority = MAX_RT_PRIO / 2 };
|
||||
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.
|
||||
*/
|
||||
void sched_set_fifo_low(struct task_struct *p)
|
||||
{
|
||||
struct sched_param sp = { .sched_priority = 1 };
|
||||
WARN_ON_ONCE(sched_setscheduler_nocheck(p, SCHED_FIFO, &sp) != 0);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sched_set_fifo_low);
|
||||
|
||||
void sched_set_normal(struct task_struct *p, int nice)
|
||||
{
|
||||
struct sched_attr attr = {
|
||||
.sched_policy = SCHED_NORMAL,
|
||||
.sched_nice = nice,
|
||||
};
|
||||
WARN_ON_ONCE(sched_setattr_nocheck(p, &attr) != 0);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sched_set_normal);
|
||||
|
||||
static int
|
||||
do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
|
||||
|
@@ -616,11 +616,8 @@ out:
|
||||
static int psi_poll_worker(void *data)
|
||||
{
|
||||
struct psi_group *group = (struct psi_group *)data;
|
||||
struct sched_param param = {
|
||||
.sched_priority = 1,
|
||||
};
|
||||
|
||||
sched_setscheduler_nocheck(current, SCHED_FIFO, ¶m);
|
||||
sched_set_fifo_low(current);
|
||||
|
||||
while (true) {
|
||||
wait_event_interruptible(group->poll_wait,
|
||||
|
Reference in New Issue
Block a user