public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: green@linuxhacker.ru, Andrew Morton <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, Oleg Drokin <green@linuxhacker.ru>
Subject: Re: [PATCH 0/2] incorrect cpumask behavior with CPUMASK_OFFSTACK
Date: Fri, 27 Feb 2015 22:16:01 +1030	[thread overview]
Message-ID: <87pp8vlgqu.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1424931551-11757-1-git-send-email-green@linuxhacker.ru>

green@linuxhacker.ru writes:
> From: Oleg Drokin <green@linuxhacker.ru>
>
> I just got a report today from Tyson Whitehead <twhitehead@gmail.com>
> that Lustre crashes when CPUMASK_OFFSTACK is enabled.
>
> A little investigation revealed that this code:
>         cpumask_t                       mask;
> ...
>         cpumask_copy(&mask, topology_thread_cpumask(0));
>         weight = cpus_weight(mask);

Yes.  cpumask_weight should have been used here.  The old cpus_* are
deprecated.

> The second patch that I am not sure if we wnat, but it seems to be useful
> until struct cpumask is fully dynamic is to convert what looks like
> whole-set operations e.g. copies, namely:
> cpumask_setall, cpumask_clear, cpumask_copy to always operate on NR_CPUS
> bits to ensure there's no stale garbage left in the mask should the
> cpu count increases later.

You can't do this, because dynamically allocated cpumasks don't have
NR_CPUS bits.

Let's just kill all the cpus_ functions.  This wasn't done originally
because archs which didn't care about offline cpumasks didn't want the
churn.  In particular, they must not copy struct cpumask by assignment,
and fixing those is a fair bit of churn.

The following is the minimal fix:

Cheers,
Rusty.

CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS: set if CPUMASK_OFFSTACK.

Using these functions with offstack cpus is unsafe.  They use all NR_CPUS
bits, unstead of nr_cpumask_bits.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/lib/Kconfig b/lib/Kconfig
index 87da53bb1fef..51b4210f3da9 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -398,8 +398,7 @@ config CPUMASK_OFFSTACK
 	  stack overflow.
 
 config DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
-       bool "Disable obsolete cpumask functions" if DEBUG_PER_CPU_MAPS
-       depends on BROKEN
+       bool "Disable obsolete cpumask functions" if CPUMASK_OFFSTACK
 
 config CPU_RMAP
 	bool

  parent reply	other threads:[~2015-02-27 12:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26  6:19 [PATCH 0/2] incorrect cpumask behavior with CPUMASK_OFFSTACK green
2015-02-26  6:19 ` [PATCH 1/2] cpumask: Properly calculate cpumask values green
2015-02-26  6:19 ` [PATCH 2/2] cpumask: make whole cpumask operations like copy to work with NR_CPUS bits green
2015-02-27 11:46 ` Rusty Russell [this message]
2015-02-27 17:51   ` [PATCH 0/2] incorrect cpumask behavior with CPUMASK_OFFSTACK Oleg Drokin
2015-03-02 11:28     ` Rusty Russell

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=87pp8vlgqu.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=green@linuxhacker.ru \
    --cc=linux-kernel@vger.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