Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753149AbbB0MLV (ORCPT ); Fri, 27 Feb 2015 07:11:21 -0500 Received: from ozlabs.org ([103.22.144.67]:54165 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752386AbbB0MLS (ORCPT ); Fri, 27 Feb 2015 07:11:18 -0500 From: Rusty Russell To: green@linuxhacker.ru, Andrew Morton , "David S. Miller" Cc: linux-kernel@vger.kernel.org, Oleg Drokin Subject: Re: [PATCH 0/2] incorrect cpumask behavior with CPUMASK_OFFSTACK In-Reply-To: <1424931551-11757-1-git-send-email-green@linuxhacker.ru> References: <1424931551-11757-1-git-send-email-green@linuxhacker.ru> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Fri, 27 Feb 2015 22:16:01 +1030 Message-ID: <87pp8vlgqu.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2138 Lines: 61 green@linuxhacker.ru writes: > From: Oleg Drokin > > I just got a report today from Tyson Whitehead > 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 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/