Skip to contentSkip to conversation

rt,locking: fix __ww_mutex_lock_interruptible() lockdep annotation

patchlet Applied Mike Galbraith 3 participants 9 messages Jun 2, 2014 – Feb 16, 2015 Locking primitives

lore
Share & tools
lore
#0 lore raw

Using mutex_acquire_nest() as used in __ww_mutex_lock() fixes the splat below. Remove superfluous line break in __ww_mutex_lock() as well.

[   56.999063] =============================================
[   56.999063] [ INFO: possible recursive locking detected ]
[   56.999065] 3.14.4-rt5 #26 Not tainted
[   56.999065] ---------------------------------------------
[   56.999067] Xorg/4298 is trying to acquire lock:
[   56.999107]  (reservation_ww_class_mutex){+.+.+.}, at: [<ffffffffa02b4270>] nouveau_gem_ioctl_pushbuf+0x870/0x19f0 [nouveau]
[   56.999107] 
               but task is already holding lock:
[   56.999130]  (reservation_ww_class_mutex){+.+.+.}, at: [<ffffffffa02b4270>] nouveau_gem_ioctl_pushbuf+0x870/0x19f0 [nouveau]
[   56.999131] 
               other info that might help us debug this:
[   56.999131]  Possible unsafe locking scenario:
[   56.999132]        CPU0
[   56.999132]        ----
[   56.999133]   lock(reservation_ww_class_mutex);
[   56.999134]   lock(reservation_ww_class_mutex);
[   56.999134] 
                *** DEADLOCK ***
[   56.999135]  May be due to missing lock nesting notation
[   56.999136] 3 locks held by Xorg/4298:
[   56.999160]  #0:  (&cli->mutex){+.+.+.}, at: [<ffffffffa02b597b>] nouveau_abi16_get+0x2b/0x100 [nouveau]
[   56.999174]  #1:  (reservation_ww_class_acquire){+.+...}, at: [<ffffffffa0160cd2>] drm_ioctl+0x4d2/0x610 [drm]
[   56.999197]  #2:  (reservation_ww_class_mutex){+.+.+.}, at: [<ffffffffa02b4270>] nouveau_gem_ioctl_pushbuf+0x870/0x19f0 [nouveau]
[   56.999198] 
               stack backtrace:
[   56.999200] CPU: 1 PID: 4298 Comm: Xorg Not tainted 3.14.4-rt5 #26
[   56.999200] Hardware name: MEDIONPC MS-7502/MS-7502, BIOS 6.00 PG 12/26/2007
[   56.999203]  ffffffff820309b0 ffff8802217a9ac8 ffffffff8157e53e ffffffff820309b0
[   56.999205]  ffff8802217a9b90 ffffffff810964ce ffff8802217a9b40 0000000000000246
[   56.999207]  0000000000000003 ffffffff8204f130 0001e09300000000 0001e093347523a9
[   56.999207] Call Trace:
[   56.999212]  [<ffffffff8157e53e>] dump_stack+0x4f/0x9d
[   56.999215]  [<ffffffff810964ce>] __lock_acquire+0x169e/0x1a50
[   56.999218]  [<ffffffff81588da9>] ? preempt_count_sub+0x49/0x50
[   56.999219]  [<ffffffff81584541>] ? _raw_spin_unlock+0x31/0x60
[   56.999221]  [<ffffffff8109701d>] lock_acquire+0x8d/0x140
[   56.999243]  [<ffffffffa02b4270>] ? nouveau_gem_ioctl_pushbuf+0x870/0x19f0 [nouveau]
[   56.999246]  [<ffffffff8158313d>] __ww_mutex_lock_interruptible+0x3d/0xf0
[   56.999268]  [<ffffffffa02b4270>] ? nouveau_gem_ioctl_pushbuf+0x870/0x19f0 [nouveau]
[   56.999290]  [<ffffffffa02b4270>] nouveau_gem_ioctl_pushbuf+0x870/0x19f0 [nouveau]
[   56.999298]  [<ffffffffa0160cd2>] ? drm_ioctl+0x4d2/0x610 [drm]
[   56.999308]  [<ffffffffa0160cd2>] drm_ioctl+0x4d2/0x610 [drm]
[   56.999311]  [<ffffffff81588da9>] ? preempt_count_sub+0x49/0x50
[   56.999313]  [<ffffffff8107cd60>] ? migrate_enable+0xe0/0x1e0
[   56.999335]  [<ffffffffa02aaece>] nouveau_drm_ioctl+0x4e/0x90 [nouveau]
[   56.999338]  [<ffffffff81185ff0>] do_vfs_ioctl+0x300/0x530
[   56.999340]  [<ffffffff8158d33b>] ? sysret_check+0x1b/0x56
[   56.999342]  [<ffffffff81094a8d>] ? trace_hardirqs_on_caller+0x10d/0x1d0
[   56.999344]  [<ffffffff81186261>] SyS_ioctl+0x41/0x80
[   56.999345]  [<ffffffff8158d316>] system_call_fastpath+0x1a/0x1f
---
 kernel/locking/rtmutex.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/locking/rtmutex.c +2 -3
