add sched_reset_on_fork patch. more bfs 330 -> 250 work
authorCorey O'Connor <coreyoconnor@gmail.com>
Thu, 30 Sep 2010 19:47:30 +0000 (12:47 -0700)
committerCorey O'Connor <coreyoconnor@gmail.com>
Thu, 30 Sep 2010 19:47:30 +0000 (12:47 -0700)
kernel-power-2.6.28/debian/patches/bfs-330-to-350.patch
kernel-power-2.6.28/debian/patches/sched_reset_on_fork.diff [new file with mode: 0644]
kernel-power-2.6.28/debian/patches/series

index 46af1f9..8d176ff 100644 (file)
@@ -64,44 +64,31 @@ nanosecond deadline resolution means this will never happen.
 -ck
 ---
 
- Documentation/scheduler/sched-BFS.txt |    2 
  include/linux/sched.h                 |    4 
  kernel/sched_bfs.c                    |  466 +++++++++++++++++++++-------------
  kernel/sysctl.c                       |    4 
  4 files changed, 293 insertions(+), 183 deletions(-)
 
-Index: linux-2.6.35-bfs/Documentation/scheduler/sched-BFS.txt
-===================================================================
---- linux-2.6.35-bfs.orig/Documentation/scheduler/sched-BFS.txt        2010-09-25 08:18:30.134360792 +1000
-+++ linux-2.6.35-bfs/Documentation/scheduler/sched-BFS.txt     2010-09-25 08:20:25.830887001 +1000
-@@ -257,7 +257,7 @@ uniprocessor machine, and automatically
- multiprocessor machines. The reasoning behind increasing the value on more CPUs
- is that the effective latency is decreased by virtue of there being more CPUs on
- BFS (for reasons explained above), and increasing the value allows for less
--cache contention and more throughput. Valid values are from 1 to 5000
-+cache contention and more throughput. Valid values are from 1 to 1000
- Decreasing the value will decrease latencies at the cost of decreasing
- throughput, while increasing it will improve throughput, but at the cost of
- worsening latencies. The accuracy of the rr interval is limited by HZ resolution
 Index: linux-2.6.35-bfs/include/linux/sched.h
 ===================================================================
 --- linux-2.6.35-bfs.orig/include/linux/sched.h        2010-09-25 08:18:08.792894602 +1000
 +++ linux-2.6.35-bfs/include/linux/sched.h     2010-09-25 08:20:25.822886826 +1000
