Re: [PATCH] s390/cpuinfo: prevent warning when reading /proc/cpuinfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 14, 2022 at 08:06:41AM -0700, Yury Norov wrote:
> On Fri, Oct 14, 2022 at 7:26 AM Alexander Gordeev
> <agordeev@xxxxxxxxxxxxx> wrote:
> >
> > Commit 78e5a3399421 ("cpumask: fix checking valid cpu range") has
> > started issuing warnings when reading /proc/cpuinfo and config
> > DEBUG_PER_CPU_MAPS is enabled. Avoid calling cpumask_next() with
> > the cpu index equal to nr_cpu_ids - 1 and ensure no warning is
> > generated.
> >
> > Link: https://lore.kernel.org/r/20221012081905.1800640-1-ajones@xxxxxxxxxxxxxxxx
> > Reported-by: Andrew Jones <ajones@xxxxxxxxxxxxxxxx>
> > Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
> > ---
> >  arch/s390/kernel/processor.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
> > index a194611ba88c..908a0be900ea 100644
> > --- a/arch/s390/kernel/processor.c
> > +++ b/arch/s390/kernel/processor.c
> > @@ -334,6 +334,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
> >
> >  static inline void *c_update(loff_t *pos)
> >  {
> > +       if (*pos >= nr_cpu_ids)
> > +               return NULL;
> >         if (*pos)
> >                 *pos = cpumask_next(*pos - 1, cpu_online_mask);
> >         else
> 
> This silences the warning entirely. If you don't need it, I'd suggest
> using find_next_bit()
> instead. But from the discussion to similar patch, I think you need to
> allow nr_cpu_ids
> only:
>  +       if (*pos == nr_cpu_ids)
>  +               return NULL;

Yes, and I'll post my v3's with this change for x86 and riscv now.

Thanks,
drew



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux