Skip to content

Commit 6beb000

Browse files
committed
locking: Make inlining decision Kconfig based
commit 892a7c6 (locking: Allow arch-inlined spinlocks) implements the selection of which lock functions are inlined based on defines in arch/.../spinlock.h: #define __always_inline__LOCK_FUNCTION Despite of the name __always_inline__* the lock functions can be built out of line depending on config options. Also if the arch does not set some inline defines the generic code might set them; again depending on config options. This makes it unnecessary hard to figure out when and which lock functions are inlined. Aside of that it makes it way harder and messier for -rt to manipulate the lock functions. Convert the inlining decision to CONFIG switches. Each lock function is inlined depending on CONFIG_INLINE_*. The configs implement the existing dependencies. The architecture code can select ARCH_INLINE_* to signal that it wants the corresponding lock function inlined. ARCH_INLINE_* is necessary as Kconfig ignores "depends on" restrictions when a config element is selected. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> LKML-Reference: <[email protected]> Acked-by: Heiko Carstens <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra <[email protected]>
1 parent 156171c commit 6beb000

File tree

6 files changed

+284
-104
lines changed

6 files changed

+284
-104
lines changed

arch/s390/Kconfig

+28
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,34 @@ config S390
9595
select HAVE_ARCH_TRACEHOOK
9696
select INIT_ALL_POSSIBLE
9797
select HAVE_PERF_EVENTS
98+
select ARCH_INLINE_SPIN_TRYLOCK
99+
select ARCH_INLINE_SPIN_TRYLOCK_BH
100+
select ARCH_INLINE_SPIN_LOCK
101+
select ARCH_INLINE_SPIN_LOCK_BH
102+
select ARCH_INLINE_SPIN_LOCK_IRQ
103+
select ARCH_INLINE_SPIN_LOCK_IRQSAVE
104+
select ARCH_INLINE_SPIN_UNLOCK
105+
select ARCH_INLINE_SPIN_UNLOCK_BH
106+
select ARCH_INLINE_SPIN_UNLOCK_IRQ
107+
select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE
108+
select ARCH_INLINE_READ_TRYLOCK
109+
select ARCH_INLINE_READ_LOCK
110+
select ARCH_INLINE_READ_LOCK_BH
111+
select ARCH_INLINE_READ_LOCK_IRQ
112+
select ARCH_INLINE_READ_LOCK_IRQSAVE
113+
select ARCH_INLINE_READ_UNLOCK
114+
select ARCH_INLINE_READ_UNLOCK_BH
115+
select ARCH_INLINE_READ_UNLOCK_IRQ
116+
select ARCH_INLINE_READ_UNLOCK_IRQRESTORE
117+
select ARCH_INLINE_WRITE_TRYLOCK
118+
select ARCH_INLINE_WRITE_LOCK
119+
select ARCH_INLINE_WRITE_LOCK_BH
120+
select ARCH_INLINE_WRITE_LOCK_IRQ
121+
select ARCH_INLINE_WRITE_LOCK_IRQSAVE
122+
select ARCH_INLINE_WRITE_UNLOCK
123+
select ARCH_INLINE_WRITE_UNLOCK_BH
124+
select ARCH_INLINE_WRITE_UNLOCK_IRQ
125+
select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
98126

99127
config SCHED_OMIT_FRAME_POINTER
100128
bool

arch/s390/include/asm/spinlock.h

-29
Original file line numberDiff line numberDiff line change
@@ -191,33 +191,4 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
191191
#define _raw_read_relax(lock) cpu_relax()
192192
#define _raw_write_relax(lock) cpu_relax()
193193

