Skip to content

Commit 442464a

Browse files
committed
[SPARC64]: Make debugging spinlocks usable again.
When the spinlock routines were moved out of line into kernel/spinlock.c this made it so that the debugging spinlocks record lock acquisition program counts in the kernel/spinlock.c functions not in their callers. This makes the debugging info kind of useless. So record the correct caller's program counter and now this feature is useful once more. Signed-off-by: David S. Miller <[email protected]>
1 parent ca7c8d2 commit 442464a

File tree

3 files changed

+38
-65
lines changed

3 files changed

+38
-65
lines changed

arch/sparc64/kernel/sparc64_ksyms.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ extern int __ashrdi3(int, int);
9999
extern void dump_thread(struct pt_regs *, struct user *);
100100
extern int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs);
101101

102-
#if defined(CONFIG_SMP) && defined(CONFIG_DEBUG_SPINLOCK)
103-
extern void _do_spin_lock (spinlock_t *lock, char *str);
104-
extern void _do_spin_unlock (spinlock_t *lock);
105-
extern int _spin_trylock (spinlock_t *lock);
106-
extern void _do_read_lock(rwlock_t *rw, char *str);
107-
extern void _do_read_unlock(rwlock_t *rw, char *str);
108-
extern void _do_write_lock(rwlock_t *rw, char *str);
109-
extern void _do_write_unlock(rwlock_t *rw);
110-
extern int _do_write_trylock(rwlock_t *rw, char *str);
111-
#endif
112-
113102
extern unsigned long phys_base;
114103
extern unsigned long pfn_base;
115104

@@ -152,18 +141,6 @@ EXPORT_SYMBOL(_mcount);
152141
EXPORT_SYMBOL(cpu_online_map);
153142
EXPORT_SYMBOL(phys_cpu_present_map);
154143

155-
/* Spinlock debugging library, optional. */
156-
#ifdef CONFIG_DEBUG_SPINLOCK
157-
EXPORT_SYMBOL(_do_spin_lock);
158-
EXPORT_SYMBOL(_do_spin_unlock);
159-
EXPORT_SYMBOL(_spin_trylock);
160-
EXPORT_SYMBOL(_do_read_lock);
161-
EXPORT_SYMBOL(_do_read_unlock);
162-
EXPORT_SYMBOL(_do_write_lock);
163-
EXPORT_SYMBOL(_do_write_unlock);
164-
EXPORT_SYMBOL(_do_write_trylock);
165-
#endif
166-
167144
EXPORT_SYMBOL(smp_call_function);
168145
#endif /* CONFIG_SMP */
169146

arch/sparc64/lib/debuglocks.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
#ifdef CONFIG_SMP
1414

