[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-1d6362fa0cfc8c7b243fa92924429d826599e691@git.kernel.org>
Date: Tue, 25 Jun 2019 01:32:55 -0700
From: tip-bot for Patrick Bellasi <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: viresh.kumar@...aro.org, balsini@...roid.com, pjt@...gle.com,
tkjos@...gle.com, tj@...nel.org, patrick.bellasi@....com,
rafael.j.wysocki@...el.com, joelaf@...gle.com, mingo@...nel.org,
vincent.guittot@...aro.org, surenb@...gle.com,
dietmar.eggemann@....com, smuckle@...gle.com,
torvalds@...ux-foundation.org, tglx@...utronix.de, hpa@...or.com,
morten.rasmussen@....com, peterz@...radead.org,
linux-kernel@...r.kernel.org, quentin.perret@....com,
juri.lelli@...hat.com
Subject: [tip:sched/core] sched/core: Allow sched_setattr() to use the
current policy
Commit-ID: 1d6362fa0cfc8c7b243fa92924429d826599e691
Gitweb: https://git.kernel.org/tip/1d6362fa0cfc8c7b243fa92924429d826599e691
Author: Patrick Bellasi <patrick.bellasi@....com>
AuthorDate: Fri, 21 Jun 2019 09:42:06 +0100
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Mon, 24 Jun 2019 19:23:46 +0200
sched/core: Allow sched_setattr() to use the current policy
The sched_setattr() syscall mandates that a policy is always specified.
This requires to always know which policy a task will have when
attributes are configured and this makes it impossible to add more
generic task attributes valid across different scheduling policies.
Reading the policy before setting generic tasks attributes is racy since
we cannot be sure it is not changed concurrently.
Introduce the required support to change generic task attributes without
affecting the current task policy. This is done by adding an attribute flag
(SCHED_FLAG_KEEP_POLICY) to enforce the usage of the current policy.
Add support for the SETPARAM_POLICY policy, which is already used by the
sched_setparam() POSIX syscall, to the sched_setattr() non-POSIX
syscall.
Signed-off-by: Patrick Bellasi <patrick.bellasi@....com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Alessio Balsini <balsini@...roid.com>
Cc: Dietmar Eggemann <dietmar.eggemann@....com>
Cc: Joel Fernandes <joelaf@...gle.com>
Cc: Juri Lelli <juri.lelli@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Morten Rasmussen <morten.rasmussen@....com>
Cc: Paul Turner <pjt@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Quentin Perret <quentin.perret@....com>
Cc: Rafael J . Wysocki <rafael.j.wysocki@...el.com>
Cc: Steve Muckle <smuckle@...gle.com>
Cc: Suren Baghdasaryan <surenb@...gle.com>
Cc: Tejun Heo <tj@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Todd Kjos <tkjos@...gle.com>
Cc: Vincent Guittot <vincent.guittot@...aro.org>
Cc: Viresh Kumar <viresh.kumar@...aro.org>
Link: https://lkml.kernel.org/r/20190621084217.8167-6-patrick.bellasi@arm.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
include/uapi/linux/sched.h | 4 +++-
kernel/sched/core.c | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h
index ed4ee170bee2..58b2368d3634 100644
--- a/include/uapi/linux/sched.h
+++ b/include/uapi/linux/sched.h
@@ -51,9 +51,11 @@
#define SCHED_FLAG_RESET_ON_FORK 0x01
#define SCHED_FLAG_RECLAIM 0x02
#define SCHED_FLAG_DL_OVERRUN 0x04
+#define SCHED_FLAG_KEEP_POLICY 0x08
#define SCHED_FLAG_ALL (SCHED_FLAG_RESET_ON_FORK | \
SCHED_FLAG_RECLAIM | \
- SCHED_FLAG_DL_OVERRUN)
+ SCHED_FLAG_DL_OVERRUN | \
+ SCHED_FLAG_KEEP_POLICY)
#endif /* _UAPI_LINUX_SCHED_H */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b74de86b68c7..6d519f3f9789 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4897,6 +4897,8 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
if ((int)attr.sched_policy < 0)
return -EINVAL;
+ if (attr.sched_flags & SCHED_FLAG_KEEP_POLICY)
+ attr.sched_policy = SETPARAM_POLICY;
rcu_read_lock();
retval = -ESRCH;
Powered by blists - more mailing lists