194-
#define __always_inline__spin_lock
195-
#define __always_inline__read_lock
196-
#define __always_inline__write_lock
197-
#define __always_inline__spin_lock_bh
198-
#define __always_inline__read_lock_bh
199-
#define __always_inline__write_lock_bh
200-
#define __always_inline__spin_lock_irq
201-
#define __always_inline__read_lock_irq
202-
#define __always_inline__write_lock_irq
203-
#define __always_inline__spin_lock_irqsave
204-
#define __always_inline__read_lock_irqsave
205-
#define __always_inline__write_lock_irqsave
206-
#define __always_inline__spin_trylock
207-
#define __always_inline__read_trylock
208-
#define __always_inline__write_trylock
209-
#define __always_inline__spin_trylock_bh
210-
#define __always_inline__spin_unlock
211-
#define __always_inline__read_unlock
212-
#define __always_inline__write_unlock
213-
#define __always_inline__spin_unlock_bh
214-
#define __always_inline__read_unlock_bh
215-
#define __always_inline__write_unlock_bh
216-
#define __always_inline__spin_unlock_irq
217-
#define __always_inline__read_unlock_irq
218-
#define __always_inline__write_unlock_irq
219-
#define __always_inline__spin_unlock_irqrestore
220-
#define __always_inline__read_unlock_irqrestore
221-
#define __always_inline__write_unlock_irqrestore
222-
223194
#endif /* __ASM_SPINLOCK_H */

include/linux/spinlock_api_smp.h

+28-47
Original file line numberDiff line numberDiff line change
@@ -60,137 +60,118 @@ void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
6060
void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
6161
__releases(lock);
6262

63-
/*
64-
* We inline the unlock functions in the nondebug case:
65-
*/
66-
#if !defined(CONFIG_DEBUG_SPINLOCK) && !defined(CONFIG_PREEMPT)
67-
#define __always_inline__spin_unlock
68-
#define __always_inline__read_unlock
69-
#define __always_inline__write_unlock
70-
#define __always_inline__spin_unlock_irq
71-
#define __always_inline__read_unlock_irq
72-
#define __always_inline__write_unlock_irq
73-
#endif
74-
75-
#ifndef CONFIG_DEBUG_SPINLOCK
76-
#ifndef CONFIG_GENERIC_LOCKBREAK
77-
78-
#ifdef __always_inline__spin_lock
63+
#ifdef CONFIG_INLINE_SPIN_LOCK
7964
#define _spin_lock(lock) __spin_lock(lock)
8065
#endif
8166

82-
#ifdef __always_inline__read_lock
67+
#ifdef CONFIG_INLINE_READ_LOCK
8368
#define _read_lock(lock) __read_lock(lock)
8469
#endif
8570

86-
#ifdef __always_inline__write_lock
71+
#ifdef CONFIG_INLINE_WRITE_LOCK
8772
#define _write_lock(lock) __write_lock(lock)
8873
#endif
8974

90-
#ifdef __always_inline__spin_lock_bh
75+
#ifdef CONFIG_INLINE_SPIN_LOCK_BH
9176
#define _spin_lock_bh(lock) __spin_lock_bh(lock)
9277
#endif
9378

94-
#ifdef __always_inline__read_lock_bh
79+
#ifdef CONFIG_INLINE_READ_LOCK_BH
9580
#define _read_lock_bh(lock) __read_lock_bh(lock)
9681
#endif
9782

98-
#ifdef __always_inline__write_lock_bh
83+
#ifdef CONFIG_INLINE_WRITE_LOCK_BH
9984
#define _write_lock_bh(lock) __write_lock_bh(lock)
10085
#endif
10186

102-
#ifdef __always_inline__spin_lock_irq
87+
#ifdef CONFIG_INLINE_SPIN_LOCK_IRQ
10388
#define _spin_lock_irq(lock) __spin_lock_irq(lock)
10489
#endif
10590

106-
#ifdef __always_inline__read_lock_irq
91+
#ifdef CONFIG_INLINE_READ_LOCK_IRQ
10792
#define _read_lock_irq(lock) __read_lock_irq(lock)
10893
#endif
10994

110-
#ifdef __always_inline__write_lock_irq
95+
#ifdef CONFIG_INLINE_WRITE_LOCK_IRQ
11196
#define _write_lock_irq(lock) __write_lock_irq(lock)
11297
#endif
11398

114-
#ifdef __always_inline__spin_lock_irqsave
99+
#ifdef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
115100
#define _spin_lock_irqsave(lock) __spin_lock_irqsave(lock)
116101
#endif
117102

118-
#ifdef __always_inline__read_lock_irqsave
103+
#ifdef CONFIG_INLINE_READ_LOCK_IRQSAVE
119104
#define _read_lock_irqsave(lock) __read_lock_irqsave(lock)
120105
#endif
121106