-@@ -1197,7 +1197,7 @@ struct task_struct {
+@@ -1118,7 +1118,7 @@ struct task_struct {
        int prio, static_prio, normal_prio;
        unsigned int rt_priority;
  #ifdef CONFIG_SCHED_BFS
 -      int time_slice, first_time_slice;
+-      unsigned long deadline;
 +      int time_slice;
-       u64 deadline;
++      u64 deadline;
        struct list_head run_list;
        u64 last_ran;
 @@ -1547,7 +1547,7 @@ static inline void tsk_cpus_current(stru
  
  static inline void print_scheduler_version(void)
  {
--      printk(KERN_INFO"BFS CPU scheduler v0.330 by Con Kolivas.\n");
-+      printk(KERN_INFO"BFS CPU scheduler v0.350 by Con Kolivas.\n");
+-      printk(KERN_INFO"BFS CPU scheduler v0.330 by Con Kolivas ported by ToAsTcfh.\n");
++      printk(KERN_INFO"BFS CPU scheduler v0.350 by Con Kolivas ported by ToAsTcfh.\n");
  }
  
  static inline int iso_task(struct task_struct *p)
@@ -191,7 +178,7 @@ Index: linux-2.6.35-bfs/kernel/sched_bfs.c
  #ifdef CONFIG_SCHEDSTATS
  
        /* latency stats */
-@@ -286,15 +298,6 @@ struct root_domain {
+@@ -290,12 +290,4 @@ struct root_domain {
  static struct root_domain def_root_domain;
  #endif
  
@@ -203,10 +190,7 @@ Index: linux-2.6.35-bfs/kernel/sched_bfs.c
 -      return 0;
 -#endif
 -}
--
- #define rcu_dereference_check_sched_domain(p) \
-       rcu_dereference_check((p), \
-                             rcu_read_lock_sched_held() || \
+
 @@ -310,17 +313,65 @@ static inline int cpu_of(struct rq *rq)
  #define for_each_domain(cpu, __sd) \
        for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); __sd; __sd = __sd->parent)
@@ -283,7 +267,7 @@ Index: linux-2.6.35-bfs/kernel/sched_bfs.c
 + * when we're not updating niffies.
 + * Looking up task_rq must be done under grq.lock to be safe.
   */
--inline void update_rq_clock(struct rq *rq)
+-static inline void update_rq_clock(struct rq *rq)
 +static inline void update_rq_clock(struct rq *rq)
  {
 -      if (!rq->skip_clock_update)
diff --git a/kernel-power-2.6.28/debian/patches/sched_reset_on_fork.diff b/kernel-power-2.6.28/debian/patches/sched_reset_on_fork.diff
new file mode 100644 (file)
index 0000000..22deac4
--- /dev/null
@@ -0,0 +1,106 @@
+Index: kernel-2.6.28/include/linux/sched.h
+===================================================================
+--- kernel-2.6.28.orig/include/linux/sched.h
++++ kernel-2.6.28/include/linux/sched.h
+@@ -45,6 +45,9 @@
+ #define SCHED_RANGE(policy)   ((policy) <= SCHED_MAX)
+ #endif
++/* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
++#define SCHED_RESET_ON_FORK     0x40000000
++
+ #ifdef __KERNEL__
+ struct sched_param {
+@@ -1174,6 +1177,10 @@ struct task_struct {
+       /* ??? */
+       unsigned int personality;
+       unsigned did_exec:1;
++
++      /* Revert to default priority/policy when forking */
++      unsigned sched_reset_on_fork:1;
++
+       pid_t pid;
+       pid_t tgid;
+Index: kernel-2.6.28/kernel/sched_bfs.c
+===================================================================
+--- kernel-2.6.28.orig/kernel/sched_bfs.c
++++ kernel-2.6.28/kernel/sched_bfs.c
+@@ -1356,6 +1356,27 @@ void sched_fork(struct task_struct *p, i
+       p->sched_time = p->stime_pc = p->utime_pc = 0;
+       /*
++       * Revert to default priority/policy on fork if requested.
++       */
++      if (unlikely(p->sched_reset_on_fork)) {
++              if (p->policy == SCHED_FIFO || p->policy == SCHED_RR) {
++                      p->policy = SCHED_NORMAL;
++                      p->normal_prio = normal_prio(p);
++              }
++
++              if (PRIO_TO_NICE(p->static_prio) < 0) {
++                      p->static_prio = NICE_TO_PRIO(0);
++                      p->normal_prio = p->static_prio;
++              }
++
++              /*
++               * We don't need the reset flag anymore after the fork. It has
++               * fulfilled its duty:
++               */
++              p->sched_reset_on_fork = 0;
++      }
++
++      /*
+        * Make sure we do not leak PI boosting priority to the child:
+        */
+       p->prio = current->normal_prio;
+@@ -3121,6 +3142,7 @@ static int __sched_setscheduler(struct t
+       struct sched_param zero_param = { .sched_priority = 0 };
+       int queued, retval, oldpolicy = -1;
+       unsigned long flags, rlim_rtprio = 0;
++      int reset_on_fork;
+       struct rq *rq;
+       /* may grab non-irq protected spin_locks */
+@@ -3145,10 +3167,17 @@ static int __sched_setscheduler(struct t
+       }
+ recheck:
+       /* double check policy once rq lock held */
+-      if (policy < 0)
++      if (policy < 0) {
++              reset_on_fork = p->sched_reset_on_fork;
+               policy = oldpolicy = p->policy;
+-      else if (!SCHED_RANGE(policy))
+-              return -EINVAL;
++      } else {
++              reset_on_fork = !!(policy & SCHED_RESET_ON_FORK);
++              policy &= ~SCHED_RESET_ON_FORK;
++
++              if (!SCHED_RANGE(policy))
++                      return -EINVAL;
++      }
++
+       /*
+        * Valid priorities for SCHED_FIFO and SCHED_RR are
+        * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL and
+@@ -3211,6 +3240,10 @@ recheck:
+               if ((current->euid != p->euid) &&
+                   (current->euid != p->uid))
+                       return -EPERM;
++
++              /* Normal users shall not reset the sched_reset_on_fork flag */
++              if (p->sched_reset_on_fork && !reset_on_fork)
++                      return -EPERM;
+       }
+       retval = security_task_setscheduler(p, policy, param);
+@@ -3234,6 +3267,8 @@ recheck:
+               goto recheck;
+       }
+       update_rq_clock(rq);
++      p->sched_reset_on_fork = reset_on_fork;
++
+       queued = task_queued(p);
+       if (queued)
+               dequeue_task(p);
index 07fe2e7..2a5c020 100644 (file)
@@ -33,6 +33,7 @@ overclock.diff
 bfs.patch
 bfs-316-to-318.patch
 bfs-318-to-330.patch
+sched_reset_on_fork.diff
 bfs-330-to-350.patch
 voltage_scaling_1.diff
 voltage_scaling_0.diff