linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
@ 2013-06-04 11:20 Viresh Kumar
  2013-06-04 11:20 ` [PATCH 2/2] sched: Remove unused params of build_sched_domain() Viresh Kumar
  2013-06-05  4:42 ` [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Michael Wang
  0 siblings, 2 replies; 8+ messages in thread
From: Viresh Kumar @ 2013-06-04 11:20 UTC (permalink / raw)
  To: mingo, peterz
  Cc: linaro-kernel, patches, linux-kernel, robin.randhawa,
	Steve.Bannister, Liviu.Dudau, charles.garcia-tobin,
	arvind.chauhan, Viresh Kumar

We are saving first scheduling domain for a cpu in build_sched_domains() by
iterating over the nested sd->child list. We don't actually need to do it this
way.

*per_cpu_ptr(d.sd, i) is guaranteed to be NULL in the beginning as we have
called __visit_domain_allocation_hell() which does a memset to zero for struct
s_data.

So, save pointer to first SD while running the iteration loop over tl's.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/sched/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 58453b8..638f6cb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
 		sd = NULL;
 		for (tl = sched_domain_topology; tl->init; tl++) {
 			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+			if (!*per_cpu_ptr(d.sd, i))
+				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
 				sd->flags |= SD_OVERLAP;
 			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
 				break;
 		}
-
-		while (sd->child)
-			sd = sd->child;
-
-		*per_cpu_ptr(d.sd, i) = sd;
 	}
 
 	/* Build the groups for the domains */
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] sched: Remove unused params of build_sched_domain()
  2013-06-04 11:20 [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Viresh Kumar
@ 2013-06-04 11:20 ` Viresh Kumar
  2013-06-05  4:42 ` [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Michael Wang
  1 sibling, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2013-06-04 11:20 UTC (permalink / raw)
  To: mingo, peterz
  Cc: linaro-kernel, patches, linux-kernel, robin.randhawa,
	Steve.Bannister, Liviu.Dudau, charles.garcia-tobin,
	arvind.chauhan, Viresh Kumar

build_sched_domain() never uses parameter struct s_data *d and so passing it is
useless.

Remove it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/sched/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 638f6cb..4210c54 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6490,9 +6490,8 @@ static void __sdt_free(const struct cpumask *cpu_map)
 }
 
 struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl,
-		struct s_data *d, const struct cpumask *cpu_map,
-		struct sched_domain_attr *attr, struct sched_domain *child,
-		int cpu)
+		const struct cpumask *cpu_map, struct sched_domain_attr *attr,
+		struct sched_domain *child, int cpu)
 {
 	struct sched_domain *sd = tl->init(tl, cpu);
 	if (!sd)
@@ -6532,7 +6531,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
 
 		sd = NULL;
 		for (tl = sched_domain_topology; tl->init; tl++) {
-			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+			sd = build_sched_domain(tl, cpu_map, attr, sd, i);
 			if (!*per_cpu_ptr(d.sd, i))
 				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
  2013-06-04 11:20 [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Viresh Kumar
  2013-06-04 11:20 ` [PATCH 2/2] sched: Remove unused params of build_sched_domain() Viresh Kumar
@ 2013-06-05  4:42 ` Michael Wang
  2013-06-05  5:07   ` Viresh Kumar
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Wang @ 2013-06-05  4:42 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: mingo, peterz, linaro-kernel, patches, linux-kernel,
	robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, arvind.chauhan

Hi, Viresh

On 06/04/2013 07:20 PM, Viresh Kumar wrote:
[snip]
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 58453b8..638f6cb 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
>  		sd = NULL;
>  		for (tl = sched_domain_topology; tl->init; tl++) {
>  			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
> +			if (!*per_cpu_ptr(d.sd, i))

What about:
			if (tl == sched_domain_topology)

It cost less than per_cpu_ptr(), isn't it?

Regards,
Michael Wang

> +				*per_cpu_ptr(d.sd, i) = sd;
>  			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
>  				sd->flags |= SD_OVERLAP;
>  			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
>  				break;
>  		}
> -
> -		while (sd->child)
> -			sd = sd->child;
> -
> -		*per_cpu_ptr(d.sd, i) = sd;
>  	}
> 
>  	/* Build the groups for the domains */
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
  2013-06-05  4:42 ` [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Michael Wang
@ 2013-06-05  5:07   ` Viresh Kumar
  2013-06-05  5:26     ` Michael Wang
  2013-06-05 11:04     ` Peter Zijlstra
  0 siblings, 2 replies; 8+ messages in thread
From: Viresh Kumar @ 2013-06-05  5:07 UTC (permalink / raw)
  To: Michael Wang
  Cc: mingo, peterz, linaro-kernel, patches, linux-kernel,
	robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, arvind.chauhan

[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]

On 5 June 2013 10:12, Michael Wang <wangyun@linux.vnet.ibm.com> wrote:
> Hi, Viresh
>
> On 06/04/2013 07:20 PM, Viresh Kumar wrote:
> [snip]
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 58453b8..638f6cb 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
>>               sd = NULL;
>>               for (tl = sched_domain_topology; tl->init; tl++) {
>>                       sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
>> +                     if (!*per_cpu_ptr(d.sd, i))
>
> What about:
>                         if (tl == sched_domain_topology)
>
> It cost less than per_cpu_ptr(), isn't it?

How can I miss it.. Obviously its better :)

See if below one looks better (Attached too in case gmail screws up
my mail)..

--------x-------------x------------------

From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 4 Jun 2013 15:41:15 +0530
Subject: [PATCH] sched: Optimize build_sched_domains() for saving first SD
 node for a cpu

We are saving first scheduling domain for a cpu in build_sched_domains() by
iterating over the nested sd->child list. We don't actually need to do it this
way.

tl will be equal to sched_domain_topology for the first iteration and so we can
set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
running the iteration loop over tl's.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/sched/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 58453b8..08a27be 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct
cpumask *cpu_map,
 		sd = NULL;
 		for (tl = sched_domain_topology; tl->init; tl++) {
 			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+			if (tl == sched_domain_topology)
+				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
 				sd->flags |= SD_OVERLAP;
 			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
 				break;
 		}
-
-		while (sd->child)
-			sd = sd->child;
-
-		*per_cpu_ptr(d.sd, i) = sd;
 	}

 	/* Build the groups for the domains */

[-- Attachment #2: 0001-sched-Optimize-build_sched_domains-for-saving-first-.patch --]
[-- Type: application/octet-stream, Size: 1576 bytes --]

From 460dbeaaea77a939e42b5a51cb27578f7bcb8f4d Mon Sep 17 00:00:00 2001
Message-Id: <460dbeaaea77a939e42b5a51cb27578f7bcb8f4d.1370408787.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 4 Jun 2013 15:41:15 +0530
Subject: [PATCH] sched: Optimize build_sched_domains() for saving first SD
 node for a cpu

We are saving first scheduling domain for a cpu in build_sched_domains() by
iterating over the nested sd->child list. We don't actually need to do it this
way.

tl will be equal to sched_domain_topology for the first iteration and so we can
set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
running the iteration loop over tl's.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/sched/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 58453b8..08a27be 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
 		sd = NULL;
 		for (tl = sched_domain_topology; tl->init; tl++) {
 			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+			if (tl == sched_domain_topology)
+				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
 				sd->flags |= SD_OVERLAP;
 			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
 				break;
 		}
-
-		while (sd->child)
-			sd = sd->child;
-
-		*per_cpu_ptr(d.sd, i) = sd;
 	}
 
 	/* Build the groups for the domains */
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
  2013-06-05  5:07   ` Viresh Kumar
@ 2013-06-05  5:26     ` Michael Wang
  2013-06-05 11:04     ` Peter Zijlstra
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Wang @ 2013-06-05  5:26 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: mingo, peterz, linaro-kernel, patches, linux-kernel,
	robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, arvind.chauhan

On 06/05/2013 01:07 PM, Viresh Kumar wrote:
> On 5 June 2013 10:12, Michael Wang <wangyun@linux.vnet.ibm.com> wrote:
>> Hi, Viresh
>>
>> On 06/04/2013 07:20 PM, Viresh Kumar wrote:
>> [snip]
>>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>>> index 58453b8..638f6cb 100644
>>> --- a/kernel/sched/core.c
>>> +++ b/kernel/sched/core.c
>>> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
>>>               sd = NULL;
>>>               for (tl = sched_domain_topology; tl->init; tl++) {
>>>                       sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
>>> +                     if (!*per_cpu_ptr(d.sd, i))
>>
>> What about:
>>                         if (tl == sched_domain_topology)
>>
>> It cost less than per_cpu_ptr(), isn't it?
> 
> How can I miss it.. Obviously its better :)
> 
> See if below one looks better (Attached too in case gmail screws up
> my mail)..

Looks good to me :)

Regards,
Michael Wang

> 
> --------x-------------x------------------
> 
> From: Viresh Kumar <viresh.kumar@linaro.org>
> Date: Tue, 4 Jun 2013 15:41:15 +0530
> Subject: [PATCH] sched: Optimize build_sched_domains() for saving first SD
>  node for a cpu
> 
> We are saving first scheduling domain for a cpu in build_sched_domains() by
> iterating over the nested sd->child list. We don't actually need to do it this
> way.
> 
> tl will be equal to sched_domain_topology for the first iteration and so we can
> set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
> running the iteration loop over tl's.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  kernel/sched/core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 58453b8..08a27be 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct
> cpumask *cpu_map,
>  		sd = NULL;
>  		for (tl = sched_domain_topology; tl->init; tl++) {
>  			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
> +			if (tl == sched_domain_topology)
> +				*per_cpu_ptr(d.sd, i) = sd;
>  			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
>  				sd->flags |= SD_OVERLAP;
>  			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
>  				break;
>  		}
> -
> -		while (sd->child)
> -			sd = sd->child;
> -
> -		*per_cpu_ptr(d.sd, i) = sd;
>  	}
> 
>  	/* Build the groups for the domains */
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
  2013-06-05  5:07   ` Viresh Kumar
  2013-06-05  5:26     ` Michael Wang
@ 2013-06-05 11:04     ` Peter Zijlstra
  2013-06-05 12:42       ` Viresh Kumar
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Zijlstra @ 2013-06-05 11:04 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Michael Wang, mingo, linaro-kernel, patches, linux-kernel,
	robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, arvind.chauhan

On Wed, Jun 05, 2013 at 10:37:29AM +0530, Viresh Kumar wrote:
> On 5 June 2013 10:12, Michael Wang <wangyun@linux.vnet.ibm.com> wrote:
> > Hi, Viresh
> >
> > On 06/04/2013 07:20 PM, Viresh Kumar wrote:
> > [snip]
> >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> >> index 58453b8..638f6cb 100644
> >> --- a/kernel/sched/core.c
> >> +++ b/kernel/sched/core.c
> >> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
> >>               sd = NULL;
> >>               for (tl = sched_domain_topology; tl->init; tl++) {
> >>                       sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
> >> +                     if (!*per_cpu_ptr(d.sd, i))
> >
> > What about:
> >                         if (tl == sched_domain_topology)
> >
> > It cost less than per_cpu_ptr(), isn't it?
> 
> How can I miss it.. Obviously its better :)
> 
> See if below one looks better (Attached too in case gmail screws up
> my mail)..
> 
> --------x-------------x------------------
> 
> From: Viresh Kumar <viresh.kumar@linaro.org>
> Date: Tue, 4 Jun 2013 15:41:15 +0530
> Subject: [PATCH] sched: Optimize build_sched_domains() for saving first SD
>  node for a cpu
> 
> We are saving first scheduling domain for a cpu in build_sched_domains() by
> iterating over the nested sd->child list. We don't actually need to do it this
> way.
> 
> tl will be equal to sched_domain_topology for the first iteration and so we can
> set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
> running the iteration loop over tl's.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  kernel/sched/core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 58453b8..08a27be 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct
> cpumask *cpu_map,

Applying patch
patches/viresh_kumar-_patch__sched-optimize_build_sched_domains_for_saving_first_sd.patch
patching file kernel/sched/core.c
patch: **** malformed patch at line 56: cpumask *cpu_map,


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
  2013-06-05 11:04     ` Peter Zijlstra
@ 2013-06-05 12:42       ` Viresh Kumar
  2013-06-05 13:03         ` Peter Zijlstra
  0 siblings, 1 reply; 8+ messages in thread
From: Viresh Kumar @ 2013-06-05 12:42 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Michael Wang, mingo, linaro-kernel, patches, linux-kernel,
	robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, arvind.chauhan

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

On 5 June 2013 16:34, Peter Zijlstra <peterz@infradead.org> wrote:
> On Wed, Jun 05, 2013 at 10:37:29AM +0530, Viresh Kumar wrote:

>> See if below one looks better (Attached too in case gmail screws up
>> my mail)..

> Applying patch
> patches/viresh_kumar-_patch__sched-optimize_build_sched_domains_for_saving_first_sd.patch
> patching file kernel/sched/core.c
> patch: **** malformed patch at line 56: cpumask *cpu_map,

You tried to apply patch from mail or attachment? I requested to
pick attachment as gmail's copy-paste screws up patches.

I rebased it over tip/master now:

2bf6874 Merge branch 'x86/cleanups'

Patches are attached now.

[-- Attachment #2: 0001-sched-Remove-unused-params-of-build_sched_domain.patch --]
[-- Type: application/octet-stream, Size: 1589 bytes --]

From 545e0b4536166a15b4475abcafe5ed0db4ad4a2c Mon Sep 17 00:00:00 2001
Message-Id: <545e0b4536166a15b4475abcafe5ed0db4ad4a2c.1370436120.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 4 Jun 2013 16:12:43 +0530
Subject: [PATCH 1/2] sched: Remove unused params of build_sched_domain()

build_sched_domain() never uses parameter struct s_data *d and so passing it is
useless.

Remove it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/sched/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 52a1760..0623703 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5930,9 +5930,8 @@ static void __sdt_free(const struct cpumask *cpu_map)
 }
 
 struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl,
-		struct s_data *d, const struct cpumask *cpu_map,
-		struct sched_domain_attr *attr, struct sched_domain *child,
-		int cpu)
+		const struct cpumask *cpu_map, struct sched_domain_attr *attr,
+		struct sched_domain *child, int cpu)
 {
 	struct sched_domain *sd = tl->init(tl, cpu);
 	if (!sd)
@@ -5972,7 +5971,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
 
 		sd = NULL;
 		for (tl = sched_domain_topology; tl->init; tl++) {
-			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+			sd = build_sched_domain(tl, cpu_map, attr, sd, i);
 			if (tl == sched_domain_topology)
 				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
-- 
1.7.12.rc2.18.g61b472e


[-- Attachment #3: 0002-sched-Optimize-build_sched_domains-for-saving-first-.patch --]
[-- Type: application/octet-stream, Size: 1770 bytes --]

From fc473527cbc4dfa0b8eeef2a59db74684eb59a83 Mon Sep 17 00:00:00 2001
Message-Id: <fc473527cbc4dfa0b8eeef2a59db74684eb59a83.1370436120.git.viresh.kumar@linaro.org>
In-Reply-To: <545e0b4536166a15b4475abcafe5ed0db4ad4a2c.1370436120.git.viresh.kumar@linaro.org>
References: <545e0b4536166a15b4475abcafe5ed0db4ad4a2c.1370436120.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 4 Jun 2013 15:41:15 +0530
Subject: [PATCH 2/2] sched: Optimize build_sched_domains() for saving first
 SD node for a cpu

We are saving first scheduling domain for a cpu in build_sched_domains() by
iterating over the nested sd->child list. We don't actually need to do it this
way.

tl will be equal to sched_domain_topology for the first iteration and so we can
set *per_cpu_ptr(d.sd, i) based on that.  So, save pointer to first SD while
running the iteration loop over tl's.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/sched/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 142c682f..52a1760 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5973,16 +5973,13 @@ static int build_sched_domains(const struct cpumask *cpu_map,
 		sd = NULL;
 		for (tl = sched_domain_topology; tl->init; tl++) {
 			sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+			if (tl == sched_domain_topology)
+				*per_cpu_ptr(d.sd, i) = sd;
 			if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
 				sd->flags |= SD_OVERLAP;
 			if (cpumask_equal(cpu_map, sched_domain_span(sd)))
 				break;
 		}
-
-		while (sd->child)
-			sd = sd->child;
-
-		*per_cpu_ptr(d.sd, i) = sd;
 	}
 
 	/* Build the groups for the domains */
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu
  2013-06-05 12:42       ` Viresh Kumar
@ 2013-06-05 13:03         ` Peter Zijlstra
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Zijlstra @ 2013-06-05 13:03 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Michael Wang, mingo, linaro-kernel, patches, linux-kernel,
	robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, arvind.chauhan

On Wed, Jun 05, 2013 at 06:12:15PM +0530, Viresh Kumar wrote:
> On 5 June 2013 16:34, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Wed, Jun 05, 2013 at 10:37:29AM +0530, Viresh Kumar wrote:
> 
> >> See if below one looks better (Attached too in case gmail screws up
> >> my mail)..
> 
> > Applying patch
> > patches/viresh_kumar-_patch__sched-optimize_build_sched_domains_for_saving_first_sd.patch
> > patching file kernel/sched/core.c
> > patch: **** malformed patch at line 56: cpumask *cpu_map,
> 
> You tried to apply patch from mail or attachment? I requested to
> pick attachment as gmail's copy-paste screws up patches.
> 

>From email; that's what my mailer is scripted for. TBH I didn't even
notice the attachment.

I'll go prod at the attachment.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-05 13:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-04 11:20 [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Viresh Kumar
2013-06-04 11:20 ` [PATCH 2/2] sched: Remove unused params of build_sched_domain() Viresh Kumar
2013-06-05  4:42 ` [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu Michael Wang
2013-06-05  5:07   ` Viresh Kumar
2013-06-05  5:26     ` Michael Wang
2013-06-05 11:04     ` Peter Zijlstra
2013-06-05 12:42       ` Viresh Kumar
2013-06-05 13:03         ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).