mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yujie Liu <yujie.liu@intel.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: kernel test robot <lkp@intel.com>,
	<oe-kbuild-all@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<x86@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Qais Yousef <qyousef@layalina.io>,
	Lukasz Luba <lukasz.luba@arm.com>
Subject: Re: [tip:sched/core 26/27] drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces)
Date: Thu, 25 Apr 2024 18:50:40 +0800	[thread overview]
Message-ID: <Zio1gGgpl0FJ4qPg@yujie-X299> (raw)
In-Reply-To: <CAKfTPtBmhCFWmeb7oaM3t3WMb0_RUwY32gzgVzyruYaP9VpfUA@mail.gmail.com>

Hi Vincent,

On Thu, Apr 25, 2024 at 08:36:31AM +0200, Vincent Guittot wrote:
> Hi,
> 
> On Thu, 25 Apr 2024 at 01:22, kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Vincent,
> >
> > FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core
> > head:   97450eb909658573dcacc1063b06d3d08642c0c1
> > commit: d4dbc991714eefcbd8d54a3204bd77a0a52bd32d [26/27] sched/cpufreq: Rename arch_update_thermal_pressure() => arch_update_hw_pressure()
> 
> I'm going to look at this more deeply but this patch only rename
> "thermal_pressure" by "hw_pressure" so unless I miss a renaming, this
> should not trigger anything new.

Before renaming, there is a global "thermal_pressure", and a local
"th_pressure" inside topology_update_thermal_pressure function. They
live together peacefully since they have different names.

DEFINE_PER_CPU(unsigned long, thermal_pressure);
                              ^____

void topology_update_thermal_pressure(const struct cpumask *cpus,
                                      unsigned long capped_freq)
{
        unsigned long max_capacity, capacity, th_pressure;
                                              ^____
...
        for_each_cpu(cpu, cpus)
                WRITE_ONCE(per_cpu(thermal_pressure, cpu), th_pressure);
                                   ^____                   ^____
}

After renaming, the global and local variables are both given the same
name "hw_pressure", so the local one shadows the global one, causing
this sparse warning.

DEFINE_PER_CPU(unsigned long, hw_pressure);
                              ^___

void topology_update_hw_pressure(const struct cpumask *cpus,
                                      unsigned long capped_freq)
{
        unsigned long max_capacity, capacity, hw_pressure;
                                              ^___
...
        for_each_cpu(cpu, cpus)
                WRITE_ONCE(per_cpu(hw_pressure, cpu), hw_pressure);
                                   ^____              ^____
}


We can give them different names as before to fix this warning:

---------------------------------------------------------------

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 0248912ff6875..c66d070207a0e 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -179,7 +179,7 @@ DEFINE_PER_CPU(unsigned long, hw_pressure);
 void topology_update_hw_pressure(const struct cpumask *cpus,
                                      unsigned long capped_freq)
 {
-       unsigned long max_capacity, capacity, hw_pressure;
+       unsigned long max_capacity, capacity, pressure;
        u32 max_freq;
        int cpu;

@@ -196,12 +196,12 @@ void topology_update_hw_pressure(const struct cpumask *cpus,
        else
                capacity = mult_frac(max_capacity, capped_freq, max_freq);

-       hw_pressure = max_capacity - capacity;
+       pressure = max_capacity - capacity;

-       trace_hw_pressure_update(cpu, hw_pressure);
+       trace_hw_pressure_update(cpu, pressure);

        for_each_cpu(cpu, cpus)
-               WRITE_ONCE(per_cpu(hw_pressure, cpu), hw_pressure);
+               WRITE_ONCE(per_cpu(hw_pressure, cpu), pressure);
 }
 EXPORT_SYMBOL_GPL(topology_update_hw_pressure);

--

Thanks,
Yujie

> > config: arm64-randconfig-r132-20240425 (https://download.01.org/0day-ci/archive/20240425/202404250740.VhQQoD7N-lkp@intel.com/config)
> > compiler: aarch64-linux-gcc (GCC) 13.2.0
> > reproduce: (https://download.01.org/0day-ci/archive/20240425/202404250740.VhQQoD7N-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202404250740.VhQQoD7N-lkp@intel.com/
> >
> > sparse warnings: (new ones prefixed by >>)
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> > >> drivers/base/arch_topology.c:204:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
> >    drivers/base/arch_topology.c:204:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    drivers/base/arch_topology.c:204:17: sparse:     got unsigned long *
> >
> > vim +204 drivers/base/arch_topology.c
> >
> >    164
> >    165  /**
> >    166   * topology_update_hw_pressure() - Update HW pressure for CPUs
> >    167   * @cpus        : The related CPUs for which capacity has been reduced
> >    168   * @capped_freq : The maximum allowed frequency that CPUs can run at
> >    169   *
> >    170   * Update the value of HW pressure for all @cpus in the mask. The
> >    171   * cpumask should include all (online+offline) affected CPUs, to avoid
> >    172   * operating on stale data when hot-plug is used for some CPUs. The
> >    173   * @capped_freq reflects the currently allowed max CPUs frequency due to
> >    174   * HW capping. It might be also a boost frequency value, which is bigger
> >    175   * than the internal 'capacity_freq_ref' max frequency. In such case the
> >    176   * pressure value should simply be removed, since this is an indication that
> >    177   * there is no HW throttling. The @capped_freq must be provided in kHz.
> >    178   */
> >    179  void topology_update_hw_pressure(const struct cpumask *cpus,
> >    180                                        unsigned long capped_freq)
> >    181  {
> >    182          unsigned long max_capacity, capacity, hw_pressure;
> >    183          u32 max_freq;
> >    184          int cpu;
> >    185
> >    186          cpu = cpumask_first(cpus);
> >    187          max_capacity = arch_scale_cpu_capacity(cpu);
> >    188          max_freq = arch_scale_freq_ref(cpu);
> >    189
> >    190          /*
> >    191           * Handle properly the boost frequencies, which should simply clean
> >    192           * the HW pressure value.
> >    193           */
> >    194          if (max_freq <= capped_freq)
> >    195                  capacity = max_capacity;
> >    196          else
> >    197                  capacity = mult_frac(max_capacity, capped_freq, max_freq);
> >    198
> >    199          hw_pressure = max_capacity - capacity;
> >    200
> >    201          trace_hw_pressure_update(cpu, hw_pressure);
> >    202
> >    203          for_each_cpu(cpu, cpus)
> >  > 204                  WRITE_ONCE(per_cpu(hw_pressure, cpu), hw_pressure);
> >    205  }
> >    206  EXPORT_SYMBOL_GPL(topology_update_hw_pressure);
> >    207
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
> 

  reply	other threads:[~2024-04-25 10:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 23:22 kernel test robot
2024-04-25  6:36 ` Vincent Guittot
2024-04-25 10:50   ` Yujie Liu [this message]
2024-04-25 11:13     ` Vincent Guittot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zio1gGgpl0FJ4qPg@yujie-X299 \
    --to=yujie.liu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lukasz.luba@arm.com \
    --cc=mingo@kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=qyousef@layalina.io \
    --cc=vincent.guittot@linaro.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®