mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sander Vanheule <sander@svanheule.net>
To: Yury Norov <yury.norov@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Valentin Schneider <vschneid@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Marco Elver <elver@google.com>,
	linux-kernel@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH v3 1/4] cpumask: Fix invalid uniprocessor mask assumption
Date: Tue, 07 Jun 2022 14:06:38 +0200	[thread overview]
Message-ID: <541d89b3aa2092382405672b70b58b5b3d263f1e.camel@svanheule.net> (raw)
In-Reply-To: <Yp5SJAkq8whC8EBI@yury-laptop>

On Mon, 2022-06-06 at 12:14 -0700, Yury Norov wrote:
> On Sun, Jun 05, 2022 at 08:22:38AM +0200, Sander Vanheule wrote:
> > On uniprocessor builds, any CPU mask is assumed to contain exactly one
> > CPU (cpu0). This assumption ignores the existence of empty masks,
> > resulting in incorrect behaviour.
> > cpumask_first_zero(), cpumask_next_zero(), and for_each_cpu_not() don't
> > provide behaviour matching the assumption that a UP mask is always "1",
> > and instead provide behaviour matching the empty mask.
> > 
> > Drop the incorrectly optimised code and use the generic implementations
> > in all cases.
> > 
> > Signed-off-by: Sander Vanheule <sander@svanheule.net>
> > ---

[...]

> > -static inline unsigned int cpumask_local_spread(unsigned int i, int node)
> > -{
> > -       return 0;
> > -}
> > -
> > -static inline int cpumask_any_and_distribute(const struct cpumask *src1p,
> > -                                            const struct cpumask *src2p) {
> > -       return cpumask_first_and(src1p, src2p);
> > -}
> > -
> > -static inline int cpumask_any_distribute(const struct cpumask *srcp)
> > -{
> > -       return cpumask_first(srcp);
> > -}
> 
> It looks like cpumask_local_spread, cpumask_any_and_distribute and
> cpumask_any_distribute were correct and better optimized in UP case.
> cpumask_local_spread - for sure. I think it's worth keeping them
> optimized.

Yes, these were correct and we can keep them. I will have to add an #ifded CONFIG_SMP (or #if
NR_CPUS > 1) guard in lib/cpumask.c around these functions, so they don't collide with the inlined
UP versions.

Best,
Sander

  reply	other threads:[~2022-06-07 12:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-05  6:22 [PATCH v3 0/4] cpumask: Fix invalid uniprocessor assumptions Sander Vanheule
2022-06-05  6:22 ` [PATCH v3 1/4] cpumask: Fix invalid uniprocessor mask assumption Sander Vanheule
2022-06-06  0:48   ` kernel test robot
2022-06-06 10:40     ` Andy Shevchenko
2022-06-08 17:59       ` Sander Vanheule
2022-06-06 19:14   ` Yury Norov
2022-06-07 12:06     ` Sander Vanheule [this message]
2022-06-05  6:22 ` [PATCH v3 2/4] lib/test: Introduce cpumask KUnit test suite Sander Vanheule
2022-06-05  6:31   ` Sander Vanheule
2022-06-06 10:36   ` Andy Shevchenko
2022-06-06 12:22     ` Sander Vanheule
2022-06-05  6:22 ` [PATCH v3 3/4] cpumask: Add UP optimised for_each_*_cpu versions Sander Vanheule
2022-06-05  6:22 ` [PATCH v3 4/4] cpumask: Update cpumask_next_wrap() signature Sander Vanheule
2022-06-06 10:37   ` Andy Shevchenko

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=541d89b3aa2092382405672b70b58b5b3d263f1e.camel@svanheule.net \
    --to=sander@svanheule.net \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=elver@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vschneid@redhat.com \
    --cc=yury.norov@gmail.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®