122-
#ifdef __always_inline__write_lock_irqsave
107+
#ifdef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
123108
#define _write_lock_irqsave(lock) __write_lock_irqsave(lock)
124109
#endif
125110

126-
#endif /* !CONFIG_GENERIC_LOCKBREAK */
127-
128-
#ifdef __always_inline__spin_trylock
111+
#ifdef CONFIG_INLINE_SPIN_TRYLOCK
129112
#define _spin_trylock(lock) __spin_trylock(lock)
130113
#endif
131114

132-
#ifdef __always_inline__read_trylock
115+
#ifdef CONFIG_INLINE_READ_TRYLOCK
133116
#define _read_trylock(lock) __read_trylock(lock)
134117
#endif
135118

136-
#ifdef __always_inline__write_trylock
119+
#ifdef CONFIG_INLINE_WRITE_TRYLOCK
137120
#define _write_trylock(lock) __write_trylock(lock)
138121
#endif
139122

140-
#ifdef __always_inline__spin_trylock_bh
123+
#ifdef CONFIG_INLINE_SPIN_TRYLOCK_BH
141124
#define _spin_trylock_bh(lock) __spin_trylock_bh(lock)
142125
#endif
143126

144-
#ifdef __always_inline__spin_unlock
127+
#ifdef CONFIG_INLINE_SPIN_UNLOCK
145128
#define _spin_unlock(lock) __spin_unlock(lock)
146129
#endif
147130

148-
#ifdef __always_inline__read_unlock
131+
#ifdef CONFIG_INLINE_READ_UNLOCK
149132
#define _read_unlock(lock) __read_unlock(lock)
150133
#endif
151134

152-
#ifdef __always_inline__write_unlock
135+
#ifdef CONFIG_INLINE_WRITE_UNLOCK
153136
#define _write_unlock(lock) __write_unlock(lock)
154137
#endif
155138

156-
#ifdef __always_inline__spin_unlock_bh
139+
#ifdef CONFIG_INLINE_SPIN_UNLOCK_BH
157140
#define _spin_unlock_bh(lock) __spin_unlock_bh(lock)
158141
#endif
159142

160-
#ifdef __always_inline__read_unlock_bh
143+
#ifdef CONFIG_INLINE_READ_UNLOCK_BH
161144
#define _read_unlock_bh(lock) __read_unlock_bh(lock)
162145
#endif
163146

164-
#ifdef __always_inline__write_unlock_bh
147+
#ifdef CONFIG_INLINE_WRITE_UNLOCK_BH
165148
#define _write_unlock_bh(lock) __write_unlock_bh(lock)
166149
#endif
167150

168-
#ifdef __always_inline__spin_unlock_irq
151+
#ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQ
169152
#define _spin_unlock_irq(lock) __spin_unlock_irq(lock)
170153
#endif
171154

172-
#ifdef __always_inline__read_unlock_irq
155+
#ifdef CONFIG_INLINE_READ_UNLOCK_IRQ
173156
#define _read_unlock_irq(lock) __read_unlock_irq(lock)
174157
#endif
175158

176-
#ifdef __always_inline__write_unlock_irq
159+
#ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQ
177160
#define _write_unlock_irq(lock) __write_unlock_irq(lock)
178161
#endif
179162

180-
#ifdef __always_inline__spin_unlock_irqrestore
163+
#ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
181164
#define _spin_unlock_irqrestore(lock, flags) __spin_unlock_irqrestore(lock, flags)
182165
#endif
183166

184-
#ifdef __always_inline__read_unlock_irqrestore
167+
#ifdef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
185168
#define _read_unlock_irqrestore(lock, flags) __read_unlock_irqrestore(lock, flags)
186169
#endif
187170

188-
#ifdef __always_inline__write_unlock_irqrestore
171+
#ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE
189172
#define _write_unlock_irqrestore(lock, flags) __write_unlock_irqrestore(lock, flags)
190173
#endif
191174

192-
#endif /* CONFIG_DEBUG_SPINLOCK */
193-
194175
static inline int __spin_trylock(spinlock_t *lock)
195176
{
196177
preempt_disable();

init/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1210,3 +1210,4 @@ source "block/Kconfig"
12101210
config PREEMPT_NOTIFIERS
12111211
bool
12121212

1213+
source "kernel/Kconfig.locks"

0 commit comments

Comments
 (0)