lkml.org 
[lkml]   [2020]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sched: make p->prio independent of p->mm
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.

\
 
 \ /
  Last update: 2020-04-23 11:27    [W:0.038 / U:0.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site