mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Marc Zyngier <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de,
	marc.zyngier@arm.com, torvalds@linux-foundation.org,
	mingo@kernel.org, peterz@infradead.org, leo.yan@linaro.org
Subject: [tip:locking/core] jump_label: Move CPU hotplug locking
Date: Thu, 10 Aug 2017 05:14:01 -0700	[thread overview]
Message-ID: <tip-b70cecf4b6b72a9977576ab32cca0e24f286f517@git.kernel.org> (raw)
In-Reply-To: <20170801080257.5056-2-marc.zyngier@arm.com>

Commit-ID:  b70cecf4b6b72a9977576ab32cca0e24f286f517
Gitweb:     http://git.kernel.org/tip/b70cecf4b6b72a9977576ab32cca0e24f286f517
Author:     Marc Zyngier <marc.zyngier@arm.com>
AuthorDate: Tue, 1 Aug 2017 09:02:54 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 10 Aug 2017 12:28:58 +0200

jump_label: Move CPU hotplug locking

As we're about to rework the locking, let's move the taking and
release of the CPU hotplug lock to locations that will make its
reworking completely obvious.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20170801080257.5056-2-marc.zyngier@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/jump_label.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index f2ea678..161301f 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -83,6 +83,7 @@ void static_key_slow_inc(struct static_key *key)
 {
 	int v, v1;
 
+	cpus_read_lock();
 	STATIC_KEY_CHECK_USE();
 
 	/*
@@ -99,11 +100,12 @@ void static_key_slow_inc(struct static_key *key)
 	 */
 	for (v = atomic_read(&key->enabled); v > 0; v = v1) {
 		v1 = atomic_cmpxchg(&key->enabled, v, v + 1);
-		if (likely(v1 == v))
+		if (likely(v1 == v)) {
+			cpus_read_unlock();
 			return;
+		}
 	}
 
-	cpus_read_lock();
 	jump_label_lock();
 	if (atomic_read(&key->enabled) == 0) {
 		atomic_set(&key->enabled, -1);

  reply	other threads:[~2017-08-10 12:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01  8:02 [PATCH v2 0/4] Working around CPU hotplug and static keys locking Marc Zyngier
2017-08-01  8:02 ` [PATCH v2 1/4] jump_label: Move cpu hotplug locking Marc Zyngier
2017-08-10 12:14   ` tip-bot for Marc Zyngier [this message]
2017-08-01  8:02 ` [PATCH v2 2/4] jump_label: Split out code under the hotplug lock Marc Zyngier
2017-08-10 12:14   ` [tip:locking/core] " tip-bot for Marc Zyngier
2017-08-01  8:02 ` [PATCH v2 3/4] jump_label: Provide hotplug context variants Marc Zyngier
2017-08-02 14:37   ` Peter Zijlstra
2017-08-02 15:02     ` Marc Zyngier
2017-08-10 12:14   ` [tip:locking/core] " tip-bot for Marc Zyngier
2017-08-01  8:02 ` [PATCH v2 4/4] clocksource/arm_arch_timer: Use static_branch_enable_cpuslocked() Marc Zyngier
2017-08-10 12:15   ` [tip:locking/core] " tip-bot for Marc Zyngier

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=tip-b70cecf4b6b72a9977576ab32cca0e24f286f517@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®