diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 3aaa5c8cb421..7c0e7063c11f 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -4744,16 +4744,8 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio) | |||
4744 | set_load_weight(p); | 4744 | set_load_weight(p); |
4745 | } | 4745 | } |
4746 | 4746 | ||
4747 | /** | 4747 | static int __sched_setscheduler(struct task_struct *p, int policy, |
4748 | * sched_setscheduler - change the scheduling policy and/or RT priority of a thread. | 4748 | struct sched_param *param, bool user) |
4749 | * @p: the task in question. | ||
4750 | * @policy: new policy. | ||
4751 | * @param: structure containing the new RT priority. | ||
4752 | * | ||
4753 | * NOTE that the task may be already dead. | ||
4754 | */ | ||
4755 | int sched_setscheduler(struct task_struct *p, int policy, | ||
4756 | struct sched_param *param) | ||
4757 | { | 4749 | { |
4758 | int retval, oldprio, oldpolicy = -1, on_rq, running; | 4750 | int retval, oldprio, oldpolicy = -1, on_rq, running; |
4759 | unsigned long flags; | 4751 | unsigned long flags; |
@@ -4785,7 +4777,7 @@ recheck: | |||
4785 | /* | 4777 | /* |
4786 | * Allow unprivileged RT tasks to decrease priority: | 4778 | * Allow unprivileged RT tasks to decrease priority: |
4787 | */ | 4779 | */ |
4788 | if (!capable(CAP_SYS_NICE)) { | 4780 | if (user && !capable(CAP_SYS_NICE)) { |
4789 | if (rt_policy(policy)) { | 4781 | if (rt_policy(policy)) { |
4790 | unsigned long rlim_rtprio; | 4782 | unsigned long rlim_rtprio; |
4791 | 4783 | ||
@@ -4821,7 +4813,8 @@ recheck: | |||
4821 | * Do not allow realtime tasks into groups that have no runtime | 4813 | * Do not allow realtime tasks into groups that have no runtime |
4822 | * assigned. | 4814 | * assigned. |
4823 | */ | 4815 | */ |
4824 | if (rt_policy(policy) && task_group(p)->rt_bandwidth.rt_runtime == 0) | 4816 | if (user |
4817 | && rt_policy(policy) && task_group(p)->rt_bandwidth.rt_runtime == 0) | ||
4825 | return -EPERM; | 4818 | return -EPERM; |
4826 | #endif | 4819 | #endif |
4827 | 4820 | ||
@@ -4870,8 +4863,39 @@ recheck: | |||
4870 | 4863 | ||
4871 | return 0; | 4864 | return 0; |
4872 | } | 4865 | } |
4866 | |||
4867 | /** | ||
4868 | * sched_setscheduler - change the scheduling policy and/or RT priority of a thread. | ||
4869 | * @p: the task in question. | ||
4870 | * @policy: new policy. | ||
4871 | * @param: structure containing the new RT priority. | ||
4872 | * | ||
4873 | * NOTE that the task may be already dead. | ||
4874 | */ | ||
4875 | int sched_setscheduler(struct task_struct *p, int policy, | ||
4876 | struct sched_param *param) | ||
4877 | { | ||
4878 | return __sched_setscheduler(p, policy, param, true); | ||
4879 | } | ||
4873 | EXPORT_SYMBOL_GPL(sched_setscheduler); | 4880 | EXPORT_SYMBOL_GPL(sched_setscheduler); |
4874 | 4881 | ||
4882 | /** | ||
4883 | * sched_setscheduler_nocheck - change the scheduling policy and/or RT priority of a thread from kernelspace. | ||
4884 | * @p: the task in question. | ||
4885 | * @policy: new policy. | ||
4886 | * @param: structure containing the new RT priority. | ||
4887 | * | ||
4888 | * Just like sched_setscheduler, only don't bother checking if the | ||
4889 | * current context has permission. For example, this is needed in | ||
4890 | * stop_machine(): we create temporary high priority worker threads, | ||
4891 | * but our caller might not have that capability. | ||
4892 | */ | ||
4893 | int sched_setscheduler_nocheck(struct task_struct *p, int policy, | ||
4894 | struct sched_param *param) | ||
4895 | { | ||
4896 | return __sched_setscheduler(p, policy, param, false); | ||
4897 | } | ||
4898 | |||
4875 | static int | 4899 | static int |
4876 | do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param) | 4900 | do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param) |
4877 | { | 4901 | { |