From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754327AbdEQQFi (ORCPT ); Wed, 17 May 2017 12:05:38 -0400 Received: from foss.arm.com ([217.140.101.70]:49736 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969AbdEQQFg (ORCPT ); Wed, 17 May 2017 12:05:36 -0400 Date: Wed, 17 May 2017 17:05:31 +0100 From: Catalin Marinas To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com, marc.zyngier@arm.com, bigeasy@linutronix.de, will.deacon@arm.com, linux-kernel@vger.kernel.org, peterz@infradead.org, tglx@linutronix.de, Christoffer Dall Subject: Re: [PATCHv5] arm64/cpufeature: don't use mutex in bringup path Message-ID: <20170517160530.GB18716@e104818-lin.cambridge.arm.com> References: <1494944285-12152-1-git-send-email-mark.rutland@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1494944285-12152-1-git-send-email-mark.rutland@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 16, 2017 at 03:18:05PM +0100, Mark Rutland wrote: > Currently, cpus_set_cap() calls static_branch_enable_cpuslocked(), which > must take the jump_label mutex. > > We call cpus_set_cap() in the secondary bringup path, from the idle > thread where interrupts are disabled. Taking a mutex in this path "is a > NONO" regardless of whether it's contended, and something we must avoid. > We didn't spot this until recently, as ___might_sleep() won't warn for > this case until all CPUs have been brought up. > > This patch avoids taking the mutex in the secondary bringup path. The > poking of static keys is deferred until enable_cpu_capabilities(), which > runs in a suitable context on the boot CPU. To account for the static > keys being set later, cpus_have_const_cap() is updated to use another > static key to check whether the const cap keys have been initialised, > falling back to the caps bitmap until this is the case. > > This means that users of cpus_have_const_cap() gain should only gain a > single additional NOP in the fast path once the const caps are > initialised, but should always see the current cap value. > > The hyp code should never dereference the caps array, since the caps are > initialized before we run the module initcall to initialise hyp. A check > is added to the hyp init code to document this requirement. > > This change will sidestep a number of issues when the upcoming hotplug > locking rework is merged. > > Signed-off-by: Mark Rutland > Reviewed-by: Marc Zyniger > Reviewed-by: Suzuki Poulose > Acked-by: Will Deacon > Cc: Catalin Marinas > Cc: Christoffer Dall > Cc: Peter Zijlstra > Cc: Sebastian Sewior > Cc: Thomas Gleixner > --- > arch/arm64/include/asm/cpufeature.h | 12 ++++++++++-- > arch/arm64/include/asm/kvm_host.h | 8 ++++++-- > arch/arm64/kernel/cpufeature.c | 23 +++++++++++++++++++++-- > 3 files changed, 37 insertions(+), 6 deletions(-) > > Catalin, can you take this as a fix for v4.12? I queued it for 4.12-rc2. Thanks. -- Catalin