Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700715 > unrolled thread

[PATCH v2 1/4] jump_label: Move cpu hotplug locking

Started byMarc Zyngier <marc.zyngier@arm.com>
First post2017-08-01 10:10 +0200
Last post2017-08-10 14:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 1/4] jump_label: Move cpu hotplug locking Marc Zyngier <marc.zyngier@arm.com> - 2017-08-01 10:10 +0200
    [tip:locking/core] jump_label: Move CPU hotplug locking tip-bot for Marc Zyngier <tipbot@zytor.com> - 2017-08-10 14:20 +0200

#1700715 — [PATCH v2 1/4] jump_label: Move cpu hotplug locking

FromMarc Zyngier <marc.zyngier@arm.com>
Date2017-08-01 10:10 +0200
Subject[PATCH v2 1/4] jump_label: Move cpu hotplug locking
Message-ID<u9Apz-HZ-1@gated-at.bofh.it>
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>
---
 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 d11c506a6ac3..f11b10091100 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -105,6 +105,7 @@ void static_key_slow_inc(struct static_key *key)
 {
 	int v, v1;
 
+	cpus_read_lock();
 	STATIC_KEY_CHECK_USE();
 
 	/*
@@ -121,11 +122,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);
-- 
2.11.0

[toc] | [next] | [standalone]


#1708505 — [tip:locking/core] jump_label: Move CPU hotplug locking

Fromtip-bot for Marc Zyngier <tipbot@zytor.com>
Date2017-08-10 14:20 +0200
Subject[tip:locking/core] jump_label: Move CPU hotplug locking
Message-ID<ucUBs-5tj-5@gated-at.bofh.it>
In reply to#1700715
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);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web