diff options
author | Yang Shi <yang.shi@linaro.org> | 2015-10-05 17:32:51 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2015-10-06 14:10:28 -0400 |
commit | 62c6c61adbc623cdacf74b8f29c278e539060c48 (patch) | |
tree | c4f2a483ba5f7a3bb7ca3843212c72877e4946af | |
parent | 4ca3bc86bea23f38596ce7508f75e072839bde44 (diff) |
arm64: replace read_lock to rcu lock in call_break_hook
BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917
in_atomic(): 0, irqs_disabled(): 128, pid: 342, name: perf
1 lock held by perf/342:
#0: (break_hook_lock){+.+...}, at: [<ffffffc0000851ac>] call_break_hook+0x34/0xd0
irq event stamp: 62224
hardirqs last enabled at (62223): [<ffffffc00010b7bc>] __call_rcu.constprop.59+0x104/0x270
hardirqs last disabled at (62224): [<ffffffc0000fbe20>] vprintk_emit+0x68/0x640
softirqs last enabled at (0): [<ffffffc000097928>] copy_process.part.8+0x428/0x17f8
softirqs last disabled at (0): [< (null)>] (null)
CPU: 0 PID: 342 Comm: perf Not tainted 4.1.6-rt5 #4
Hardware name: linux,dummy-virt (DT)
Call trace:
[<ffffffc000089968>] dump_backtrace+0x0/0x128
[<ffffffc000089ab0>] show_stack+0x20/0x30
[<ffffffc0007030d0>] dump_stack+0x7c/0xa0
[<ffffffc0000c878c>] ___might_sleep+0x174/0x260
[<ffffffc000708ac8>] __rt_spin_lock+0x28/0x40
[<ffffffc000708db0>] rt_read_lock+0x60/0x80
[<ffffffc0000851a8>] call_break_hook+0x30/0xd0
[<ffffffc000085a70>] brk_handler+0x30/0x98
[<ffffffc000082248>] do_debug_exception+0x50/0xb8
Exception stack(0xffffffc00514fe30 to 0xffffffc00514ff50)
fe20: 00000000 00000000 c1594680 0000007f
fe40: ffffffff ffffffff 92063940 0000007f 0550dcd8 ffffffc0 00000000 00000000
fe60: 0514fe70 ffffffc0 000be1f8 ffffffc0 0514feb0 ffffffc0 0008948c ffffffc0
fe80: 00000004 00000000 0514fed0 ffffffc0 ffffffff ffffffff 9282a948 0000007f
fea0: 00000000 00000000 9282b708 0000007f c1592820 0000007f 00083914 ffffffc0
fec0: 00000000 00000000 00000010 00000000 00000064 00000000 00000001 00000000
fee0: 005101e0 00000000 c1594680 0000007f c1594740 0000007f ffffffd8 ffffff80
ff00: 00000000 00000000 00000000 00000000 c1594770 0000007f c1594770 0000007f
ff20: 00665e10 00000000 7f7f7f7f 7f7f7f7f 01010101 01010101 00000000 00000000
ff40: 928e4cc0 0000007f 91ff11e8 0000007f
call_break_hook is called in atomic context (hard irq disabled), so replace
the sleepable lock to rcu lock, replace relevant list operations to rcu
version and call synchronize_rcu() in unregister_break_hook().
And, replace write lock to spinlock in {un}register_break_hook.
Signed-off-by: Yang Shi <yang.shi@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | arch/arm64/kernel/debug-monitors.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 8eef30f92651..253021ef2769 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c | |||
@@ -271,20 +271,21 @@ static int single_step_handler(unsigned long addr, unsigned int esr, | |||
271 | * Use reader/writer locks instead of plain spinlock. | 271 | * Use reader/writer locks instead of plain spinlock. |
272 | */ | 272 | */ |
273 | static LIST_HEAD(break_hook); | 273 | static LIST_HEAD(break_hook); |
274 | static DEFINE_RWLOCK(break_hook_lock); | 274 | static DEFINE_SPINLOCK(break_hook_lock); |
275 | 275 | ||
276 | void register_break_hook(struct break_hook *hook) | 276 | void register_break_hook(struct break_hook *hook) |
277 | { | 277 | { |
278 | write_lock(&break_hook_lock); | 278 | spin_lock(&break_hook_lock); |
279 | list_add(&hook->node, &break_hook); | 279 | list_add_rcu(&hook->node, &break_hook); |
280 | write_unlock(&break_hook_lock); | 280 | spin_unlock(&break_hook_lock); |
281 | } | 281 | } |
282 | 282 | ||
283 | void unregister_break_hook(struct break_hook *hook) | 283 | void unregister_break_hook(struct break_hook *hook) |
284 | { | 284 | { |
285 | write_lock(&break_hook_lock); | 285 | spin_lock(&break_hook_lock); |
286 | list_del(&hook->node); | 286 | list_del_rcu(&hook->node); |
287 | write_unlock(&break_hook_lock); | 287 | spin_unlock(&break_hook_lock); |
288 | synchronize_rcu(); | ||
288 | } | 289 | } |
289 | 290 | ||
290 | static int call_break_hook(struct pt_regs *regs, unsigned int esr) | 291 | static int call_break_hook(struct pt_regs *regs, unsigned int esr) |
@@ -292,11 +293,11 @@ static int call_break_hook(struct pt_regs *regs, unsigned int esr) | |||
292 | struct break_hook *hook; | 293 | struct break_hook *hook; |
293 | int (*fn)(struct pt_regs *regs, unsigned int esr) = NULL; | 294 | int (*fn)(struct pt_regs *regs, unsigned int esr) = NULL; |
294 | 295 | ||
295 | read_lock(&break_hook_lock); | 296 | rcu_read_lock(); |
296 | list_for_each_entry(hook, &break_hook, node) | 297 | list_for_each_entry_rcu(hook, &break_hook, node) |
297 | if ((esr & hook->esr_mask) == hook->esr_val) | 298 | if ((esr & hook->esr_mask) == hook->esr_val) |
298 | fn = hook->fn; | 299 | fn = hook->fn; |
299 | read_unlock(&break_hook_lock); | 300 | rcu_read_unlock(); |
300 | 301 | ||
301 | return fn ? fn(regs, esr) : DBG_HOOK_ERROR; | 302 | return fn ? fn(regs, esr) : DBG_HOOK_ERROR; |
302 | } | 303 | } |