Re: [PATCH v3 10/17] Remove some CFS specific code from the wakeup path of RT tasks

2007-11-17 Thread Steven Rostedt

On Sat, 17 Nov 2007, Gregory Haskins wrote:

> >>> On Sat, Nov 17, 2007 at  1:21 AM, in message
> <[EMAIL PROTECTED]>, Steven Rostedt <[EMAIL PROTECTED]>
> wrote:
>
> > +*/
> > +   if (idle_cpu(cpu) || cpu_rq(cpu)->nr_running > 1)
> > +   return cpu;
> > +
> > +   for_each_domain(cpu, sd) {
> > +   if (sd->flags & SD_WAKE_IDLE) {
> > +   cpus_and(tmp, sd->span, p->cpus_allowed);
> > +   for_each_cpu_mask(i, tmp) {
> > +   if (idle_cpu(i))
> > +   return i;
> 
> 
>
> Looks like some stuff that was added in 24 was inadvertently lost in the move 
> when you merged the patches up from 23.1-rt11.  The attached patch is updated 
> to move the new logic as well.
>

Doh!  Good catch. Will rework on Monday.

-- Steve

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 10/17] Remove some CFS specific code from the wakeup path of RT tasks

2007-11-17 Thread Gregory Haskins
>>> On Sat, Nov 17, 2007 at  1:21 AM, in message
<[EMAIL PROTECTED]>, Steven Rostedt <[EMAIL PROTECTED]>
wrote: 

> -/*
> - * wake_idle() will wake a task on an idle cpu if task->cpu is
> - * not idle and an idle cpu is available.  The span of cpus to
> - * search starts with cpus closest then further out as needed,
> - * so we always favor a closer, idle cpu.
> - *
> - * Returns the CPU we should wake onto.
> - */
> -#if defined(ARCH_HAS_SCHED_WAKE_IDLE)
> -static int wake_idle(int cpu, struct task_struct *p)
> -{
> - cpumask_t tmp;
> - struct sched_domain *sd;
> - int i;
> -
> - /*
> -  * If it is idle, then it is the best cpu to run this task.
> -  *
> -  * This cpu is also the best, if it has more than one task already.
> -  * Siblings must be also busy(in most cases) as they didn't already
> -  * pickup the extra load from this cpu and hence we need not check
> -  * sibling runqueue info. This will avoid the checks and cache miss
> -  * penalities associated with that.
> -  */
> - if (idle_cpu(cpu) || cpu_rq(cpu)->nr_running > 1)
> - return cpu;
> -
> - for_each_domain(cpu, sd) {
> - if (sd->flags & SD_WAKE_IDLE) {
> - cpus_and(tmp, sd->span, p->cpus_allowed);
> - for_each_cpu_mask(i, tmp) {
> - if (idle_cpu(i)) {
> - if (i != task_cpu(p)) {
> - schedstat_inc(p,
> - se.nr_wakeups_idle);

  ^

[...]


> --- linux-compile.git.orig/kernel/sched_fair.c2007-11-16 
> 11:16:38.0 -0500
> +++ linux-compile.git/kernel/sched_fair.c 2007-11-16 22:23:39.0 
> -0500
> @@ -564,6 +564,137 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
>  }
>  
>  /*
> + * wake_idle() will wake a task on an idle cpu if task->cpu is
> + * not idle and an idle cpu is available.  The span of cpus to
> + * search starts with cpus closest then further out as needed,
> + * so we always favor a closer, idle cpu.
> + *
> + * Returns the CPU we should wake onto.
> + */
> +#if defined(ARCH_HAS_SCHED_WAKE_IDLE)
> +static int wake_idle(int cpu, struct task_struct *p)
> +{
> + cpumask_t tmp;
> + struct sched_domain *sd;
> + int i;
> +
> + /*
> +  * If it is idle, then it is the best cpu to run this task.
> +  *
> +  * This cpu is also the best, if it has more than one task already.
> +  * Siblings must be also busy(in most cases) as they didn't already
> +  * pickup the extra load from this cpu and hence we need not check
> +  * sibling runqueue info. This will avoid the checks and cache miss
> +  * penalities associated with that.
> +  */
> + if (idle_cpu(cpu) || cpu_rq(cpu)->nr_running > 1)
> + return cpu;
> +
> + for_each_domain(cpu, sd) {
> + if (sd->flags & SD_WAKE_IDLE) {
> + cpus_and(tmp, sd->span, p->cpus_allowed);
> + for_each_cpu_mask(i, tmp) {
> + if (idle_cpu(i))
> + return i;



Looks like some stuff that was added in 24 was inadvertently lost in the move 
when you merged the patches up from 23.1-rt11.  The attached patch is updated 
to move the new logic as well.

Regards,
-Greg


RT: Remove some CFS specific code from the wakeup path of RT tasks

From: Gregory Haskins <[EMAIL PROTECTED]>

The current wake-up code path tries to determine if it can optimize the
wake-up to "this_cpu" by computing load calculations.  The problem is that
these calculations are only relevant to CFS tasks where load is king.  For RT
tasks, priority is king.  So the load calculation is completely wasted
bandwidth.

Therefore, we create a new sched_class interface to help with
pre-wakeup routing decisions and move the load calculation as a function
of CFS task's class.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 include/linux/sched.h   |1 
 kernel/sched.c  |  167 ---
 kernel/sched_fair.c |  148 ++
 kernel/sched_idletask.c |9 +++
 kernel/sched_rt.c   |   10 +++
 5 files changed, 195 insertions(+), 140 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index e9e74de..253517b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -823,6 +823,7 @@ struct sched_class {
void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
void (*yield_task) (struct rq *rq);
+   int  

Re: [PATCH v3 10/17] Remove some CFS specific code from the wakeup path of RT tasks

2007-11-17 Thread Gregory Haskins
 On Sat, Nov 17, 2007 at  1:21 AM, in message
[EMAIL PROTECTED], Steven Rostedt [EMAIL PROTECTED]
wrote: 

 -/*
 - * wake_idle() will wake a task on an idle cpu if task-cpu is
 - * not idle and an idle cpu is available.  The span of cpus to
 - * search starts with cpus closest then further out as needed,
 - * so we always favor a closer, idle cpu.
 - *
 - * Returns the CPU we should wake onto.
 - */
 -#if defined(ARCH_HAS_SCHED_WAKE_IDLE)
 -static int wake_idle(int cpu, struct task_struct *p)
 -{
 - cpumask_t tmp;
 - struct sched_domain *sd;
 - int i;
 -
 - /*
 -  * If it is idle, then it is the best cpu to run this task.
 -  *
 -  * This cpu is also the best, if it has more than one task already.
 -  * Siblings must be also busy(in most cases) as they didn't already
 -  * pickup the extra load from this cpu and hence we need not check
 -  * sibling runqueue info. This will avoid the checks and cache miss
 -  * penalities associated with that.
 -  */
 - if (idle_cpu(cpu) || cpu_rq(cpu)-nr_running  1)
 - return cpu;
 -
 - for_each_domain(cpu, sd) {
 - if (sd-flags  SD_WAKE_IDLE) {
 - cpus_and(tmp, sd-span, p-cpus_allowed);
 - for_each_cpu_mask(i, tmp) {
 - if (idle_cpu(i)) {
 - if (i != task_cpu(p)) {
 - schedstat_inc(p,
 - se.nr_wakeups_idle);

  ^

[...]


 --- linux-compile.git.orig/kernel/sched_fair.c2007-11-16 
 11:16:38.0 -0500
 +++ linux-compile.git/kernel/sched_fair.c 2007-11-16 22:23:39.0 
 -0500
 @@ -564,6 +564,137 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
  }
  
  /*
 + * wake_idle() will wake a task on an idle cpu if task-cpu is
 + * not idle and an idle cpu is available.  The span of cpus to
 + * search starts with cpus closest then further out as needed,
 + * so we always favor a closer, idle cpu.
 + *
 + * Returns the CPU we should wake onto.
 + */
 +#if defined(ARCH_HAS_SCHED_WAKE_IDLE)
 +static int wake_idle(int cpu, struct task_struct *p)
 +{
 + cpumask_t tmp;
 + struct sched_domain *sd;
 + int i;
 +
 + /*
 +  * If it is idle, then it is the best cpu to run this task.
 +  *
 +  * This cpu is also the best, if it has more than one task already.
 +  * Siblings must be also busy(in most cases) as they didn't already
 +  * pickup the extra load from this cpu and hence we need not check
 +  * sibling runqueue info. This will avoid the checks and cache miss
 +  * penalities associated with that.
 +  */
 + if (idle_cpu(cpu) || cpu_rq(cpu)-nr_running  1)
 + return cpu;
 +
 + for_each_domain(cpu, sd) {
 + if (sd-flags  SD_WAKE_IDLE) {
 + cpus_and(tmp, sd-span, p-cpus_allowed);
 + for_each_cpu_mask(i, tmp) {
 + if (idle_cpu(i))
 + return i;



Looks like some stuff that was added in 24 was inadvertently lost in the move 
when you merged the patches up from 23.1-rt11.  The attached patch is updated 
to move the new logic as well.

Regards,
-Greg


RT: Remove some CFS specific code from the wakeup path of RT tasks

From: Gregory Haskins [EMAIL PROTECTED]

The current wake-up code path tries to determine if it can optimize the
wake-up to this_cpu by computing load calculations.  The problem is that
these calculations are only relevant to CFS tasks where load is king.  For RT
tasks, priority is king.  So the load calculation is completely wasted
bandwidth.

Therefore, we create a new sched_class interface to help with
pre-wakeup routing decisions and move the load calculation as a function
of CFS task's class.

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 include/linux/sched.h   |1 
 kernel/sched.c  |  167 ---
 kernel/sched_fair.c |  148 ++
 kernel/sched_idletask.c |9 +++
 kernel/sched_rt.c   |   10 +++
 5 files changed, 195 insertions(+), 140 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index e9e74de..253517b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -823,6 +823,7 @@ struct sched_class {
void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
void (*yield_task) (struct rq *rq);
+   int  (*select_task_rq)(struct task_struct *p, int sync);
 
void (*check_preempt_curr) (struct rq *rq, struct task_struct 

Re: [PATCH v3 10/17] Remove some CFS specific code from the wakeup path of RT tasks

2007-11-17 Thread Steven Rostedt

On Sat, 17 Nov 2007, Gregory Haskins wrote:

  On Sat, Nov 17, 2007 at  1:21 AM, in message
 [EMAIL PROTECTED], Steven Rostedt [EMAIL PROTECTED]
 wrote:

  +*/
  +   if (idle_cpu(cpu) || cpu_rq(cpu)-nr_running  1)
  +   return cpu;
  +
  +   for_each_domain(cpu, sd) {
  +   if (sd-flags  SD_WAKE_IDLE) {
  +   cpus_and(tmp, sd-span, p-cpus_allowed);
  +   for_each_cpu_mask(i, tmp) {
  +   if (idle_cpu(i))
  +   return i;
 
 

 Looks like some stuff that was added in 24 was inadvertently lost in the move 
 when you merged the patches up from 23.1-rt11.  The attached patch is updated 
 to move the new logic as well.


Doh!  Good catch. Will rework on Monday.

-- Steve

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 10/17] Remove some CFS specific code from the wakeup path of RT tasks

2007-11-16 Thread Steven Rostedt
From: Gregory Haskins <[EMAIL PROTECTED]>

The current wake-up code path tries to determine if it can optimize the
wake-up to "this_cpu" by computing load calculations.  The problem is that
these calculations are only relevant to CFS tasks where load is king.  For RT
tasks, priority is king.  So the load calculation is completely wasted
bandwidth.

Therefore, we create a new sched_class interface to help with
pre-wakeup routing decisions and move the load calculation as a function
of CFS task's class.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
Signed-off-by: Steven Rostedt <[EMAIL PROTECTED]>
---

 include/linux/sched.h   |1 
 kernel/sched.c  |  144 +++-
 kernel/sched_fair.c |  132 
 kernel/sched_idletask.c |9 +++
 kernel/sched_rt.c   |8 ++
 5 files changed, 159 insertions(+), 135 deletions(-)

Index: linux-compile.git/include/linux/sched.h
===
--- linux-compile.git.orig/include/linux/sched.h2007-11-16 
22:12:34.0 -0500
+++ linux-compile.git/include/linux/sched.h 2007-11-16 22:23:39.0 
-0500
@@ -823,6 +823,7 @@ struct sched_class {
void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
void (*yield_task) (struct rq *rq);
+   int  (*select_task_rq)(struct task_struct *p, int sync);
 
void (*check_preempt_curr) (struct rq *rq, struct task_struct *p);
 
Index: linux-compile.git/kernel/sched.c
===
--- linux-compile.git.orig/kernel/sched.c   2007-11-16 22:12:34.0 
-0500
+++ linux-compile.git/kernel/sched.c2007-11-16 22:23:39.0 -0500
@@ -860,6 +860,10 @@ iter_move_one_task(struct rq *this_rq, i
   struct rq_iterator *iterator);
 #endif
 
+static unsigned long source_load(int cpu, int type);
+static unsigned long target_load(int cpu, int type);
+static unsigned long cpu_avg_load_per_task(int cpu);
+
 #include "sched_stats.h"
 #include "sched_idletask.c"
 #include "sched_fair.c"
@@ -1270,7 +1274,7 @@ static unsigned long target_load(int cpu
 /*
  * Return the average load per task on the cpu's run queue
  */
-static inline unsigned long cpu_avg_load_per_task(int cpu)
+static unsigned long cpu_avg_load_per_task(int cpu)
 {
struct rq *rq = cpu_rq(cpu);
unsigned long total = weighted_cpuload(cpu);
@@ -1427,58 +1431,6 @@ static int sched_balance_self(int cpu, i
 
 #endif /* CONFIG_SMP */
 
-/*
- * wake_idle() will wake a task on an idle cpu if task->cpu is
- * not idle and an idle cpu is available.  The span of cpus to
- * search starts with cpus closest then further out as needed,
- * so we always favor a closer, idle cpu.
- *
- * Returns the CPU we should wake onto.
- */
-#if defined(ARCH_HAS_SCHED_WAKE_IDLE)
-static int wake_idle(int cpu, struct task_struct *p)
-{
-   cpumask_t tmp;
-   struct sched_domain *sd;
-   int i;
-
-   /*
-* If it is idle, then it is the best cpu to run this task.
-*
-* This cpu is also the best, if it has more than one task already.
-* Siblings must be also busy(in most cases) as they didn't already
-* pickup the extra load from this cpu and hence we need not check
-* sibling runqueue info. This will avoid the checks and cache miss
-* penalities associated with that.
-*/
-   if (idle_cpu(cpu) || cpu_rq(cpu)->nr_running > 1)
-   return cpu;
-
-   for_each_domain(cpu, sd) {
-   if (sd->flags & SD_WAKE_IDLE) {
-   cpus_and(tmp, sd->span, p->cpus_allowed);
-   for_each_cpu_mask(i, tmp) {
-   if (idle_cpu(i)) {
-   if (i != task_cpu(p)) {
-   schedstat_inc(p,
-   se.nr_wakeups_idle);
-   }
-   return i;
-   }
-   }
-   } else {
-   break;
-   }
-   }
-   return cpu;
-}
-#else
-static inline int wake_idle(int cpu, struct task_struct *p)
-{
-   return cpu;
-}
-#endif
-
 /***
  * try_to_wake_up - wake up a thread
  * @p: the to-be-woken-up thread
@@ -1500,8 +1452,6 @@ static int try_to_wake_up(struct task_st
long old_state;
struct rq *rq;
 #ifdef CONFIG_SMP
-   struct sched_domain *sd, *this_sd = NULL;
-   unsigned long load, this_load;
int new_cpu;
 #endif
 
@@ -1521,90 +1471,14 @@ static int try_to_wake_up(struct task_st
if (unlikely(task_running(rq, p)))
goto out_activate;
 
-   new_cpu = cpu;
-
  

[PATCH v3 10/17] Remove some CFS specific code from the wakeup path of RT tasks

2007-11-16 Thread Steven Rostedt
From: Gregory Haskins [EMAIL PROTECTED]

The current wake-up code path tries to determine if it can optimize the
wake-up to this_cpu by computing load calculations.  The problem is that
these calculations are only relevant to CFS tasks where load is king.  For RT
tasks, priority is king.  So the load calculation is completely wasted
bandwidth.

Therefore, we create a new sched_class interface to help with
pre-wakeup routing decisions and move the load calculation as a function
of CFS task's class.

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
Signed-off-by: Steven Rostedt [EMAIL PROTECTED]
---

 include/linux/sched.h   |1 
 kernel/sched.c  |  144 +++-
 kernel/sched_fair.c |  132 
 kernel/sched_idletask.c |9 +++
 kernel/sched_rt.c   |8 ++
 5 files changed, 159 insertions(+), 135 deletions(-)

Index: linux-compile.git/include/linux/sched.h
===
--- linux-compile.git.orig/include/linux/sched.h2007-11-16 
22:12:34.0 -0500
+++ linux-compile.git/include/linux/sched.h 2007-11-16 22:23:39.0 
-0500
@@ -823,6 +823,7 @@ struct sched_class {
void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
void (*yield_task) (struct rq *rq);
+   int  (*select_task_rq)(struct task_struct *p, int sync);
 
void (*check_preempt_curr) (struct rq *rq, struct task_struct *p);
 
Index: linux-compile.git/kernel/sched.c
===
--- linux-compile.git.orig/kernel/sched.c   2007-11-16 22:12:34.0 
-0500
+++ linux-compile.git/kernel/sched.c2007-11-16 22:23:39.0 -0500
@@ -860,6 +860,10 @@ iter_move_one_task(struct rq *this_rq, i
   struct rq_iterator *iterator);
 #endif
 
+static unsigned long source_load(int cpu, int type);
+static unsigned long target_load(int cpu, int type);
+static unsigned long cpu_avg_load_per_task(int cpu);
+
 #include sched_stats.h
 #include sched_idletask.c
 #include sched_fair.c
@@ -1270,7 +1274,7 @@ static unsigned long target_load(int cpu
 /*
  * Return the average load per task on the cpu's run queue
  */
-static inline unsigned long cpu_avg_load_per_task(int cpu)
+static unsigned long cpu_avg_load_per_task(int cpu)
 {
struct rq *rq = cpu_rq(cpu);
unsigned long total = weighted_cpuload(cpu);
@@ -1427,58 +1431,6 @@ static int sched_balance_self(int cpu, i
 
 #endif /* CONFIG_SMP */
 
-/*
- * wake_idle() will wake a task on an idle cpu if task-cpu is
- * not idle and an idle cpu is available.  The span of cpus to
- * search starts with cpus closest then further out as needed,
- * so we always favor a closer, idle cpu.
- *
- * Returns the CPU we should wake onto.
- */
-#if defined(ARCH_HAS_SCHED_WAKE_IDLE)
-static int wake_idle(int cpu, struct task_struct *p)
-{
-   cpumask_t tmp;
-   struct sched_domain *sd;
-   int i;
-
-   /*
-* If it is idle, then it is the best cpu to run this task.
-*
-* This cpu is also the best, if it has more than one task already.
-* Siblings must be also busy(in most cases) as they didn't already
-* pickup the extra load from this cpu and hence we need not check
-* sibling runqueue info. This will avoid the checks and cache miss
-* penalities associated with that.
-*/
-   if (idle_cpu(cpu) || cpu_rq(cpu)-nr_running  1)
-   return cpu;
-
-   for_each_domain(cpu, sd) {
-   if (sd-flags  SD_WAKE_IDLE) {
-   cpus_and(tmp, sd-span, p-cpus_allowed);
-   for_each_cpu_mask(i, tmp) {
-   if (idle_cpu(i)) {
-   if (i != task_cpu(p)) {
-   schedstat_inc(p,
-   se.nr_wakeups_idle);
-   }
-   return i;
-   }
-   }
-   } else {
-   break;
-   }
-   }
-   return cpu;
-}
-#else
-static inline int wake_idle(int cpu, struct task_struct *p)
-{
-   return cpu;
-}
-#endif
-
 /***
  * try_to_wake_up - wake up a thread
  * @p: the to-be-woken-up thread
@@ -1500,8 +1452,6 @@ static int try_to_wake_up(struct task_st
long old_state;
struct rq *rq;
 #ifdef CONFIG_SMP
-   struct sched_domain *sd, *this_sd = NULL;
-   unsigned long load, this_load;
int new_cpu;
 #endif
 
@@ -1521,90 +1471,14 @@ static int try_to_wake_up(struct task_st
if (unlikely(task_running(rq, p)))
goto out_activate;
 
-   new_cpu = cpu;
-
schedstat_inc(rq,