public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390/cpuinfo: prevent warning when reading /proc/cpuinfo
@ 2022-10-14 14:26 Alexander Gordeev
  2022-10-14 15:06 ` Yury Norov
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Gordeev @ 2022-10-14 14:26 UTC (permalink / raw)
  To: linux-s390; +Cc: Yury Norov, Andrew Jones

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@ventanamicro.com
Reported-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
 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
-- 
2.34.1


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

* Re: [PATCH] s390/cpuinfo: prevent warning when reading /proc/cpuinfo
  2022-10-14 14:26 [PATCH] s390/cpuinfo: prevent warning when reading /proc/cpuinfo Alexander Gordeev
@ 2022-10-14 15:06 ` Yury Norov
  2022-10-14 15:36   ` Andrew Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Yury Norov @ 2022-10-14 15:06 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: linux-s390, Andrew Jones

On Fri, Oct 14, 2022 at 7:26 AM Alexander Gordeev
<agordeev@linux.ibm.com> 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@ventanamicro.com
> Reported-by: Andrew Jones <ajones@ventanamicro.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
>  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;

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

* Re: [PATCH] s390/cpuinfo: prevent warning when reading /proc/cpuinfo
  2022-10-14 15:06 ` Yury Norov
@ 2022-10-14 15:36   ` Andrew Jones
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2022-10-14 15:36 UTC (permalink / raw)
  To: Yury Norov; +Cc: Alexander Gordeev, linux-s390

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@linux.ibm.com> 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@ventanamicro.com
> > Reported-by: Andrew Jones <ajones@ventanamicro.com>
> > Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> > ---
> >  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

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

end of thread, other threads:[~2022-10-14 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-14 14:26 [PATCH] s390/cpuinfo: prevent warning when reading /proc/cpuinfo Alexander Gordeev
2022-10-14 15:06 ` Yury Norov
2022-10-14 15:36   ` Andrew Jones

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