public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains
@ 2022-02-18 16:27 K Prateek Nayak
  2022-03-04  3:48 ` K Prateek Nayak
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: K Prateek Nayak @ 2022-02-18 16:27 UTC (permalink / raw)
  To: peterz
  Cc: aubrey.li, efault, gautham.shenoy, linux-kernel, mgorman, mingo,
	song.bao.hua, srikar, valentin.schneider, vincent.guittot

While investigating the sparse warning reported by the LKP bot [1],
observed that we have a redundant variable "top" in the function
build_sched_domains that was introduced in the recent commit
e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when
SD_NUMA spans multiple LLCs")

The existing variable "sd" suffices which allows us to remove the
redundant variable "top" while annotating the other variable "top_p"
with the "__rcu" annotation to silence the sparse warning.

[1] https://lore.kernel.org/lkml/202202170853.9vofgC3O-lkp@intel.com/

Fixes: e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
---
 kernel/sched/topology.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index e6cd55951304..4b757fb8f661 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2255,7 +2255,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 
 			if (!(sd->flags & SD_SHARE_PKG_RESOURCES) && child &&
 			    (child->flags & SD_SHARE_PKG_RESOURCES)) {
-				struct sched_domain *top, *top_p;
+				struct sched_domain __rcu *top_p;
 				unsigned int nr_llcs;
 
 				/*
@@ -2280,11 +2280,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 				sd->imb_numa_nr = imb;
 
 				/* Set span based on the first NUMA domain. */
-				top = sd;
-				top_p = top->parent;
+				top_p = sd->parent;
 				while (top_p && !(top_p->flags & SD_NUMA)) {
-					top = top->parent;
-					top_p = top->parent;
+					top_p = top_p->parent;
 				}
 				imb_span = top_p ? top_p->span_weight : sd->span_weight;
 			} else {
-- 
2.25.1


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

* Re: [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains
  2022-02-18 16:27 [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains K Prateek Nayak
@ 2022-03-04  3:48 ` K Prateek Nayak
  2022-03-04 12:56 ` Valentin Schneider
  2022-03-08 22:25 ` [tip: sched/core] " tip-bot2 for K Prateek Nayak
  2 siblings, 0 replies; 5+ messages in thread
From: K Prateek Nayak @ 2022-03-04  3:48 UTC (permalink / raw)
  To: peterz
  Cc: aubrey.li, efault, gautham.shenoy, linux-kernel, mgorman, mingo,
	song.bao.hua, srikar, valentin.schneider, vincent.guittot

Hello everyone,

Ping :)

On 2/18/2022 9:57 PM, K Prateek Nayak wrote:
> While investigating the sparse warning reported by the LKP bot [1],
> observed that we have a redundant variable "top" in the function
> build_sched_domains that was introduced in the recent commit
> e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when
> SD_NUMA spans multiple LLCs")
> 
> The existing variable "sd" suffices which allows us to remove the
> redundant variable "top" while annotating the other variable "top_p"
> with the "__rcu" annotation to silence the sparse warning.
> 
> [1] https://lore.kernel.org/lkml/202202170853.9vofgC3O-lkp@intel.com/
> 
> Fixes: e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
> ---
>  kernel/sched/topology.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index e6cd55951304..4b757fb8f661 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -2255,7 +2255,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
>  
>  			if (!(sd->flags & SD_SHARE_PKG_RESOURCES) && child &&
>  			    (child->flags & SD_SHARE_PKG_RESOURCES)) {
> -				struct sched_domain *top, *top_p;
> +				struct sched_domain __rcu *top_p;
>  				unsigned int nr_llcs;
>  
>  				/*
> @@ -2280,11 +2280,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
>  				sd->imb_numa_nr = imb;
>  
>  				/* Set span based on the first NUMA domain. */
> -				top = sd;
> -				top_p = top->parent;
> +				top_p = sd->parent;
>  				while (top_p && !(top_p->flags & SD_NUMA)) {
> -					top = top->parent;
> -					top_p = top->parent;
> +					top_p = top_p->parent;
>  				}
>  				imb_span = top_p ? top_p->span_weight : sd->span_weight;
>  			} else {

--
Thanks and Regards,
Prateek

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

* Re: [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains
  2022-02-18 16:27 [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains K Prateek Nayak
  2022-03-04  3:48 ` K Prateek Nayak
@ 2022-03-04 12:56 ` Valentin Schneider
  2022-03-04 13:49   ` Peter Zijlstra
  2022-03-08 22:25 ` [tip: sched/core] " tip-bot2 for K Prateek Nayak
  2 siblings, 1 reply; 5+ messages in thread
From: Valentin Schneider @ 2022-03-04 12:56 UTC (permalink / raw)
  To: K Prateek Nayak, peterz
  Cc: aubrey.li, efault, gautham.shenoy, linux-kernel, mgorman, mingo,
	song.bao.hua, srikar, vincent.guittot

On 18/02/22 21:57, K Prateek Nayak wrote:
> While investigating the sparse warning reported by the LKP bot [1],
> observed that we have a redundant variable "top" in the function
> build_sched_domains that was introduced in the recent commit
> e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when
> SD_NUMA spans multiple LLCs")
>
> The existing variable "sd" suffices which allows us to remove the
> redundant variable "top" while annotating the other variable "top_p"
> with the "__rcu" annotation to silence the sparse warning.
>
> [1] https://lore.kernel.org/lkml/202202170853.9vofgC3O-lkp@intel.com/
>
> Fixes: e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
> ---
>  kernel/sched/topology.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index e6cd55951304..4b757fb8f661 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -2255,7 +2255,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
>
>                       if (!(sd->flags & SD_SHARE_PKG_RESOURCES) && child &&
>                           (child->flags & SD_SHARE_PKG_RESOURCES)) {
> -				struct sched_domain *top, *top_p;
> +				struct sched_domain __rcu *top_p;
>                               unsigned int nr_llcs;
>
>                               /*
> @@ -2280,11 +2280,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
>                               sd->imb_numa_nr = imb;
>
>                               /* Set span based on the first NUMA domain. */
> -				top = sd;
> -				top_p = top->parent;
> +				top_p = sd->parent;
>                               while (top_p && !(top_p->flags & SD_NUMA)) {
> -					top = top->parent;
> -					top_p = top->parent;
> +					top_p = top_p->parent;
>                               }
>                               imb_span = top_p ? top_p->span_weight : sd->span_weight;


So sd starts as the first domain without SD_SHARE_PKG_RESOURCES (but its
direct child has it), and the loop searches upward for a NUMA domain. This
indeed shouldn't require two variables.

I was going to say that while you're at it, you could init top_p to sd
rather than sd->parent in case someone runs a non-default
sched_domain_topology[], but NODE should have neither
SD_SHARE_PKG_RESOURCES nor SD_NUMA, so that doesn't seem required.

Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>

>                       } else {
> --
> 2.25.1

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

* Re: [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains
  2022-03-04 12:56 ` Valentin Schneider
@ 2022-03-04 13:49   ` Peter Zijlstra
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2022-03-04 13:49 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: K Prateek Nayak, aubrey.li, efault, gautham.shenoy, linux-kernel,
	mgorman, mingo, song.bao.hua, srikar, vincent.guittot

On Fri, Mar 04, 2022 at 12:56:44PM +0000, Valentin Schneider wrote:
> On 18/02/22 21:57, K Prateek Nayak wrote:
> > While investigating the sparse warning reported by the LKP bot [1],
> > observed that we have a redundant variable "top" in the function
> > build_sched_domains that was introduced in the recent commit
> > e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when
> > SD_NUMA spans multiple LLCs")
> >
> > The existing variable "sd" suffices which allows us to remove the
> > redundant variable "top" while annotating the other variable "top_p"
> > with the "__rcu" annotation to silence the sparse warning.
> >
> > [1] https://lore.kernel.org/lkml/202202170853.9vofgC3O-lkp@intel.com/
> >
> > Fixes: e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
> > ---
> >  kernel/sched/topology.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> > index e6cd55951304..4b757fb8f661 100644
> > --- a/kernel/sched/topology.c
> > +++ b/kernel/sched/topology.c
> > @@ -2255,7 +2255,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
> >
> >                       if (!(sd->flags & SD_SHARE_PKG_RESOURCES) && child &&
> >                           (child->flags & SD_SHARE_PKG_RESOURCES)) {
> > -				struct sched_domain *top, *top_p;
> > +				struct sched_domain __rcu *top_p;
> >                               unsigned int nr_llcs;
> >
> >                               /*
> > @@ -2280,11 +2280,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
> >                               sd->imb_numa_nr = imb;
> >
> >                               /* Set span based on the first NUMA domain. */
> > -				top = sd;
> > -				top_p = top->parent;
> > +				top_p = sd->parent;
> >                               while (top_p && !(top_p->flags & SD_NUMA)) {
> > -					top = top->parent;
> > -					top_p = top->parent;
> > +					top_p = top_p->parent;
> >                               }
> >                               imb_span = top_p ? top_p->span_weight : sd->span_weight;
> 
> 
> So sd starts as the first domain without SD_SHARE_PKG_RESOURCES (but its
> direct child has it), and the loop searches upward for a NUMA domain. This
> indeed shouldn't require two variables.
> 
> I was going to say that while you're at it, you could init top_p to sd
> rather than sd->parent in case someone runs a non-default
> sched_domain_topology[], but NODE should have neither
> SD_SHARE_PKG_RESOURCES nor SD_NUMA, so that doesn't seem required.
> 
> Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>

Thanks!

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

* [tip: sched/core] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains
  2022-02-18 16:27 [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains K Prateek Nayak
  2022-03-04  3:48 ` K Prateek Nayak
  2022-03-04 12:56 ` Valentin Schneider
@ 2022-03-08 22:25 ` tip-bot2 for K Prateek Nayak
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for K Prateek Nayak @ 2022-03-08 22:25 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kernel test robot, K Prateek Nayak, Peter Zijlstra (Intel),
	Valentin Schneider, x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     7f434dff76215af00c26ba6449eaa4738fe9e2ab
Gitweb:        https://git.kernel.org/tip/7f434dff76215af00c26ba6449eaa4738fe9e2ab
Author:        K Prateek Nayak <kprateek.nayak@amd.com>
AuthorDate:    Fri, 18 Feb 2022 21:57:43 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 08 Mar 2022 16:08:40 +01:00

sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains

While investigating the sparse warning reported by the LKP bot [1],
observed that we have a redundant variable "top" in the function
build_sched_domains that was introduced in the recent commit
e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when
SD_NUMA spans multiple LLCs")

The existing variable "sd" suffices which allows us to remove the
redundant variable "top" while annotating the other variable "top_p"
with the "__rcu" annotation to silence the sparse warning.

[1] https://lore.kernel.org/lkml/202202170853.9vofgC3O-lkp@intel.com/

Fixes: e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Link: https://lore.kernel.org/r/20220218162743.1134-1-kprateek.nayak@amd.com
---
 kernel/sched/topology.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 32841c6..43f2899 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2291,7 +2291,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 
 			if (!(sd->flags & SD_SHARE_PKG_RESOURCES) && child &&
 			    (child->flags & SD_SHARE_PKG_RESOURCES)) {
-				struct sched_domain *top, *top_p;
+				struct sched_domain __rcu *top_p;
 				unsigned int nr_llcs;
 
 				/*
@@ -2316,11 +2316,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 				sd->imb_numa_nr = imb;
 
 				/* Set span based on the first NUMA domain. */
-				top = sd;
-				top_p = top->parent;
+				top_p = sd->parent;
 				while (top_p && !(top_p->flags & SD_NUMA)) {
-					top = top->parent;
-					top_p = top->parent;
+					top_p = top_p->parent;
 				}
 				imb_span = top_p ? top_p->span_weight : sd->span_weight;
 			} else {

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

end of thread, other threads:[~2022-03-08 22:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18 16:27 [PATCH] sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains K Prateek Nayak
2022-03-04  3:48 ` K Prateek Nayak
2022-03-04 12:56 ` Valentin Schneider
2022-03-04 13:49   ` Peter Zijlstra
2022-03-08 22:25 ` [tip: sched/core] " tip-bot2 for K Prateek Nayak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox