From: Peter Zijlstra <peterz@infradead.org>
To: Fengguang Wu <fengguang.wu@intel.com>
Cc: Dario Faggioli <raistlin@linux.it>,
Juri Lelli <juri.lelli@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
lkp@linux.intel.com
Subject: [PATCH] sched: Fixup scheduler syscall LTP fails
Date: Wed, 15 Jan 2014 16:33:20 +0100 [thread overview]
Message-ID: <20140115153320.GH31570@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140115124739.GB19419@localhost>
Subject: sched: Fixup scheduler syscall LTP fails
Wu reported:
> ltp.sched_setparam02.1.TFAIL
> ltp.sched_setparam02.2.TFAIL
> ltp.sched_setparam02.3.TFAIL
> ltp.sched_setparam03.1.TFAIL
There were 2 things wrong; firstly __setscheduler() failed on
sched_setparam()'s policy = -1, fix that by reading from p->policy in
that case.
Secondly, getparam() (and getattr()) would still report !0
sched_priority for !FIFO/RR tasks after having been such. So
unconditionally set p->rt_priority.
Fixes: d50dde5a10f3 ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI")
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
kernel/sched/core.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0326c06953eb..50e99f2cf98b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3183,15 +3183,23 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
{
int policy = attr->sched_policy;
+ if (policy == -1) /* setparam */
+ policy = p->policy;
+
p->policy = policy;
if (dl_policy(policy))
__setparam_dl(p, attr);
- else if (rt_policy(policy))
- p->rt_priority = attr->sched_priority;
- else
+ else if (fair_policy(policy))
p->static_prio = NICE_TO_PRIO(attr->sched_nice);
+ /*
+ * __sched_setscheduler() ensures attr->sched_priority == 0 when
+ * !rt_policy. Always setting this ensures that things like
+ * getparam()/getattr() don't report silly values for !rt tasks.
+ */
+ p->rt_priority = attr->sched_priority;
+
p->normal_prio = normal_prio(p);
p->prio = rt_mutex_getprio(p);
next prev parent reply other threads:[~2014-01-15 15:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-15 12:47 [sched] d50dde5a1: LTP sched_setparam* TFAILs Fengguang Wu
2014-01-15 12:49 ` Peter Zijlstra
2014-01-15 13:09 ` Peter Zijlstra
2014-01-15 13:26 ` Fengguang Wu
2014-01-15 13:32 ` Peter Zijlstra
2014-01-15 15:33 ` Peter Zijlstra [this message]
2014-01-16 13:40 ` [tip:sched/core] sched: Fix up scheduler syscall LTP fails tip-bot for Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140115153320.GH31570@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=fengguang.wu@intel.com \
--cc=juri.lelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@linux.intel.com \
--cc=raistlin@linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox