Hottest Free Downloads - DownloadPipe.com Over 197,000 downloads! Bookmark Now!
DownloadPipe.com - New Downloads Every Minute
 SEARCH:
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

[PATCH 1/14] cpumask: simplify sched_rt.c

 
   Linux (Home) -> Kernel RSS
Next:  Accepted sm 2.2-3-2 (source i386)  
Author Message
Rusty Russell

External


Since: Jul 08, 2005
Posts: 25



(Msg. 1) Posted: Tue Nov 03, 2009 12:25 am
Post subject: [PATCH 1/14] cpumask: simplify sched_rt.c
Archived from groups: linux>kernel (more info?)

find_lowest_rq() wants to call pick_optimal_cpu() on the intersection
of sched_domain_span(sd) and lowest_mask. Rather than doing a cpus_and
into a temporary, we can open-code it.

This actually makes the code slightly clearer, IMHO.

Signed-off-by: Rusty Russell <rusty.RemoveThis@rustcorp.com.au>
To: Steven Rostedt <rostedt.RemoveThis@goodmis.org>
Cc: Ingo Molnar <mingo.RemoveThis@redhat.com>
---
kernel/sched_rt.c | 59 +++++++++++++++++++++---------------------------------
1 file changed, 23 insertions(+), 36 deletions(-)

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1115,29 +1115,12 @@ static struct task_struct *pick_next_hig

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 */
@@ -1167,28 +1150,26 @@ static int find_lowest_rq(struct task_st
* 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);
+ /*
+ * "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 = pick_optimal_cpu(this_cpu,
- domain_mask);
-
- if (best_cpu != -1) {
- free_cpumask_var(domain_mask);
- return best_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);
}

/*
@@ -1196,7 +1177,13 @@ static int find_lowest_rq(struct task_st
* 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 */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Steven Rostedt

External


Since: Jan 14, 2006
Posts: 224



(Msg. 2) Posted: Tue Nov 03, 2009 12:25 pm
Post subject: Re: [PATCH 1/14] cpumask: simplify sched_rt.c [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Greg,

I believe this was mostly your code. Can you review this change.

Thanks,

-- Steve


On Tue, 2009-11-03 at 14:53 +1030, Rusty Russell wrote:
> find_lowest_rq() wants to call pick_optimal_cpu() on the intersection
> of sched_domain_span(sd) and lowest_mask. Rather than doing a cpus_and
> into a temporary, we can open-code it.
>
> This actually makes the code slightly clearer, IMHO.
>
> Signed-off-by: Rusty Russell <rusty DeleteThis @rustcorp.com.au>
> To: Steven Rostedt <rostedt DeleteThis @goodmis.org>
> Cc: Ingo Molnar <mingo DeleteThis @redhat.com>
> ---
> kernel/sched_rt.c | 59 +++++++++++++++++++++---------------------------------
> 1 file changed, 23 insertions(+), 36 deletions(-)
>
> diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
> --- a/kernel/sched_rt.c
> +++ b/kernel/sched_rt.c
> @@ -1115,29 +1115,12 @@ static struct task_struct *pick_next_hig
>
> 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 */
> @@ -1167,28 +1150,26 @@ static int find_lowest_rq(struct task_st
> * 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);
> + /*
> + * "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 = pick_optimal_cpu(this_cpu,
> - domain_mask);
> -
> - if (best_cpu != -1) {
> - free_cpumask_var(domain_mask);
> - return best_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);
> }
>
> /*
> @@ -1196,7 +1177,13 @@ static int find_lowest_rq(struct task_st
> * 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 */
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Gregory Haskins

External


Since: Nov 03, 2009
Posts: 2



(Msg. 3) Posted: Tue Nov 03, 2009 5:25 pm
Post subject: Re: [PATCH 1/14] cpumask: simplify sched_rt.c [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>>> On 11/3/2009 at 11:41 AM, in message
<1257266509.26028.3343.camel RemoveThis @gandalf.stny.rr.com>, Steven Rostedt
<rostedt RemoveThis @goodmis.org> wrote:
> Greg,
>
> I believe this was mostly your code. Can you review this change.
>

Hi Steve,
FYI: Looking now. The diff hunk layout is a little confusing, so I need to think about it a little longer.

Kind Regards,
-Greg


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Gregory Haskins

External


Since: Nov 03, 2009
Posts: 2



(Msg. 4) Posted: Tue Nov 03, 2009 5:25 pm
Post subject: Re: [PATCH 1/14] cpumask: simplify sched_rt.c [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>>> On 11/3/2009 at 11:41 AM, in message
<1257266509.26028.3343.camel.RemoveThis@gandalf.stny.rr.com>, Steven Rostedt
<rostedt.RemoveThis@goodmis.org> wrote:
> Greg,
>
> I believe this was mostly your code. Can you review this change.
>
> Thanks,
>
> -- Steve
>
>
> On Tue, 2009-11-03 at 14:53 +1030, Rusty Russell wrote:
>> find_lowest_rq() wants to call pick_optimal_cpu() on the intersection
>> of sched_domain_span(sd) and lowest_mask. Rather than doing a cpus_and
>> into a temporary, we can open-code it.
>>
>> This actually makes the code slightly clearer, IMHO.
>>
>> Signed-off-by: Rusty Russell <rusty.RemoveThis@rustcorp.com.au>
>> To: Steven Rostedt <rostedt.RemoveThis@goodmis.org>
>> Cc: Ingo Molnar <mingo.RemoveThis@redhat.com>

I am not sure that I agree that its "clearer", but I do like the fact that the potentially nasty dynamic mask allocation is removed from the fast path.

I checked the logic, and it does appear to be functionally equivalent to the original.

Acked-by: Gregory Haskins <ghaskins.RemoveThis@novell.com>

>> ---
>> kernel/sched_rt.c | 59 +++++++++++++++++++++---------------------------------
>> 1 file changed, 23 insertions(+), 36 deletions(-)
>>
>> diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
>> --- a/kernel/sched_rt.c
>> +++ b/kernel/sched_rt.c
>> @@ -1115,29 +1115,12 @@ static struct task_struct *pick_next_hig
>>
>> 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 */
>> @@ -1167,28 +1150,26 @@ static int find_lowest_rq(struct task_st
>> * 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);
>> + /*
>> + * "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 = pick_optimal_cpu(this_cpu,
>> - domain_mask);
>> -
>> - if (best_cpu != -1) {
>> - free_cpumask_var(domain_mask);
>> - return best_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);
>> }
>>
>> /*
>> @@ -1196,7 +1177,13 @@ static int find_lowest_rq(struct task_st
>> * 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 */
>>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
tip-bot for Rusty Russell

External


Since: Nov 04, 2009
Posts: 1



(Msg. 5) Posted: Wed Nov 04, 2009 11:25 am
Post subject: [tip:sched/core] cpumask: Simplify sched_rt.c [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Commit-ID: e2c880630438f80b474378d5487b511b07665051
Gitweb: http://git.kernel.org/tip/e2c880630438f80b474378d5487b511b07665051
Author: Rusty Russell <rusty DeleteThis @rustcorp.com.au>
AuthorDate: Tue, 3 Nov 2009 14:53:15 +1030
Committer: Ingo Molnar <mingo DeleteThis @elte.hu>
CommitDate: Wed, 4 Nov 2009 13:16:38 +0100

cpumask: Simplify sched_rt.c

find_lowest_rq() wants to call pick_optimal_cpu() on the
intersection of sched_domain_span(sd) and lowest_mask. Rather
than doing a cpus_and into a temporary, we can open-code it.

This actually makes the code slightly clearer, IMHO.

Signed-off-by: Rusty Russell <rusty DeleteThis @rustcorp.com.au>
Acked-by: Gregory Haskins <ghaskins DeleteThis @novell.com>
Cc: Steven Rostedt <rostedt DeleteThis @goodmis.org>
LKML-Reference: <200911031453.15350.rusty DeleteThis @rustcorp.com.au>
Signed-off-by: Ingo Molnar <mingo DeleteThis @elte.hu>
---
kernel/sched_rt.c | 61 ++++++++++++++++++++--------------------------------
1 files changed, 24 insertions(+), 37 deletions(-)

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index a4d790c..5c5fef3 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1153,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 */
@@ -1198,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 (alloc_cpumask_var(&domain_mask, GFP_ATOMIC)) {
- for_each_domain(cpu, sd) {
- if (sd->flags & SD_WAKE_AFFINE) {
- int best_cpu;
+ if (!cpumask_test_cpu(this_cpu, lowest_mask))
+ this_cpu = -1; /* Skip this_cpu opt if not among lowest */

- cpumask_and(domain_mask,
- sched_domain_span(sd),
- lowest_mask);
+ for_each_domain(cpu, sd) {
+ if (sd->flags & SD_WAKE_AFFINE) {
+ int best_cpu;

- 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);
}

/*
@@ -1227,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 */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
[PATCH 4/14] cpumask: use struct cpumask rather than the d.. - Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> To: Ingo Molnar <mingo@elte.hu> --- arch/x86/include/asm/msr.h | 4 ++-- arch/x86/lib/msr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git..

[PATCH 2/10] make some arch depend routines accept cpumask - Make __cpu_disable/__cpu_die accept 'cpumask_t' parameter. Signed-off-by: Ashok Raj <ashok.raj@intel.com> Signed-off-by: Shaohua Li <shaohua.li@intel.com> --- linux-2.6.17-rc3-root/arch/arm/kernel/smp.c | 7 +++++-- ..

[PATCH 10/14] cpumask: convert drivers/idle/i7300_idle.c t.. - Fairly simple transformation: 1) cpumask_t -> cpumask_var_t and alloc_cpumask_var/free_cpumask_var (which are a NOOP unless CONFIG_CPUMASK_OFFSTACK=y). 2) cpu_set -> cpumask_set_cpu 3) cpus_weight -> cpumask_weight 4) cpu_clear -> cpumask_...

[PATCH] tracing: simplify print_graph_cpu() - print_graph_cpu() is little over-designed. And "log10_all" may be wrong when there are holes in cpu_online_mask: the max online cpu id > cpumask_weight(cpu_online_mask) Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> --- diff --g...

[PATCH] ia64: simplify and fix udelay() - The original ia64 udelay() was simple, but flawed for platforms without synchronized ITCs: a preemption and migration to another CPU during the while-loop likely resulted in too-early termination or very, very lengthy looping. The first fix (now in..
       Linux (Home) -> Kernel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
  Linux Forums
 Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact