exofs: More sane debug print
[safe/jmp/linux-2.6] / kernel / sched_rt.c
index 3d4020a..5c5fef3 100644 (file)
@@ -615,6 +615,8 @@ static void update_curr_rt(struct rq *rq)
        curr->se.exec_start = rq->clock;
        cpuacct_charge(curr, delta_exec);
 
+       sched_rt_avg_update(rq, delta_exec);
+
        if (!rt_bandwidth_enabled())
                return;
 
@@ -887,8 +889,6 @@ static void enqueue_task_rt(struct rq *rq, struct task_struct *p, int wakeup)
 
        if (!task_current(rq, p) && p->rt.nr_cpus_allowed > 1)
                enqueue_pushable_task(rq, p);
-
-       inc_cpu_load(rq, p->se.load.weight);
 }
 
 static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int sleep)
@@ -899,8 +899,6 @@ static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int sleep)
        dequeue_rt_entity(rt_se);
 
        dequeue_pushable_task(rq, p);
-
-       dec_cpu_load(rq, p->se.load.weight);
 }
 
 /*
@@ -940,10 +938,13 @@ static void yield_task_rt(struct rq *rq)
 #ifdef CONFIG_SMP
 static int find_lowest_rq(struct task_struct *task);
 
-static int select_task_rq_rt(struct task_struct *p, int sync)
+static int select_task_rq_rt(struct task_struct *p, int sd_flag, int flags)
 {
        struct rq *rq = task_rq(p);
 
+       if (sd_flag != SD_BALANCE_WAKE)
+               return smp_processor_id();
+
        /*
         * If the current task is an RT task, then
         * try to see if we can wake this RT task up on another
@@ -1001,7 +1002,7 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p)
 /*
  * Preempt the current task with a newly woken task if needed:
  */
-static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int sync)
+static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flags)
 {
        if (p->prio < rq->curr->prio) {
                resched_task(rq->curr);
@@ -1152,29 +1153,12 @@ static struct task_struct *pick_next_highest_task_rt(struct rq *rq, int cpu)
 
 static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask);
 
-static inline int pick_optimal_cpu(int this_cpu,
-                                  const struct cpumask *mask)
-{
-       int first;
-
-       /* "this_cpu" is cheaper to preempt than a remote processor */
-       if ((this_cpu != -1) && cpumask_test_cpu(this_cpu, mask))
-               return this_cpu;
-
-       first = cpumask_first(mask);
-       if (first < nr_cpu_ids)
-               return first;
-
-       return -1;
-}
-
 static int find_lowest_rq(struct task_struct *task)
 {
        struct sched_domain *sd;
        struct cpumask *lowest_mask = __get_cpu_var(local_cpu_mask);
        int this_cpu = smp_processor_id();
        int cpu      = task_cpu(task);
-       cpumask_var_t domain_mask;
 
        if (task->rt.nr_cpus_allowed == 1)
                return -1; /* No other targets possible */
@@ -1197,28 +1181,26 @@ static int find_lowest_rq(struct task_struct *task)
         * Otherwise, we consult the sched_domains span maps to figure
         * out which cpu is logically closest to our hot cache data.
         */
-       if (this_cpu == cpu)
-               this_cpu = -1; /* Skip this_cpu opt if the same */
+       if (!cpumask_test_cpu(this_cpu, lowest_mask))
+               this_cpu = -1; /* Skip this_cpu opt if not among lowest */
 
-       if (alloc_cpumask_var(&domain_mask, GFP_ATOMIC)) {
-               for_each_domain(cpu, sd) {
-                       if (sd->flags & SD_WAKE_AFFINE) {
-                               int best_cpu;
+       for_each_domain(cpu, sd) {
+               if (sd->flags & SD_WAKE_AFFINE) {
+                       int best_cpu;
 
-                               cpumask_and(domain_mask,
-                                           sched_domain_span(sd),
-                                           lowest_mask);
-
-                               best_cpu = pick_optimal_cpu(this_cpu,
-                                                           domain_mask);
-
-                               if (best_cpu != -1) {
-                                       free_cpumask_var(domain_mask);
-                                       return best_cpu;
-                               }
-                       }
+                       /*
+                        * "this_cpu" is cheaper to preempt than a
+                        * remote processor.
+                        */
+                       if (this_cpu != -1 &&
+                           cpumask_test_cpu(this_cpu, sched_domain_span(sd)))
+                               return this_cpu;
+
+                       best_cpu = cpumask_first_and(lowest_mask,
+                                                    sched_domain_span(sd));
+                       if (best_cpu < nr_cpu_ids)
+                               return best_cpu;
                }
-               free_cpumask_var(domain_mask);
        }
 
        /*
@@ -1226,7 +1208,13 @@ static int find_lowest_rq(struct task_struct *task)
         * just give the caller *something* to work with from the compatible
         * locations.
         */
-       return pick_optimal_cpu(this_cpu, lowest_mask);
+       if (this_cpu != -1)
+               return this_cpu;
+
+       cpu = cpumask_any(lowest_mask);
+       if (cpu < nr_cpu_ids)
+               return cpu;
+       return -1;
 }
 
 /* Will lock the rq it finds */
@@ -1733,6 +1721,17 @@ static void set_curr_task_rt(struct rq *rq)
        dequeue_pushable_task(rq, p);
 }
 
+unsigned int get_rr_interval_rt(struct task_struct *task)
+{
+       /*
+        * Time slice is 0 for SCHED_FIFO tasks
+        */
+       if (task->policy == SCHED_RR)
+               return DEF_TIMESLICE;
+       else
+               return 0;
+}
+
 static const struct sched_class rt_sched_class = {
        .next                   = &fair_sched_class,
        .enqueue_task           = enqueue_task_rt,
@@ -1761,6 +1760,8 @@ static const struct sched_class rt_sched_class = {
        .set_curr_task          = set_curr_task_rt,
        .task_tick              = task_tick_rt,
 
+       .get_rr_interval        = get_rr_interval_rt,
+
        .prio_changed           = prio_changed_rt,
        .switched_to            = switched_to_rt,
 };