From patchwork Fri Apr 28 11:01:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 98328 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp204080qgf; Fri, 28 Apr 2017 04:02:17 -0700 (PDT) X-Received: by 10.98.159.29 with SMTP id g29mr11315124pfe.189.1493377337655; Fri, 28 Apr 2017 04:02:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o16si5779080pfa.236.2017.04.28.04.02.17; Fri, 28 Apr 2017 04:02:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035777AbdD1LB6 (ORCPT + 25 others); Fri, 28 Apr 2017 07:01:58 -0400 Received: from foss.arm.com ([217.140.101.70]:47420 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164836AbdD1LBk (ORCPT ); Fri, 28 Apr 2017 07:01:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F48115BE; Fri, 28 Apr 2017 04:01:40 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 66EF33F220; Fri, 28 Apr 2017 04:01:38 -0700 (PDT) From: Mark Rutland To: tglx@linutronix.de Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will.deacon@arm.com, catalin.marinas@arm.com, bigeasy@linutronix.de, jbaron@akamai.com, mark.rutland@arm.com, peterz@infradead.org, rostedt@goodmis.org, suzuki.poulose@arm.com Subject: [PATCHv3 1/2] jump_label: Provide static_key_[enable|/slow_inc]_cpuslocked() Date: Fri, 28 Apr 2017 12:01:05 +0100 Message-Id: <1493377266-2205-2-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493377266-2205-1-git-send-email-mark.rutland@arm.com> References: <1493377266-2205-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior Provide static_key_[enable|slow_inc]_cpuslocked() variant that don't take cpu_hotplug_lock(). Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Mark Rutland Cc: Peter Zijlstra Cc: Sebastian Siewior Cc: Steven Rostedt Cc: jbaron@akamai.com --- include/linux/jump_label.h | 7 +++++++ kernel/jump_label.c | 10 ++++++++++ 2 files changed, 17 insertions(+) -- 1.9.1 diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index d7b17d1..c80d8b1 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -164,6 +164,7 @@ extern void arch_jump_label_transform_static(struct jump_entry *entry, extern void jump_label_apply_nops(struct module *mod); extern int static_key_count(struct static_key *key); extern void static_key_enable(struct static_key *key); +extern void static_key_enable_cpuslocked(struct static_key *key); extern void static_key_disable(struct static_key *key); extern void static_key_disable_cpuslocked(struct static_key *key); @@ -252,6 +253,11 @@ static inline void static_key_enable(struct static_key *key) static_key_slow_inc(key); } +static inline void static_key_enable_cpuslocked(struct static_key *key) +{ + static_key_enable(key); +} + static inline void static_key_disable(struct static_key *key) { int count = static_key_count(key); @@ -429,6 +435,7 @@ struct static_key_false { */ #define static_branch_enable(x) static_key_enable(&(x)->key) +#define static_branch_enable_cpuslocked(x) static_key_enable_cpuslocked(&(x)->key) #define static_branch_disable(x) static_key_disable(&(x)->key) #define static_branch_disable_cpuslocked(x) static_key_disable_cpuslocked(&(x)->key) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index d71124e..6343f4c 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -90,6 +90,16 @@ void static_key_enable(struct static_key *key) } EXPORT_SYMBOL_GPL(static_key_enable); +void static_key_enable_cpuslocked(struct static_key *key) +{ + int count = static_key_count(key); + + WARN_ON_ONCE(count < 0 || count > 1); + + if (!count) + static_key_slow_inc_cpuslocked(key); +} + void static_key_disable(struct static_key *key) { int count = static_key_count(key);