From: Steven Rostedt <rostedt@goodmis.org>
To: Hillf Danton <hdanton@sina.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Mike Galbraith <efault@gmx.de>,
lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] sched: make p->prio independent of p->mm
Date: Thu, 23 Apr 2020 11:01:12 -0400 [thread overview]
Message-ID: <20200423110112.3e06e508@gandalf.local.home> (raw)
In-Reply-To: <20200423141609.5224-1-hdanton@sina.com>
On Thu, 23 Apr 2020 22:16:09 +0800
Hillf Danton <hdanton@sina.com> wrote:
> On Thu, 23 Apr 2020 09:44:03 -0400 Steven Rostedt wrote:
> >
> > On Thu, 23 Apr 2020 11:26:20 +0200
> > Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > > On Thu, Apr 23, 2020 at 12:01:28PM +0800, Hillf Danton wrote:
> > > > --- a/kernel/sched/core.c
> > > > +++ b/kernel/sched/core.c
> > > > @@ -4796,13 +4796,19 @@ recheck:
> > > > return -EINVAL;
> > > >
> > > > /*
> > > > - * Valid priorities for SCHED_FIFO and SCHED_RR are
> > > > - * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL,
> > > > - * SCHED_BATCH and SCHED_IDLE is 0.
> > > > + * The MAX_USER_RT_PRIO value allows the actual maximum
> > > > + * RT priority to be separate from the value exported to
> > > > + * user-space. This allows kernel threads to set their
> > > > + * priority to a value higher than any user task.
> > > > */
> > > > - if ((p->mm && attr->sched_priority > MAX_USER_RT_PRIO-1) ||
> > > > - (!p->mm && attr->sched_priority > MAX_RT_PRIO-1))
> > > > - return -EINVAL;
> > > > + if (p->flags & PF_KTHREAD) {
> > > > + if (attr->sched_priority > MAX_RT_PRIO - 1)
> > > > + return -EINVAL;
> > > > + } else {
> > > > + if (attr->sched_priority > MAX_USER_RT_PRIO - 1)
> > > > + return -EINVAL;
> > > > + }
> > > > +
> > >
> > > Arguably we can do away with the check entirely, MAX_RT_PRIO ==
> > > MAX_USER_RT_PRIO.
> >
> > Heh, that was one of my first patches accepted in the mainline kernel! :-)
> >
> > And the reason we added it, was because there was a small time when the RT
> > patch (or my variation of it) had MAX_USER_RT_PRIO and MAX_RT_PRIO different
> > values, and would crash in that case here.
> >
> > d46523ea32a79 ("fix MAX_USER_RT_PRIO and MAX_RT_PRIO")
> >
> > I would say if we get rid of that check, get rid of the MAX_USER_RT_PRIO
> > with it, and make everything use MAX_RT_PRIO.
>
> BTW the newprio compuation at the beginning of the function looks
> questionable if that check is axed without anything added, because
> it's then used in the case of pi boost.
I believe Peter meant axing the double check, not the check together.
That is, instead of:
if (p->flags & PF_KTHREAD) {
if (attr->sched_priority > MAX_RT_PRIO - 1)
return -EINVAL;
} else {
if (attr->sched_priority > MAX_USER_RT_PRIO - 1)
return -EINVAL;
}
Just have:
if (attr->sched_priority > MAX_RT_PRIO -1)
return -EINVAL;
-- Steve
next prev parent reply other threads:[~2020-04-23 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200423040128.6120-1-hdanton@sina.com>
2020-04-23 9:26 ` [PATCH] sched: make p->prio independent of p->mm Peter Zijlstra
2020-04-23 13:44 ` Steven Rostedt
[not found] ` <20200423141609.5224-1-hdanton@sina.com>
2020-04-23 15:01 ` Steven Rostedt [this message]
[not found] ` <20200424003028.14800-1-hdanton@sina.com>
2020-04-24 0:41 ` Steven Rostedt
[not found] ` <20200424021231.13676-1-hdanton@sina.com>
2020-04-24 12:43 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200423110112.3e06e508@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=efault@gmx.de \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).