diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2014-07-23 11:28:26 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-07-28 04:04:14 -0400 |
commit | c13db6b131a4388edca9867a1457b988b83902f8 (patch) | |
tree | 8cff077493d86c6213dc952358122ccc52fda606 /kernel/sched/core.c | |
parent | 6ae72dff37596f736b795426306404f0793e4b1b (diff) |
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: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter 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.home
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r-- | kernel/sched/core.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2a36a74c16ae..2676866b4394 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -3218,12 +3218,18 @@ __setparam_dl(struct task_struct *p, const struct sched_attr *attr) | |||
3218 | dl_se->dl_yielded = 0; | 3218 | dl_se->dl_yielded = 0; |
3219 | } | 3219 | } |
3220 | 3220 | ||
3221 | /* | ||
3222 | * sched_setparam() passes in -1 for its policy, to let the functions | ||
3223 | * it calls know not to change it. | ||
3224 | */ | ||
3225 | #define SETPARAM_POLICY -1 | ||
3226 | |||
3221 | static void __setscheduler_params(struct task_struct *p, | 3227 | static void __setscheduler_params(struct task_struct *p, |
3222 | const struct sched_attr *attr) | 3228 | const struct sched_attr *attr) |
3223 | { | 3229 | { |
3224 | int policy = attr->sched_policy; | 3230 | int policy = attr->sched_policy; |
3225 | 3231 | ||
3226 | if (policy == -1) /* setparam */ | 3232 | if (policy == SETPARAM_POLICY) |
3227 | policy = p->policy; | 3233 | policy = p->policy; |
3228 | 3234 | ||
3229 | p->policy = policy; | 3235 | p->policy = policy; |
@@ -3572,11 +3578,8 @@ static int _sched_setscheduler(struct task_struct *p, int policy, | |||
3572 | .sched_nice = PRIO_TO_NICE(p->static_prio), | 3578 | .sched_nice = PRIO_TO_NICE(p->static_prio), |
3573 | }; | 3579 | }; |
3574 | 3580 | ||
3575 | /* | 3581 | /* Fixup the legacy SCHED_RESET_ON_FORK hack. */ |
3576 | * Fixup the legacy SCHED_RESET_ON_FORK hack, except if | 3582 | if ((policy != SETPARAM_POLICY) && (policy & SCHED_RESET_ON_FORK)) { |
3577 | * the policy=-1 was passed by sched_setparam(). | ||
3578 | */ | ||
3579 | if ((policy != -1) && (policy & SCHED_RESET_ON_FORK)) { | ||
3580 | attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK; | 3583 | attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK; |
3581 | policy &= ~SCHED_RESET_ON_FORK; | 3584 | policy &= ~SCHED_RESET_ON_FORK; |
3582 | attr.sched_policy = policy; | 3585 | attr.sched_policy = policy; |
@@ -3746,7 +3749,7 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy, | |||
3746 | */ | 3749 | */ |
3747 | SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param) | 3750 | SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param) |
3748 | { | 3751 | { |
3749 | return do_sched_setscheduler(pid, -1, param); | 3752 | return do_sched_setscheduler(pid, SETPARAM_POLICY, param); |
3750 | } | 3753 | } |
3751 | 3754 | ||
3752 | /** | 3755 | /** |