@@ -1780,7 +1780,7 @@ __ww_mutex_lock_interruptible(struct ww_
 
 	might_sleep();
 
-	mutex_acquire(&lock->base.dep_map, 0, 0, _RET_IP_);
+	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
 	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL, 0, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
@@ -1798,8 +1798,7 @@ __ww_mutex_lock(struct ww_mutex *lock, s
 
 	might_sleep();
 
-	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map,
-			_RET_IP_);
+	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
 	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL, 0, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
#1 lore raw

nouveau + rt = boom

TODO++: Rummage around in this nouveau -rt explosion.

[  178.647978] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
[  178.648010] IP: [<ffffffffa02ad6c2>] nouveau_fence_signal+0x52/0xd0 [nouveau]
[  178.648012] PGD 21fa60067 PUD 221b78067 PMD 0
[  178.648014] Oops: 0002 [#1] PREEMPT SMP
[  178.648018] Dumping ftrace buffer:
[  178.648021]    (ftrace buffer empty)
[  178.648045] Modules linked in: nfsd nfs_acl auth_rpcgss snd_pcm_oss snd_mixer_oss snd_seq oid_registry snd_seq_device edd nfs fscache lockd sunrpc af_packet bridge stp llc cpufreq_conservative cpufreq_ondemand cpufreq_userspace microcode cpufreq_powersave nls_iso8859_1 nls_cp437 vfat fat fuse ext3 jbd nouveau ttm drm_kms_helper e1000e drm snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_pcm i2c_algo_bit snd_timer iTCO_wdt usb_storage mxm_wmi video sr_mod cdrom sg iTCO_vendor_support snd wmi lpc_ich ptp acpi_cpufreq button mfd_core pps_core i2c_i801 pcspkr soundcore thermal fan processor thermal_sys
[  178.648047] CPU: 1 PID: 4298 Comm: Xorg Not tainted 3.14.4-rt5 #26
[  178.648048] Hardware name: MEDIONPC MS-7502/MS-7502, BIOS 6.00 PG 12/26/2007
[  178.648049] task: ffff8802201f0000 ti: ffff8802217a8000 task.ti: ffff8802217a8000
[  178.648072] RIP: 0010:[<ffffffffa02ad6c2>]  [<ffffffffa02ad6c2>] nouveau_fence_signal+0x52/0xd0 [nouveau]
[  178.648073] RSP: 0018:ffff8802217a9c88  EFLAGS: 00010202
[  178.648074] RAX: 0000000000000000 RBX: ffff8800ca64df60 RCX: 0000000000000000
[  178.648075] RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
[  178.648075] RBP: ffff8802217a9ca8 R08: 0000000000000000 R09: 0000000000000000
[  178.648076] R10: ffff8802201f0000 R11: 0000000000000001 R12: ffff8800ca64dea0
[  178.648077] R13: ffff880204497c50 R14: ffff880204497c40 R15: ffff88021f903048
[  178.648078] FS:  00007f9be9f2d880(0000) GS:ffff88022fc80000(0000) knlGS:0000000000000000
[  178.648079] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  178.648080] CR2: 0000000000000008 CR3: 000000021f5dd000 CR4: 00000000000007e0
[  178.648081] Stack:
[  178.648083]  ffff880204497c40 ffff8802044973c0 ffff88021f903000 ffff880037a7a840
[  178.648085]  ffff8802217a9ce0 ffffffffa02ad7f8 ffff880037a7a840 ffff8800b9de6200
[  178.648087]  ffff880204497f80 ffffffffa02b2e50 ffff88021f755000 ffff8802217a9d18
[  178.648087] Call Trace:
[  178.648111]  [<ffffffffa02ad7f8>] nouveau_fence_update+0x48/0xa0 [nouveau]
[  178.648133]  [<ffffffffa02b2e50>] ? nouveau_gem_info+0xc0/0xc0 [nouveau]
[  178.648156]  [<ffffffffa02adfb0>] nouveau_fence_work+0x30/0x150 [nouveau]
[  178.648178]  [<ffffffffa02b3647>] nouveau_gem_object_close+0x137/0x1d0 [nouveau]
[  178.648190]  [<ffffffffa01628b2>] drm_gem_handle_delete+0xc2/0x120 [drm]
[  178.648199]  [<ffffffffa0162ff8>] drm_gem_close_ioctl+0x28/0x30 [drm]
[  178.648208]  [<ffffffffa0160cd2>] drm_ioctl+0x4d2/0x610 [drm]
[  178.648213]  [<ffffffff8139d4a5>] ? __pm_runtime_resume+0x35/0x60
[  178.648216]  [<ffffffff8107c84d>] ? get_parent_ip+0xd/0x50
[  178.648219]  [<ffffffff81588da9>] ? preempt_count_sub+0x49/0x50
[  178.648221]  [<ffffffff8107cd60>] ? migrate_enable+0xe0/0x1e0
[  178.648243]  [<ffffffffa02aaece>] nouveau_drm_ioctl+0x4e/0x90 [nouveau]
[  178.648245]  [<ffffffff81185ff0>] do_vfs_ioctl+0x300/0x530
[  178.648248]  [<ffffffff8158d33b>] ? sysret_check+0x1b/0x56
[  178.648250]  [<ffffffff81094996>] ? trace_hardirqs_on_caller+0x16/0x1d0
[  178.648252]  [<ffffffff81186261>] SyS_ioctl+0x41/0x80
[  178.648254]  [<ffffffff8158d316>] system_call_fastpath+0x1a/0x1f
[  178.648273] Code: 61 c0 75 0b eb 5b 0f 1f 00 4c 89 e3 49 89 d4 48 8b 35 b3 f3 81 e1 48 89 da bf 08 00 00 00 e8 d6 70 db e0 48 8b 53 40 48 8b 43 48 <48> 89 42 08 48 89 10 48 b8 00 01 10 00 00 00 ad de 48 89 43 40
[  178.648295] RIP  [<ffffffffa02ad6c2>] nouveau_fence_signal+0x52/0xd0 [nouveau]
[  178.648295]  RSP <ffff8802217a9c88>
[  178.648296] CR2: 0000000000000008
#4 lore raw

Re: nouveau + rt = boom

Quoted 7 lines · Mike Galbraith
Quoted 4 lines · Sebastian Andrzej Siewior
Quoted 1 line · Mike Galbraith

TODO++: Rummage around in this nouveau -rt explosion.

https://lkml.org/lkml/2014/3/7/163

Aha, thanks.

I hit instability in a SLE nopreempt kernel yesterday with the thing too, one of the events being an fs BUG() that just happened to occur immediately after my display went gaga. Playing with nouveau in box I need for daily bread could be a bad idea. (chicken) TODO--

-Mike

#6 lore raw
Quoted 1 line · Sebastian Andrzej Siewior

umgwanakikbuti? The good ones were taken, right?

Yup, I have a low tolerance for "Taken, try again". My next may well be gimmeafuckingaccountdamnit :)

-Mike

#8 lore raw
Quoted 9 lines · Steven Rostedt

On Mon, 16 Feb 2015 18:24:32 +0100
Sebastian Andrzej Siewior <[email protected]> wrote:

\

Quoted 3 lines
Quoted 1 line

umgwanakikbuti? The good ones were taken, right?

I think Mike threw up on the keyboard while creating his user name.

Ooook, 'nuff crack'n on little ole /me, get back to work ;-)

-Mike