mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sander Vanheule <sander@svanheule.net>
To: Saurabh Sengar <ssengar@linux.microsoft.com>,
	ssengar@microsoft.com, mikelley@microsoft.com,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] issue with cpumask for UniProcessor
Date: Mon, 08 Aug 2022 19:34:53 +0200	[thread overview]
Message-ID: <e5e85517a918b67ca8315a88ae9a8c1c6ce4da0f.camel@svanheule.net> (raw)
In-Reply-To: <1659975821-30762-1-git-send-email-ssengar@linux.microsoft.com>

Hi Saurabh,

On Mon, 2022-08-08 at 09:23 -0700, Saurabh Sengar wrote:
> 
> Hi,
> 
> I am working on a UniProcessor system with latest linux-next kernel
> (20220803).
> I observed two files "shared_cpu_map” and “shared_cpu_list” are missing
> for L3 cache (/sys/devices/system/cpu/cpu0/cache/index3). This causes lscpu
> version 2.34 to segfault. On further digging I figured below is the commit
> which introduced this problem.
> 
> https://lore.kernel.org/lkml/e78c55ecb98172356248a7a89da501479ead6ae0.1659077534.git.sander@svanheule.net/
> 

This is the v5 of the patch, which sadly isn't the version that got merged. The
commit that's triggering your issue is b81dce77cedc ("cpumask: Fix invalid
uniprocessor mask assumption"), which is patch v4.

https://lore.kernel.org/lkml/86bf3f005abba2d92120ddd0809235cab4f759a6.1656777646.git.sander@svanheule.net/

> 
> I am not 100% certain what the proper fix for it is, but below changes fix
> this issue. I understand above patch is already confirmed for linux kernel
> 6.0, please suggest if we need fixing this in 6.0.
> 
> Regards,
> Saurabh
> 
> 
> 
> diff --git a/lib/cpumask.c b/lib/cpumask.c
> index b9728513a4d4..81fc2e35b5b1 100644
> --- a/lib/cpumask.c
> +++ b/lib/cpumask.c
> @@ -16,10 +16,14 @@
>   */
>  unsigned int cpumask_next(int n, const struct cpumask *srcp)
>  {
> +#if NR_CPUS == 1
> +       return n+1;
> +#else

This is ignoring the provided cpumask again, which was exactly what my patch
fixed. If the mask is empty, then cpumask_next(-1, mask) should return (at
least) 1, not 0.

I think the problem could be caused by cpumask_next() getting an empty mask.
Then the real issue is would be that a certain mask is empty when it shouldn't
be, which was compensated by the old code's built-in assumption that a cpumask
couldn't be empty.

My MIPS testing system doesn't have these L3 maps, and "shared_cpu_map" and
"shared_cpu_list" are present for index0 and index1. I would propose that you
look for the point where the files should be created, and check how
cpumask_next() is involved, to find the actual cause of this problem.

Best,
Sander

>         /* -1 is a legal arg here. */
>         if (n != -1)
>                 cpumask_check(n);
>         return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
> +#endif
>  }
>  EXPORT_SYMBOL(cpumask_next);


  reply	other threads:[~2022-08-08 17:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  7:01 [PATCH v5 0/5] cpumask: fix invalid uniprocessor assumptions Sander Vanheule
2022-07-29  7:01 ` [PATCH v5 1/5] x86/cacheinfo: move shared cache map definitions Sander Vanheule
2022-08-02 11:13   ` Ingo Molnar
2022-07-29  7:01 ` [PATCH v5 2/5] cpumask: add UP optimised for_each_*_cpu versions Sander Vanheule
2022-07-29  7:01 ` [PATCH v5 3/5] cpumask: fix invalid uniprocessor mask assumption Sander Vanheule
2022-08-08 16:23   ` [RFC] issue with cpumask for UniProcessor Saurabh Sengar
2022-08-08 17:34     ` Sander Vanheule [this message]
2022-07-29  7:01 ` [PATCH v5 4/5] lib/test: introduce cpumask KUnit test suite Sander Vanheule
2022-07-31 15:23   ` Maíra Canal
2022-07-31 15:42     ` Sander Vanheule
2022-07-31 22:11       ` Maíra Canal
2022-08-09 18:38     ` Sander Vanheule
2022-07-29  7:01 ` [PATCH v5 5/5] cpumask: update cpumask_next_wrap() signature Sander Vanheule
2022-07-30 18:15 ` [PATCH v5 0/5] cpumask: fix invalid uniprocessor assumptions Yury Norov
2022-07-31 13:02   ` Sander Vanheule
2022-07-31 15:28     ` Yury Norov

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=e5e85517a918b67ca8315a88ae9a8c1c6ce4da0f.camel@svanheule.net \
    --to=sander@svanheule.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=ssengar@linux.microsoft.com \
    --cc=ssengar@microsoft.com \
    /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®