sched: Sched Domains: Fixups
cover sched: Sched Domains: Fixups
Peter/Ingo,
These are minor fixes that I could find for code responsible for creating sched domains. They are rebased of my earlier fixes:
https://lkml.org/lkml/2013/6/4/253
I couldn't find them in linux-next or tip/master and so giving this link.
Viresh Kumar (3):
sched: don't initialize alloc_state in build_sched_domains
sched: don't sd->child to NULL when it is already NULL
sched: Create for_each_sd_topology()
kernel/sched/core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH 1/3 sched: don't initialize alloc_state in build_sched_domains
alloc_state will be overwritten by __visit_domain_allocation_hell() and so we don't actually need to initialize alloc_state.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -5956,7 +5956,7 @@ struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl,static int build_sched_domains (const struct cpumask *cpu_map,struct sched_domain_attr *attr) { -enum s_alloc alloc_state = sa_none; +enum s_alloc alloc_state;struct sched_domain *sd;struct s_data d;int i, ret = -ENOMEM ;
Signature · 1 line
1.7.12.rc2.18.g61b472e
tip-bot for Viresh Kumar
merge bot[tip:sched/core] sched: Don' t initialize alloc_state in build_sched_domains()
sched: Don't initialize alloc_state in build_sched_domains()
Commit-ID: 1c6321694074163b5863c13d71c19ca953a3fb08 Gitweb: http://git.kernel.org/tip/1c6321694074163b5863c13d71c19ca953a3fb08 Author: Viresh Kumar <[email protected]> AuthorDate: Mon, 10 Jun 2013 16:27:18 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 19 Jun 2013 12:58:44 +0200
sched: Don't initialize alloc_state in build_sched_domains()
alloc_state will be overwritten by __visit_domain_allocation_hell() and so we don't actually need to initialize alloc_state.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -5969,7 +5969,7 @@ struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl,static int build_sched_domains (const struct cpumask *cpu_map,struct sched_domain_attr *attr) { -enum s_alloc alloc_state = sa_none; +enum s_alloc alloc_state;struct sched_domain *sd;struct s_data d;int i, ret = -ENOMEM ;
PATCH 2/3 sched: don't sd->child to NULL when it is already NULL
In reply to Viresh KumarMemory for sd is allocated with kzalloc_node() which will initialize its fields with zero. In build_sched_domain() we are setting sd->child to child even if child is NULL, which isn't required.
Lets do it only if child isn't NULL.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -5942,8 +5942,8 @@ struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl, sd->level = child->level +1 ; sched_domain_level_max =max (sched_domain_level_max, sd->level); child->parent = sd; + sd->child = child; } - sd->child = child;set_domain_attribute (sd, attr);return sd;
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 2/3] sched: don't sd->child to NULL when it is already NULL
On 10 June 2013 16:27, Viresh Kumar <[email protected]> wrote:
Yes subject should be: sched: don't set sd->child to NULL when it is already NULL
tip-bot for Viresh Kumar
merge bot[tip:sched/core] sched: Don't set sd-> child to NULL when it is already NULL
In reply to Viresh Kumarsched: Don't set sd->child to NULL when it is already NULL
Commit-ID: c75e01288ce9c9a6b7beb6b23c07d2e4d1db8c84 Gitweb: http://git.kernel.org/tip/c75e01288ce9c9a6b7beb6b23c07d2e4d1db8c84 Author: Viresh Kumar <[email protected]> AuthorDate: Mon, 10 Jun 2013 16:27:19 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 19 Jun 2013 12:58:45 +0200
sched: Don't set sd->child to NULL when it is already NULL
Memory for sd is allocated with kzalloc_node() which will initialize its fields with zero. In build_sched_domain() we are setting sd->child to child even if child is NULL, which isn't required.
Lets do it only if child isn't NULL.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -5955,8 +5955,8 @@ struct sched_domain *build_sched_domain(struct sched_domain_topology_level *tl, sd->level = child->level +1 ; sched_domain_level_max =max (sched_domain_level_max, sd->level); child->parent = sd; + sd->child = child; } - sd->child = child;set_domain_attribute (sd, attr);return sd;
PATCH 3/3 sched: Create for_each_sd_topology()
In reply to Viresh KumarFor loop for traversing sched_domain_topology was used at multiple placed in core.c. This patch removes code redundancy by creating for_each_sd_topology().
--- kernel/sched/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/sched/core.c +6 -3
@@ -5552,6 +5552,9 @@ static struct sched_domain_topology_level default_topology[] = {static struct sched_domain_topology_level *sched_domain_topology = default_topology; +#define for_each_sd_topology (tl) \ + for (tl = sched_domain_topology; tl->init; tl++) +#ifdef CONFIG_NUMA static int sched_domains_numa_levels;
@@ -5849,7 +5852,7 @@ static int __sdt_alloc(const struct cpumask *cpu_map)struct sched_domain_topology_level *tl;int j; -for (tl = sched_domain_topology; tl->init; tl++) { +for_each_sd_topology (tl) {struct sd_data *sdd = &tl->data; sdd->sd = alloc_percpu(struct sched_domain *);
@@ -5902,7 +5905,7 @@ static void __sdt_free(const struct cpumask *cpu_map)struct sched_domain_topology_level *tl;int j; -for (tl = sched_domain_topology; tl->init; tl++) { +for_each_sd_topology (tl) {struct sd_data *sdd = &tl->data;for_each_cpu (j, cpu_map) {
@@ -5970,7 +5973,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,struct sched_domain_topology_level *tl; sd =NULL ; -for (tl = sched_domain_topology; tl->init; tl++) { +for_each_sd_topology (tl) { sd =build_sched_domain (tl, cpu_map, attr, sd, i);if (tl == sched_domain_topology) *per_cpu_ptr (d.sd, i) = sd;
Signature · 1 line
1.7.12.rc2.18.g61b472e
tip-bot for Viresh Kumar
merge bot[tip:sched/core] sched: Create for_each_sd_topology()
sched: Create for_each_sd_topology()
Commit-ID: 27723a68caf05381b0b0bc6e127da2c9e7bcb775 Gitweb: http://git.kernel.org/tip/27723a68caf05381b0b0bc6e127da2c9e7bcb775 Author: Viresh Kumar <[email protected]> AuthorDate: Mon, 10 Jun 2013 16:27:20 +0530 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 19 Jun 2013 12:58:45 +0200
sched: Create for_each_sd_topology()
For loop for traversing sched_domain_topology was used at multiple placed in core.c. This patch removes code redundancy by creating for_each_sd_topology().
--- kernel/sched/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/sched/core.c +6 -3
@@ -5565,6 +5565,9 @@ static struct sched_domain_topology_level default_topology[] = {static struct sched_domain_topology_level *sched_domain_topology = default_topology; +#define for_each_sd_topology (tl) \ + for (tl = sched_domain_topology; tl->init; tl++) +#ifdef CONFIG_NUMA static int sched_domains_numa_levels;
@@ -5862,7 +5865,7 @@ static int __sdt_alloc(const struct cpumask *cpu_map)struct sched_domain_topology_level *tl;int j; -for (tl = sched_domain_topology; tl->init; tl++) { +for_each_sd_topology (tl) {struct sd_data *sdd = &tl->data; sdd->sd = alloc_percpu(struct sched_domain *);
@@ -5915,7 +5918,7 @@ static void __sdt_free(const struct cpumask *cpu_map)struct sched_domain_topology_level *tl;int j; -for (tl = sched_domain_topology; tl->init; tl++) { +for_each_sd_topology (tl) {struct sd_data *sdd = &tl->data;for_each_cpu (j, cpu_map) {
@@ -5983,7 +5986,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,struct sched_domain_topology_level *tl; sd =NULL ; -for (tl = sched_domain_topology; tl->init; tl++) { +for_each_sd_topology (tl) { sd =build_sched_domain (tl, cpu_map, attr, sd, i);if (tl == sched_domain_topology) *per_cpu_ptr (d.sd, i) = sd;
Peter Zijlstra
maintainerQuoted 9 lines · Viresh Kumar
Peter/Ingo,
These are minor fixes that I could find for code responsible for creating sched domains. They are rebased of my earlier fixes:
https://lkml.org/lkml/2013/6/4/253
I couldn't find them in linux-next or tip/master and so giving this link.
Quoted 8 lines
Viresh Kumar (3):
sched: don't initializealloc_stateinbuild_sched_domains
sched: don'tsd->childto NULL when it is already NULL
sched: Createfor_each_sd_topology()kernel/sched/core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Thanks!