15-
#define GET_CALLER(PC) __asm__ __volatile__("mov %%i7, %0" : "=r" (PC))
16-
1715
static inline void show (char *str, spinlock_t *lock, unsigned long caller)
1816
{
1917
int cpu = smp_processor_id();
@@ -51,14 +49,13 @@ static inline void show_write (char *str, rwlock_t *lock, unsigned long caller)
5149
#undef INIT_STUCK
5250
#define INIT_STUCK 100000000
5351

54-
void _do_spin_lock(spinlock_t *lock, char *str)
52+
void _do_spin_lock(spinlock_t *lock, char *str, unsigned long caller)
5553
{
56-
unsigned long caller, val;
54+
unsigned long val;
5755
int stuck = INIT_STUCK;
5856
int cpu = get_cpu();
5957
int shown = 0;
6058

61-
GET_CALLER(caller);
6259
again:
6360
__asm__ __volatile__("ldstub [%1], %0"
6461
: "=r" (val)
@@ -84,12 +81,11 @@ void _do_spin_lock(spinlock_t *lock, char *str)
8481
put_cpu();
8582
}
8683

87-
int _do_spin_trylock(spinlock_t *lock)
84+
int _do_spin_trylock(spinlock_t *lock, unsigned long caller)
8885
{
89-
unsigned long val, caller;
86+
unsigned long val;
9087
int cpu = get_cpu();
9188

92-
GET_CALLER(caller);
9389
__asm__ __volatile__("ldstub [%1], %0"
9490
: "=r" (val)
9591
: "r" (&(lock->lock))
@@ -118,14 +114,13 @@ void _do_spin_unlock(spinlock_t *lock)
118114

119115
/* Keep INIT_STUCK the same... */
120116

121-
void _do_read_lock (rwlock_t *rw, char *str)
117+
void _do_read_lock(rwlock_t *rw, char *str, unsigned long caller)
122118
{
123-
unsigned long caller, val;
119+
unsigned long val;
124120
int stuck = INIT_STUCK;
125121
int cpu = get_cpu();
126122
int shown = 0;
127123

128-
GET_CALLER(caller);
129124
wlock_again:
130125
/* Wait for any writer to go away. */
131126
while (((long)(rw->lock)) < 0) {
@@ -157,15 +152,13 @@ void _do_read_lock (rwlock_t *rw, char *str)
157152
put_cpu();
158153
}
159154

160-
void _do_read_unlock (rwlock_t *rw, char *str)
155+
void _do_read_unlock(rwlock_t *rw, char *str, unsigned long caller)
161156
{
162-
unsigned long caller, val;
157+
unsigned long val;
163158
int stuck = INIT_STUCK;
164159
int cpu = get_cpu();
165160
int shown = 0;
166161

167-
GET_CALLER(caller);
168-
169162
/* Drop our identity _first_. */
170163
rw->reader_pc[cpu] = 0;
171164
current->thread.smp_lock_count--;
@@ -193,14 +186,13 @@ void _do_read_unlock (rwlock_t *rw, char *str)
193186
put_cpu();
194187
}
195188

196-
void _do_write_lock (rwlock_t *rw, char *str)
189+
void _do_write_lock(rwlock_t *rw, char *str, unsigned long caller)
197190
{
198-
unsigned long caller, val;
191+
unsigned long val;
199192
int stuck = INIT_STUCK;
200193
int cpu = get_cpu();
201194
int shown = 0;
202195

203-
GET_CALLER(caller);
204196
wlock_again:
205197
/* Spin while there is another writer. */
206198
while (((long)rw->lock) < 0) {
@@ -278,14 +270,12 @@ void _do_write_lock (rwlock_t *rw, char *str)
278270
put_cpu();
279271
}
280272

281-
void _do_write_unlock(rwlock_t *rw)
273+
void _do_write_unlock(rwlock_t *rw, unsigned long caller)
282274
{
283-
unsigned long caller, val;
275+
unsigned long val;
284276
int stuck = INIT_STUCK;
285277
int shown = 0;
286278

287-
GET_CALLER(caller);
288-
289279
/* Drop our identity _first_ */
290280
rw->writer_pc = 0;
291281
rw->writer_cpu = NO_PROC_ID;
@@ -313,13 +303,11 @@ void _do_write_unlock(rwlock_t *rw)
313303
}
314304
}
315305

316-
int _do_write_trylock (rwlock_t *rw, char *str)
306+
int _do_write_trylock(rwlock_t *rw, char *str, unsigned long caller)
317307
{
318-
unsigned long caller, val;
308+
unsigned long val;
319309
int cpu = get_cpu();
320310

321-
GET_CALLER(caller);
322-
323311
/* Try to acuire the write bit. */
324312
__asm__ __volatile__(
325313
" mov 1, %%g3\n"

include/asm-sparc64/spinlock.h

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ do { \
132132
membar("#LoadLoad"); \
133133
} while((__lock)->lock)
134134

135-
extern void _do_spin_lock (spinlock_t *lock, char *str);
136-
extern void _do_spin_unlock (spinlock_t *lock);
137-
extern int _do_spin_trylock (spinlock_t *lock);
138-
139-
#define _raw_spin_trylock(lp) _do_spin_trylock(lp)
140-
#define _raw_spin_lock(lock) _do_spin_lock(lock, "spin_lock")
135+
extern void _do_spin_lock(spinlock_t *lock, char *str, unsigned long caller);
136+
extern void _do_spin_unlock(spinlock_t *lock);
137+
extern int _do_spin_trylock(spinlock_t *lock, unsigned long caller);
138+
139+
#define _raw_spin_trylock(lp) \
140+
_do_spin_trylock(lp, (unsigned long) __builtin_return_address(0))
141+
#define _raw_spin_lock(lock) \
142+
_do_spin_lock(lock, "spin_lock", \
143+
(unsigned long) __builtin_return_address(0))
141144
#define _raw_spin_unlock(lock) _do_spin_unlock(lock)
142145
#define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock)
143146

@@ -279,45 +282,50 @@ typedef struct {
279282
#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } }
280283
#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
281284

282-
extern void _do_read_lock(rwlock_t *rw, char *str);
283-
extern void _do_read_unlock(rwlock_t *rw, char *str);
284-
extern void _do_write_lock(rwlock_t *rw, char *str);
285-
extern void _do_write_unlock(rwlock_t *rw);
286-
extern int _do_write_trylock(rwlock_t *rw, char *str);
285+
extern void _do_read_lock(rwlock_t *rw, char *str, unsigned long caller);
286+
extern void _do_read_unlock(rwlock_t *rw, char *str, unsigned long caller);
287+
extern void _do_write_lock(rwlock_t *rw, char *str, unsigned long caller);
288+
extern void _do_write_unlock(rwlock_t *rw, unsigned long caller);
289+
extern int _do_write_trylock(rwlock_t *rw, char *str, unsigned long caller);
287290

288291
#define _raw_read_lock(lock) \
289292
do { unsigned long flags; \
290293
local_irq_save(flags); \
291-
_do_read_lock(lock, "read_lock"); \
294+
_do_read_lock(lock, "read_lock", \
295+
(unsigned long) __builtin_return_address(0)); \
292296
local_irq_restore(flags); \
293297
} while(0)
294298

295299
#define _raw_read_unlock(lock) \
296300
do { unsigned long flags; \
297301
local_irq_save(flags); \
298-
_do_read_unlock(lock, "read_unlock"); \
302+
_do_read_unlock(lock, "read_unlock", \
303+
(unsigned long) __builtin_return_address(0)); \
299304
local_irq_restore(flags); \
300305
} while(0)
301306

302307
#define _raw_write_lock(lock) \
303308
do { unsigned long flags; \
304309
local_irq_save(flags); \
305-
_do_write_lock(lock, "write_lock"); \
310+
_do_write_lock(lock, "write_lock", \
311+
(unsigned long) __builtin_return_address(0)); \
306312
local_irq_restore(flags); \
307313
} while(0)
308314

309315
#define _raw_write_unlock(lock) \
310316
do { unsigned long flags; \
311317
local_irq_save(flags); \
312-
_do_write_unlock(lock); \
318+
_do_write_unlock(lock, \
319+
(unsigned long) __builtin_return_address(0)); \
313320
local_irq_restore(flags); \
314321
} while(0)
315322

316323
#define _raw_write_trylock(lock) \
317324
({ unsigned long flags; \
318325
int val; \
319326
local_irq_save(flags); \
320-
val = _do_write_trylock(lock, "write_trylock"); \
327+
val = _do_write_trylock(lock, "write_trylock", \
328+
(unsigned long) __builtin_return_address(0)); \
321329
local_irq_restore(flags); \
322330
val; \
323331
})

0 commit comments

Comments
 (0)