Commit c13db6b1 authored by Steven Rostedt's avatar Steven Rostedt Committed by Ingo Molnar

sched: Use macro for magic number of -1 for setparam

Instead of passing around a magic number -1 for the sched_setparam()
policy, use a more descriptive macro name like SETPARAM_POLICY.

[ based on top of Daniel's sched_setparam() fix ]
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: Daniel Bristot de Oliveira<bristot@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140723112826.6ed6cbce@gandalf.local.homeSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 6ae72dff
...@@ -3218,12 +3218,18 @@ __setparam_dl(struct task_struct *p, const struct sched_attr *attr) ...@@ -3218,12 +3218,18 @@ __setparam_dl(struct task_struct *p, const struct sched_attr *attr)
dl_se->dl_yielded = 0; dl_se->dl_yielded = 0;
} }
/*
* sched_setparam() passes in -1 for its policy, to let the functions
* it calls know not to change it.
*/
#define SETPARAM_POLICY -1
static void __setscheduler_params(struct task_struct *p, static void __setscheduler_params(struct task_struct *p,
const struct sched_attr *attr) const struct sched_attr *attr)
{ {
int policy = attr->sched_policy; int policy = attr->sched_policy;
if (policy == -1) /* setparam */ if (policy == SETPARAM_POLICY)
policy = p->policy; policy = p->policy;
p->policy = policy; p->policy = policy;
...@@ -3572,11 +3578,8 @@ static int _sched_setscheduler(struct task_struct *p, int policy, ...@@ -3572,11 +3578,8 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
.sched_nice = PRIO_TO_NICE(p->static_prio), .sched_nice = PRIO_TO_NICE(p->static_prio),
}; };
/* /* Fixup the legacy SCHED_RESET_ON_FORK hack. */
* Fixup the legacy SCHED_RESET_ON_FORK hack, except if if ((policy != SETPARAM_POLICY) && (policy & SCHED_RESET_ON_FORK)) {
* the policy=-1 was passed by sched_setparam().
*/
if ((policy != -1) && (policy & SCHED_RESET_ON_FORK)) {
attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK; attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
policy &= ~SCHED_RESET_ON_FORK; policy &= ~SCHED_RESET_ON_FORK;
attr.sched_policy = policy; attr.sched_policy = policy;
...@@ -3746,7 +3749,7 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy, ...@@ -3746,7 +3749,7 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
*/ */
SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param) SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
{ {
return do_sched_setscheduler(pid, -1, param); return do_sched_setscheduler(pid, SETPARAM_POLICY, param);
} }
/** /**
......
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