Commit 33f18d46 authored by Robert Love's avatar Robert Love Committed by Linus Torvalds

[PATCH] clean up maximum priorities

This patch further cleans up and separates the code in an effort to
allow setting (a) a larger maximum real-time priority than default and
(b) a maximum kernel RT priority that is separate than the maximum
priority exported to user-space.
parent 38b60834
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
thread_info: &init_thread_info, \ thread_info: &init_thread_info, \
flags: 0, \ flags: 0, \
lock_depth: -1, \ lock_depth: -1, \
prio: 120, \ prio: MAX_PRIO-20, \
static_prio: 120, \ static_prio: MAX_PRIO-20, \
policy: SCHED_OTHER, \ policy: SCHED_OTHER, \
cpus_allowed: -1, \ cpus_allowed: -1, \
mm: NULL, \ mm: NULL, \
......
...@@ -206,6 +206,23 @@ struct signal_struct { ...@@ -206,6 +206,23 @@ struct signal_struct {
spinlock_t siglock; spinlock_t siglock;
}; };
/*
* Priority of a process goes from 0..MAX_PRIO-1, valid RT
* priority is 0..MAX_RT_PRIO-1, and SCHED_OTHER tasks are
* in the range MAX_RT_PRIO..MAX_PRIO-1. Priority values
* are inverted: lower p->prio value means higher priority.
*
* The MAX_RT_USER_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. Note:
* MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
*/
#define MAX_USER_RT_PRIO 100
#define MAX_RT_PRIO MAX_USER_RT_PRIO
#define MAX_PRIO (MAX_RT_PRIO + 40)
/* /*
* Some day this will be a full-fledged user tracking system.. * Some day this will be a full-fledged user tracking system..
......
...@@ -23,23 +23,9 @@ ...@@ -23,23 +23,9 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/kernel_stat.h> #include <linux/kernel_stat.h>
/*
* Priority of a process goes from 0 to 139. The 0-99
* priority range is allocated to RT tasks, the 100-139
* range is for SCHED_OTHER tasks. Priority values are
* inverted: lower p->prio value means higher priority.
*
* MAX_USER_RT_PRIO allows the actual maximum RT priority
* to be separate from the value exported to user-space.
* NOTE: MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
*/
#define MAX_RT_PRIO 100
#define MAX_USER_RT_PRIO 100
#define MAX_PRIO (MAX_RT_PRIO + 40)
/* /*
* Convert user-nice values [ -20 ... 0 ... 19 ] * Convert user-nice values [ -20 ... 0 ... 19 ]
* to static priority [ 100 ... 139 (MAX_PRIO-1) ], * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
* and back. * and back.
*/ */
#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20) #define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
...@@ -1138,8 +1124,8 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param) ...@@ -1138,8 +1124,8 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param)
} }
/* /*
* Valid priorities for SCHED_FIFO and SCHED_RR are 1..99, valid * Valid priorities for SCHED_FIFO and SCHED_RR are
* priority for SCHED_OTHER is 0. * 1..MAX_USER_RT_PRIO, valid priority for SCHED_OTHER is 0.
*/ */
retval = -EINVAL; retval = -EINVAL;
if (lp.sched_priority < 0 || lp.sched_priority > MAX_USER_RT_PRIO-1) if (lp.sched_priority < 0 || lp.sched_priority > MAX_USER_RT_PRIO-1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment