rpms/kernel/devel kernel.spec, 1.1584, 1.1585 sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch, 1.1, 1.2
Kyle McMartin
kyle at fedoraproject.org
Mon Jun 22 16:15:43 UTC 2009
Author: kyle
Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv24479
Modified Files:
kernel.spec
sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch
Log Message:
* Mon Jun 22 2009 Kyle McMartin <kyle at redhat.com>
- sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch: pull in
two fixes from Mike Galbraith from tip.git
Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.1584
retrieving revision 1.1585
diff -u -p -r1.1584 -r1.1585
--- kernel.spec 22 Jun 2009 03:30:42 -0000 1.1584
+++ kernel.spec 22 Jun 2009 16:15:12 -0000 1.1585
@@ -1826,6 +1826,10 @@ fi
# and build.
%changelog
+* Mon Jun 22 2009 Kyle McMartin <kyle at redhat.com>
+- sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch: pull in
+ two fixes from Mike Galbraith from tip.git
+
* Sun Jun 21 2009 Dave Jones <davej at redhat.com> 2.6.31-0.21.rc0.git18
- Add patch to possibly fix the pktlen problem on via-velocity.
sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch:
Index: sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch 20 Jun 2009 19:36:14 -0000 1.1
+++ sched-introduce-SCHED_RESET_ON_FORK-scheduling-policy-flag.patch 22 Jun 2009 16:15:12 -0000 1.2
@@ -1,56 +1,5 @@
-From: Lennart Poettering <lennart at poettering.net>
-Date: Mon, 15 Jun 2009 15:17:47 +0000 (+0200)
-Subject: sched: Introduce SCHED_RESET_ON_FORK scheduling policy flag
-X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fx86%2Flinux-2.6-tip.git;a=commitdiff_plain;h=ca94c442535a44d508c99a77e54f21a59f4fc462
-
-sched: Introduce SCHED_RESET_ON_FORK scheduling policy flag
-
-This patch introduces a new flag SCHED_RESET_ON_FORK which can be passed
-to the kernel via sched_setscheduler(), ORed in the policy parameter. If
-set this will make sure that when the process forks a) the scheduling
-priority is reset to DEFAULT_PRIO if it was higher and b) the scheduling
-policy is reset to SCHED_NORMAL if it was either SCHED_FIFO or SCHED_RR.
-
-Why have this?
-
-Currently, if a process is real-time scheduled this will 'leak' to all
-its child processes. For security reasons it is often (always?) a good
-idea to make sure that if a process acquires RT scheduling this is
-confined to this process and only this process. More specifically this
-makes the per-process resource limit RLIMIT_RTTIME useful for security
-purposes, because it makes it impossible to use a fork bomb to
-circumvent the per-process RLIMIT_RTTIME accounting.
-
-This feature is also useful for tools like 'renice' which can then
-change the nice level of a process without having this spill to all its
-child processes.
-
-Why expose this via sched_setscheduler() and not other syscalls such as
-prctl() or sched_setparam()?
-
-prctl() does not take a pid parameter. Due to that it would be
-impossible to modify this flag for other processes than the current one.
-
-The struct passed to sched_setparam() can unfortunately not be extended
-without breaking compatibility, since sched_setparam() lacks a size
-parameter.
-
-How to use this from userspace? In your RT program simply replace this:
-
- sched_setscheduler(pid, SCHED_FIFO, ¶m);
-
-by this:
-
- sched_setscheduler(pid, SCHED_FIFO|SCHED_RESET_ON_FORK, ¶m);
-
-Signed-off-by: Lennart Poettering <lennart at poettering.net>
-Acked-by: Peter Zijlstra <a.p.zijlstra at chello.nl>
-LKML-Reference: <20090615152714.GA29092 at tango.0pointer.de>
-Signed-off-by: Ingo Molnar <mingo at elte.hu>
----
-
diff --git a/include/linux/sched.h b/include/linux/sched.h
-index 4896fdf..d4a2c66 100644
+index 4d07542..5ba2c37 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -38,6 +38,8 @@
@@ -62,7 +11,7 @@ index 4896fdf..d4a2c66 100644
#ifdef __KERNEL__
-@@ -1209,6 +1211,10 @@ struct task_struct {
+@@ -1208,6 +1210,10 @@ struct task_struct {
unsigned did_exec:1;
unsigned in_execve:1; /* Tell the LSMs that the process is doing an
* execve */
@@ -74,41 +23,44 @@ index 4896fdf..d4a2c66 100644
pid_t tgid;
diff --git a/kernel/sched.c b/kernel/sched.c
-index 8ec9d13..32e6ede 100644
+index 7c9098d..168b268 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
-@@ -2613,12 +2613,28 @@ void sched_fork(struct task_struct *p, int clone_flags)
+@@ -2614,9 +2614,32 @@ void sched_fork(struct task_struct *p, int clone_flags)
set_task_cpu(p, cpu);
/*
- * Make sure we do not leak PI boosting priority to the child:
-+ * Revert to default priority/policy on fork if requested. Make sure we
-+ * do not leak PI boosting priority to the child.
++ * Make sure we do not leak PI boosting priority to the child.
*/
-- p->prio = current->normal_prio;
-+ if (current->sched_reset_on_fork &&
-+ (p->policy == SCHED_FIFO || p->policy == SCHED_RR))
-+ p->policy = SCHED_NORMAL;
-+
-+ if (current->sched_reset_on_fork &&
-+ (current->normal_prio < DEFAULT_PRIO))
-+ p->prio = DEFAULT_PRIO;
-+ else
-+ p->prio = current->normal_prio;
+ p->prio = current->normal_prio;
+
- if (!rt_prio(p->prio))
- p->sched_class = &fair_sched_class;
-
+ /*
-+ * We don't need the reset flag anymore after the fork. It has
-+ * fulfilled its duty:
++ * Revert to default priority/policy on fork if requested.
+ */
-+ p->sched_reset_on_fork = 0;
++ if (unlikely(p->sched_reset_on_fork)) {
++ if (p->policy == SCHED_FIFO || p->policy == SCHED_RR)
++ p->policy = SCHED_NORMAL;
++
++ if (p->normal_prio < DEFAULT_PRIO)
++ p->prio = DEFAULT_PRIO;
++
++ if (PRIO_TO_NICE(p->static_prio) < 0) {
++ p->static_prio = NICE_TO_PRIO(0);
++ set_load_weight(p);
++ }
++
++ /*
++ * We don't need the reset flag anymore after the fork. It has
++ * fulfilled its duty:
++ */
++ p->sched_reset_on_fork = 0;
++ }
+
- #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
- if (likely(sched_info_on()))
- memset(&p->sched_info, 0, sizeof(p->sched_info));
-@@ -6094,17 +6110,25 @@ static int __sched_setscheduler(struct task_struct *p, int policy,
+ if (!rt_prio(p->prio))
+ p->sched_class = &fair_sched_class;
+
+@@ -6100,17 +6123,25 @@ static int __sched_setscheduler(struct task_struct *p, int policy,
unsigned long flags;
const struct sched_class *prev_class = p->sched_class;
struct rq *rq;
@@ -139,7 +91,7 @@ index 8ec9d13..32e6ede 100644
/*
* Valid priorities for SCHED_FIFO and SCHED_RR are
* 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL,
-@@ -6148,6 +6172,10 @@ recheck:
+@@ -6154,6 +6185,10 @@ recheck:
/* can't change other user's priorities */
if (!check_same_owner(p))
return -EPERM;
@@ -150,7 +102,7 @@ index 8ec9d13..32e6ede 100644
}
if (user) {
-@@ -6191,6 +6219,8 @@ recheck:
+@@ -6197,6 +6232,8 @@ recheck:
if (running)
p->sched_class->put_prev_task(rq, p);
@@ -159,7 +111,7 @@ index 8ec9d13..32e6ede 100644
oldprio = p->prio;
__setscheduler(rq, p, policy, param->sched_priority);
-@@ -6307,14 +6337,15 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
+@@ -6313,14 +6350,15 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
if (p) {
retval = security_task_getscheduler(p);
if (!retval)
More information about the scm-commits
mailing list