From: Raistlin <raistlin@linux.it>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
michael trimarchi <michael@evidence.eu.com>,
Fabio Checconi <fabio@gandalf.sssup.it>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Dhaval Giani <dhaval.giani@gmail.com>,
Johan Eker <johan.eker@ericsson.com>,
"p.faure" <p.faure@akatech.ch>,
Chris Friesen <cfriesen@nortel.com>,
Steven Rostedt <rostedt@goodmis.org>,
Henrik Austad <henrik@austad.us>,
Frederic Weisbecker <fweisbec@gmail.com>,
Darren Hart <darren@dvhart.com>,
Sven-Thorsten Dietrich <sven@thebigcorporation.com>,
Bjoern Brandenburg <bbb@cs.unc.edu>,
Tommaso Cucinotta <tommaso.cucinotta@sssup.it>,
"giuseppe.lipari" <giuseppe.lipari@sssup.it>,
Juri Lelli <juri.lelli@gmail.com>
Subject: [RFC 12/12][PATCH] SCHED_DEADLINE: modified sched_*_ex API
Date: Fri, 16 Oct 2009 17:48:06 +0200 [thread overview]
Message-ID: <1255708086.6228.469.camel@Palantir> (raw)
In-Reply-To: <1255707324.6228.448.camel@Palantir>
[-- Attachment #1: Type: text/plain, Size: 5359 bytes --]
This commit amends the new API introduced to deal with the new sched_param_ex
scheduling parameter data structure.
What we add is one more parameter to all the functions, containing the size of
sched_param_ex. It might turn out useful in possible future extensions of
sched_param_ex itself, to avoid issue with ABI of legacy applications.
Signed-off-by: Raistlin <raistlin@linux.it>
---
include/linux/syscalls.h | 6 +++---
kernel/sched.c | 25 ++++++++++++++++---------
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e01f59c..60a99a7 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -391,16 +391,16 @@ asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
asmlinkage long sys_nice(int increment);
asmlinkage long sys_sched_setscheduler(pid_t pid, int policy,
struct sched_param __user *param);
-asmlinkage long sys_sched_setscheduler_ex(pid_t pid, int policy,
+asmlinkage long sys_sched_setscheduler_ex(pid_t pid, int policy, unsigned len,
struct sched_param_ex __user *param);
asmlinkage long sys_sched_setparam(pid_t pid,
struct sched_param __user *param);
-asmlinkage long sys_sched_setparam_ex(pid_t pid,
+asmlinkage long sys_sched_setparam_ex(pid_t pid, unsigned len,
struct sched_param_ex __user *param);
asmlinkage long sys_sched_getscheduler(pid_t pid);
asmlinkage long sys_sched_getparam(pid_t pid,
struct sched_param __user *param);
-asmlinkage long sys_sched_getparam_ex(pid_t pid,
+asmlinkage long sys_sched_getparam_ex(pid_t pid, unsigned len,
struct sched_param_ex __user *param);
asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len,
unsigned long __user *user_mask_ptr);
diff --git a/kernel/sched.c b/kernel/sched.c
index a8ebfa2..d3a61f5 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6662,7 +6662,7 @@ do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
}
static int
-do_sched_setscheduler_ex(pid_t pid, int policy,
+do_sched_setscheduler_ex(pid_t pid, int policy, unsigned int len,
struct sched_param_ex __user *param_ex)
{
struct sched_param lparam;
@@ -6672,8 +6672,9 @@ do_sched_setscheduler_ex(pid_t pid, int policy,
if (!param_ex || pid < 0)
return -EINVAL;
- if (copy_from_user(&lparam_ex, param_ex,
- sizeof(struct sched_param_ex)))
+ if (len > sizeof(struct sched_param_ex))
+ return -EINVAL;
+ if (copy_from_user(&lparam_ex, param_ex,len))
return -EFAULT;
rcu_read_lock();
@@ -6708,15 +6709,17 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
* sys_sched_setscheduler_ex - set/change the scheduler policy to SCHED_DEADLINE
* @pid: the pid in question.
* @policy: new policy (should be SCHED_DEADLINE).
+ * @len: size of data pointed by param_ex.
* @param: structure containg the extended deadline parameters.
*/
-SYSCALL_DEFINE3(sched_setscheduler_ex, pid_t, pid, int, policy,
+SYSCALL_DEFINE4(sched_setscheduler_ex, pid_t, pid,
+ int, policy, unsigned, len,
struct sched_param_ex __user *, param_ex)
{
if (policy < 0)
return -EINVAL;
- return do_sched_setscheduler_ex(pid, policy, param_ex);
+ return do_sched_setscheduler_ex(pid, policy, len, param_ex);
}
/**
@@ -6732,12 +6735,13 @@ SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
/**
* sys_sched_setparam - set/change the DEADLINE parameters of a thread
* @pid: the pid in question.
+ * @len: size of data pointed by param_ex.
* @param_ex: structure containing the new parameters (deadline, runtime, etc.).
*/
-SYSCALL_DEFINE2(sched_setparam_ex, pid_t, pid,
+SYSCALL_DEFINE3(sched_setparam_ex, pid_t, pid, unsigned, len,
struct sched_param_ex __user *, param_ex)
{
- return do_sched_setscheduler_ex(pid, -1, param_ex);
+ return do_sched_setscheduler_ex(pid, -1, len, param_ex);
}
/**
@@ -6807,9 +6811,10 @@ out_unlock:
/**
* sys_sched_getparam - get the DEADLINE task parameters of a thread
* @pid: the pid in question.
+ * @len: size of data pointed by param_ex.
* @param_ex: structure containing the new parameters (deadline, runtime, etc.).
*/
-SYSCALL_DEFINE2(sched_getparam_ex, pid_t, pid,
+SYSCALL_DEFINE3(sched_getparam_ex, pid_t, pid, unsigned, len,
struct sched_param_ex __user *, param_ex)
{
struct sched_param_ex lp;
@@ -6818,6 +6823,8 @@ SYSCALL_DEFINE2(sched_getparam_ex, pid_t, pid,
if (!param_ex || pid < 0)
return -EINVAL;
+ if (len < sizeof(struct sched_param_ex))
+ return -EINVAL;
read_lock(&tasklist_lock);
p = find_process_by_pid(pid);
@@ -6837,7 +6844,7 @@ SYSCALL_DEFINE2(sched_getparam_ex, pid_t, pid,
/*
* This one might sleep, we cannot do it with a spinlock held ...
*/
- retval = copy_to_user(param_ex, &lp, sizeof(*param_ex)) ? -EFAULT : 0;
+ retval = copy_to_user(param_ex, &lp, len) ? -EFAULT : 0;
return retval;
--
1.6.0.4
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
----------------------------------------------------------------------
Dario Faggioli, ReTiS Lab, Scuola Superiore Sant'Anna, Pisa (Italy)
http://blog.linux.it/raistlin / raistlin@ekiga.net /
dario.faggioli@jabber.org
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-10-16 15:48 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-16 15:35 [RFC 0/12][PATCH] SCHED_DEADLINE (new version of SCHED_EDF) Raistlin
2009-10-16 15:38 ` [RFC 1/12][PATCH] Extended scheduling parameters structure added Raistlin
2009-12-29 12:15 ` Peter Zijlstra
2010-01-13 10:36 ` Raistlin
2009-10-16 15:40 ` [RFC 0/12][PATCH] SCHED_DEADLINE: core of the scheduling class Raistlin
2009-12-29 12:25 ` Peter Zijlstra
2010-01-13 10:40 ` Dario Faggioli
2009-12-29 12:27 ` Peter Zijlstra
2010-01-13 10:42 ` Raistlin
2009-12-29 14:30 ` Peter Zijlstra
2009-12-29 14:37 ` Peter Zijlstra
2009-12-29 14:40 ` Peter Zijlstra
2010-01-13 16:32 ` Dario Faggioli
2010-01-13 16:47 ` Peter Zijlstra
2009-12-29 14:41 ` Peter Zijlstra
2010-01-13 10:46 ` Raistlin
2009-10-16 15:41 ` [RFC 0/12][PATCH] SCHED_DEADLINE: fork and terminate task logic Raistlin
2009-12-29 15:20 ` Peter Zijlstra
2010-01-13 11:11 ` Raistlin
2010-01-13 16:15 ` Peter Zijlstra
2010-01-13 16:28 ` Dario Faggioli
2010-01-13 21:30 ` Fabio Checconi
2009-10-16 15:41 ` [RFC 0/12][PATCH] SCHED_DEADLINE: added sched_*_ex syscalls Raistlin
2009-10-16 15:42 ` [RFC 0/12][PATCH] SCHED_DEADLINE: added sched-debug support Raistlin
2009-10-16 15:43 ` [RFC 6/12][PATCH] SCHED_DEADLINE: added scheduling latency tracer Raistlin
2009-10-16 15:44 ` [RFC 7/12][PATCH] SCHED_DEADLINE: signal delivery when overrunning Raistlin
2009-12-28 14:19 ` Peter Zijlstra
2010-01-13 9:30 ` Raistlin
2009-10-16 15:44 ` [RFC 8/12][PATCH] SCHED_DEADLINE: wait next instance syscall added Raistlin
2009-12-28 14:30 ` Peter Zijlstra
2010-01-13 9:33 ` Raistlin
2009-10-16 15:45 ` [RFC 9/12][PATCH] SCHED_DEADLINE: system wide bandwidth management Raistlin
2009-11-06 11:34 ` Dhaval Giani
2009-12-28 14:44 ` Peter Zijlstra
2010-01-13 9:41 ` Raistlin
2009-10-16 15:46 ` [RFC 10/12][PATCH] SCHED_DEADLINE: group bandwidth management code Raistlin
2009-12-28 14:51 ` Peter Zijlstra
2010-01-13 9:46 ` Raistlin
2009-10-16 15:47 ` [RFC 11/12][PATCH] SCHED_DEADLINE: documentation Raistlin
2009-10-16 15:48 ` Raistlin [this message]
2009-12-28 15:09 ` [RFC 12/12][PATCH] SCHED_DEADLINE: modified sched_*_ex API Peter Zijlstra
2010-01-13 10:27 ` Raistlin
2010-01-13 16:23 ` Peter Zijlstra
2009-12-29 12:15 ` Peter Zijlstra
2010-01-13 10:33 ` Raistlin
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=1255708086.6228.469.camel@Palantir \
--to=raistlin@linux.it \
--cc=bbb@cs.unc.edu \
--cc=cfriesen@nortel.com \
--cc=darren@dvhart.com \
--cc=dhaval.giani@gmail.com \
--cc=fabio@gandalf.sssup.it \
--cc=fweisbec@gmail.com \
--cc=giuseppe.lipari@sssup.it \
--cc=henrik@austad.us \
--cc=johan.eker@ericsson.com \
--cc=juri.lelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@evidence.eu.com \
--cc=mingo@elte.hu \
--cc=p.faure@akatech.ch \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sven@thebigcorporation.com \
--cc=tglx@linutronix.de \
--cc=tommaso.cucinotta@sssup.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.