diff options
author | Josh Triplett <josh@joshtriplett.org> | 2014-04-07 18:39:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-07 19:36:14 -0400 |
commit | 64b47e8fdb40a0d46e8cf458dd3e24f8afa073f6 (patch) | |
tree | 284e2335ba622406f3d3437c2abd416cc8979294 | |
parent | 188a81409ff7de1c5aae947a96356ddd8ff4aaa3 (diff) |
lglock: map to spinlock when !CONFIG_SMP
When the system has only one CPU, lglock is effectively a spinlock; map
it directly to spinlock to eliminate the indirection and duplicate code.
In addition to removing overhead, this drops 1.6k of code with a
defconfig modified to have !CONFIG_SMP, and 1.1k with a minimal config.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: David Howells <dhowells@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/lglock.h | 16 | ||||
-rw-r--r-- | kernel/locking/Makefile | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/include/linux/lglock.h b/include/linux/lglock.h index 96549abe8842..0081f000e34b 100644 --- a/include/linux/lglock.h +++ b/include/linux/lglock.h | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/cpu.h> | 25 | #include <linux/cpu.h> |
26 | #include <linux/notifier.h> | 26 | #include <linux/notifier.h> |
27 | 27 | ||
28 | #ifdef CONFIG_SMP | ||
29 | |||
28 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 30 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
29 | #define LOCKDEP_INIT_MAP lockdep_init_map | 31 | #define LOCKDEP_INIT_MAP lockdep_init_map |
30 | #else | 32 | #else |
@@ -57,4 +59,18 @@ void lg_local_unlock_cpu(struct lglock *lg, int cpu); | |||
57 | void lg_global_lock(struct lglock *lg); | 59 | void lg_global_lock(struct lglock *lg); |
58 | void lg_global_unlock(struct lglock *lg); | 60 | void lg_global_unlock(struct lglock *lg); |
59 | 61 | ||
62 | #else | ||
63 | /* When !CONFIG_SMP, map lglock to spinlock */ | ||
64 | #define lglock spinlock | ||
65 | #define DEFINE_LGLOCK(name) DEFINE_SPINLOCK(name) | ||
66 | #define DEFINE_STATIC_LGLOCK(name) static DEFINE_SPINLOCK(name) | ||
67 | #define lg_lock_init(lg, name) spin_lock_init(lg) | ||
68 | #define lg_local_lock spin_lock | ||
69 | #define lg_local_unlock spin_unlock | ||
70 | #define lg_local_lock_cpu(lg, cpu) spin_lock(lg) | ||
71 | #define lg_local_unlock_cpu(lg, cpu) spin_unlock(lg) | ||
72 | #define lg_global_lock spin_lock | ||
73 | #define lg_global_unlock spin_unlock | ||
74 | #endif | ||
75 | |||
60 | #endif | 76 | #endif |
diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile index 306a76b51e0f..b8bdcd4785b7 100644 --- a/kernel/locking/Makefile +++ b/kernel/locking/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | obj-y += mutex.o semaphore.o rwsem.o lglock.o mcs_spinlock.o | 2 | obj-y += mutex.o semaphore.o rwsem.o mcs_spinlock.o |
3 | 3 | ||
4 | ifdef CONFIG_FUNCTION_TRACER | 4 | ifdef CONFIG_FUNCTION_TRACER |
5 | CFLAGS_REMOVE_lockdep.o = -pg | 5 | CFLAGS_REMOVE_lockdep.o = -pg |
@@ -14,6 +14,7 @@ ifeq ($(CONFIG_PROC_FS),y) | |||
14 | obj-$(CONFIG_LOCKDEP) += lockdep_proc.o | 14 | obj-$(CONFIG_LOCKDEP) += lockdep_proc.o |
15 | endif | 15 | endif |
16 | obj-$(CONFIG_SMP) += spinlock.o | 16 | obj-$(CONFIG_SMP) += spinlock.o |
17 | obj-$(CONFIG_SMP) += lglock.o | ||
17 | obj-$(CONFIG_PROVE_LOCKING) += spinlock.o | 18 | obj-$(CONFIG_PROVE_LOCKING) += spinlock.o |
18 | obj-$(CONFIG_RT_MUTEXES) += rtmutex.o | 19 | obj-$(CONFIG_RT_MUTEXES) += rtmutex.o |
19 | obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o | 20 | obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o |