From: Rusty Russell <rusty@rustcorp.com.au>
To: Andi Kleen <ak@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@kernel.dk>,
linux-kernel <linux-kernel@vger.kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
"Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/3] lglock: remove online variants of lock
Date: Mon, 05 Mar 2012 17:33:41 +1030 [thread overview]
Message-ID: <87obsbzfzm.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20120228112422.GC11324@alboin.amr.corp.intel.com>
Optimizing the slow paths adds a lot of complexity. If you need to
grab every lock often, you have other problems.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
include/linux/lglock.h | 58 +------------------------------------------------
1 file changed, 2 insertions(+), 56 deletions(-)
diff --git a/include/linux/lglock.h b/include/linux/lglock.h
--- a/include/linux/lglock.h
+++ b/include/linux/lglock.h
@@ -28,8 +28,8 @@
#define br_lock_init(name) name##_lock_init()
#define br_read_lock(name) name##_local_lock()
#define br_read_unlock(name) name##_local_unlock()
-#define br_write_lock(name) name##_global_lock_online()
-#define br_write_unlock(name) name##_global_unlock_online()
+#define br_write_lock(name) name##_global_lock()
+#define br_write_unlock(name) name##_global_unlock()
#define DECLARE_BRLOCK(name) DECLARE_LGLOCK(name)
#define DEFINE_BRLOCK(name) DEFINE_LGLOCK(name)
@@ -42,8 +42,6 @@
#define lg_local_unlock_cpu(name, cpu) name##_local_unlock_cpu(cpu)
#define lg_global_lock(name) name##_global_lock()
#define lg_global_unlock(name) name##_global_unlock()
-#define lg_global_lock_online(name) name##_global_lock_online()
-#define lg_global_unlock_online(name) name##_global_unlock_online()
#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define LOCKDEP_INIT_MAP lockdep_init_map
@@ -68,36 +66,13 @@
extern void name##_local_unlock_cpu(int cpu); \
extern void name##_global_lock(void); \
extern void name##_global_unlock(void); \
- extern void name##_global_lock_online(void); \
- extern void name##_global_unlock_online(void); \
#define DEFINE_LGLOCK(name) \
\
DEFINE_SPINLOCK(name##_cpu_lock); \
- cpumask_t name##_cpus __read_mostly; \
DEFINE_PER_CPU(arch_spinlock_t, name##_lock); \
DEFINE_LGLOCK_LOCKDEP(name); \
\
- static int \
- name##_lg_cpu_callback(struct notifier_block *nb, \
- unsigned long action, void *hcpu) \
- { \
- switch (action & ~CPU_TASKS_FROZEN) { \
- case CPU_UP_PREPARE: \
- spin_lock(&name##_cpu_lock); \
- cpu_set((unsigned long)hcpu, name##_cpus); \
- spin_unlock(&name##_cpu_lock); \
- break; \
- case CPU_UP_CANCELED: case CPU_DEAD: \
- spin_lock(&name##_cpu_lock); \
- cpu_clear((unsigned long)hcpu, name##_cpus); \
- spin_unlock(&name##_cpu_lock); \
- } \
- return NOTIFY_OK; \
- } \
- static struct notifier_block name##_lg_cpu_notifier = { \
- .notifier_call = name##_lg_cpu_callback, \
- }; \
void name##_lock_init(void) { \
int i; \
LOCKDEP_INIT_MAP(&name##_lock_dep_map, #name, &name##_lock_key, 0); \
@@ -106,11 +81,6 @@
lock = &per_cpu(name##_lock, i); \
*lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; \
} \
- register_hotcpu_notifier(&name##_lg_cpu_notifier); \
- get_online_cpus(); \
- for_each_online_cpu(i) \
- cpu_set(i, name##_cpus); \
- put_online_cpus(); \
} \
EXPORT_SYMBOL(name##_lock_init); \
\
@@ -150,30 +120,6 @@
} \
EXPORT_SYMBOL(name##_local_unlock_cpu); \
\
- void name##_global_lock_online(void) { \
- int i; \
- spin_lock(&name##_cpu_lock); \
- rwlock_acquire(&name##_lock_dep_map, 0, 0, _RET_IP_); \
- for_each_cpu(i, &name##_cpus) { \
- arch_spinlock_t *lock; \
- lock = &per_cpu(name##_lock, i); \
- arch_spin_lock(lock); \
- } \
- } \
- EXPORT_SYMBOL(name##_global_lock_online); \
- \
- void name##_global_unlock_online(void) { \
- int i; \
- rwlock_release(&name##_lock_dep_map, 1, _RET_IP_); \
- for_each_cpu(i, &name##_cpus) { \
- arch_spinlock_t *lock; \
- lock = &per_cpu(name##_lock, i); \
- arch_spin_unlock(lock); \
- } \
- spin_unlock(&name##_cpu_lock); \
- } \
- EXPORT_SYMBOL(name##_global_unlock_online); \
- \
void name##_global_lock(void) { \
int i; \
preempt_disable(); \
next prev parent reply other threads:[~2012-03-05 7:08 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-27 23:22 [PATCH] cpumask: fix lg_lock/br_lock Rusty Russell
2012-02-27 23:53 ` Andrew Morton
2012-02-28 8:43 ` Ingo Molnar
2012-02-28 11:25 ` Andi Kleen
2012-02-28 12:51 ` Ingo Molnar
2012-02-28 21:27 ` Andrew Morton
2012-02-29 5:44 ` Srivatsa S. Bhat
2012-02-29 9:17 ` Ingo Molnar
2012-02-29 11:12 ` Srivatsa S. Bhat
2012-03-01 7:38 ` Ingo Molnar
2012-03-01 9:15 ` Srivatsa S. Bhat
2012-03-01 9:45 ` Ingo Molnar
2012-03-01 9:56 ` Srivatsa S. Bhat
2012-03-01 8:12 ` Srivatsa S. Bhat
2012-03-01 8:15 ` [PATCH 1/3] CPU hotplug: Fix issues with callback registration Srivatsa S. Bhat
2012-03-01 8:16 ` [PATCH 2/3] CPU hotplug, arch/powerpc: Fix CPU hotplug " Srivatsa S. Bhat
2012-03-01 8:18 ` [PATCH 3/3] CPU hotplug, arch/sparc: " Srivatsa S. Bhat
2012-02-29 8:29 ` [PATCH] cpumask: fix lg_lock/br_lock Ingo Molnar
2012-02-29 8:58 ` Peter Zijlstra
2012-02-29 9:32 ` Ingo Molnar
2012-02-28 11:24 ` Andi Kleen
2012-03-05 7:02 ` Rusty Russell
2012-03-05 7:03 ` Rusty Russell [this message]
2012-04-20 11:12 ` [PATCH 1/3] lglock: remove online variants of lock Nick Piggin
2012-03-05 7:04 ` [PATCH 2/3] brlocks/lglocks: API cleanups Rusty Russell
2012-03-05 7:05 ` [PATCH 3/3] brlocks/lglocks: turn into functions Rusty Russell
2012-04-20 11:21 ` Nick Piggin
2012-05-07 3:39 ` Rusty Russell
2012-05-07 5:46 ` Al Viro
2012-05-08 3:59 ` [PATCH 1/3] lglock: remove online variants of lock Rusty Russell
2012-05-08 4:50 ` Al Viro
2012-05-08 6:12 ` Rusty Russell
2012-05-08 4:02 ` [PATCH 2/3] brlocks/lglocks: API cleanups Rusty Russell
2012-05-08 4:02 ` [PATCH 3/3] brlocks/lglocks: turn into functions Rusty Russell
2012-05-09 7:35 ` Nick Piggin
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=87obsbzfzm.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@kernel.dk \
--cc=srivatsa.bhat@linux.vnet.ibm.com \
--cc=viro@zeniv.linux.org.uk \
/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
Powered by JetHome