mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-19 21:56:31 +00:00
scst: prevent possible memory reclaim deadlock
Reported by lockdep: [ 415.813281] ================================= [ 415.817626] [ INFO: inconsistent lock state ] [ 415.821974] 4.10.12-scst-dbg #4 Tainted: G O [ 415.827360] --------------------------------- [ 415.831705] inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-W} usage. [ 415.838217] kswapd0/558 [HC0[0]:SC0[0]:HE1:SE1] takes: [ 415.843342] (sgv_pools_mutex){+.+.?.}, at: [<ffffffffa036d300>] __sgv_shrink+0x90/0x1d0 [scst] [ 415.852075] {RECLAIM_FS-ON-W} state was registered at: [ 415.857208] mark_held_locks+0x6c/0x90 [ 415.861034] lockdep_trace_alloc+0x8a/0xd0 [ 415.865210] kmem_cache_alloc_node+0x32/0x2f0 [ 415.869670] sgv_pool_create_node+0x186/0x2e0 [scst] [ 415.874735] sgv_pool_create+0x12/0x20 [scst] [ 415.879194] scst_sgv_pools_init+0xb9/0x3c0 [scst] [ 415.884065] __dev_user_set_opt+0x152/0x5f0 [scst_user] [ 415.889367] do_one_initcall+0x59/0x190 [ 415.893280] do_init_module+0x6a/0x230 [ 415.897106] load_module+0x591/0x830 [ 415.900758] SYSC_init_module+0xd3/0x120 [ 415.904758] SyS_init_module+0xe/0x10 [ 415.908501] entry_SYSCALL_64_fastpath+0x18/0xad [ 415.913193] irq event stamp: 3831137 [ 415.916763] hardirqs last enabled at (3831137): [<ffffffff8106ff37>] __local_bh_enable_ip+0x67/0xd0 [ 415.925878] hardirqs last disabled at (3831135): [<ffffffff8106fefe>] __local_bh_enable_ip+0x2e/0xd0 [ 415.935018] softirqs last enabled at (3831136): [<ffffffffa036c72d>] __sgv_can_be_shrunk+0x9d/0x180 [scst] [ 415.944764] softirqs last disabled at (3831134): [<ffffffffa036c6e3>] __sgv_can_be_shrunk+0x53/0x180 [scst] [ 415.954481] [ 415.954481] other info that might help us debug this: [ 415.960994] Possible unsafe locking scenario: [ 415.960994] [ 415.966899] CPU0 [ 415.969336] ---- [ 415.971774] lock(sgv_pools_mutex); [ 415.975339] <Interrupt> [ 415.977950] lock(sgv_pools_mutex); [ 415.981691] [ 415.981691] *** DEADLOCK *** [ 415.981691] [ 415.987599] 1 lock held by kswapd0/558: [ 415.991424] #0: (shrinker_rwsem){++++..}, at: [<ffffffff811ace5c>] T.1898+0x4c/0x100 [ 415.999329] [ 415.999329] stack backtrace: [ 416.003677] CPU: 2 PID: 558 Comm: kswapd0 Tainted: G O 4.10.12-scst-dbg #4 [ 416.011663] Hardware name: Dell Inc. PowerEdge R710/00NH4P, BIOS 2.2.10 11/09/2010 [ 416.019216] Call Trace: [ 416.021661] dump_stack+0x6b/0xa0 [ 416.024968] print_usage_bug+0x182/0x190 [ 416.028881] ? print_circular_bug+0x110/0x110 [ 416.033226] mark_lock_irq+0xee/0x290 [ 416.036879] mark_lock+0x113/0x1a0 [ 416.040271] mark_irqflags+0xb0/0x180 [ 416.043924] __lock_acquire+0x245/0x610 [ 416.047750] ? __lock_release+0x408/0x470 [ 416.051750] lock_acquire+0xce/0x2b0 [ 416.055343] ? __sgv_shrink+0x90/0x1d0 [scst] [ 416.059689] ? mutex_lock_nested+0x47/0x750 [ 416.063863] mutex_lock_nested+0x82/0x750 [ 416.067888] ? __sgv_shrink+0x90/0x1d0 [scst] [ 416.072236] ? put_lock_stats+0xe/0x30 [ 416.075975] ? __lock_release+0x408/0x470 [ 416.080001] ? __sgv_shrink+0x90/0x1d0 [scst] [ 416.084349] ? debug_smp_processor_id+0x17/0x20 [ 416.088868] ? put_lock_stats+0xe/0x30 [ 416.092633] ? __sgv_can_be_shrunk+0x9d/0x180 [scst] [ 416.097588] ? mark_held_locks+0x6c/0x90 [ 416.101500] ? __local_bh_enable_ip+0x67/0xd0 [ 416.105873] __sgv_shrink+0x90/0x1d0 [scst] [ 416.110047] ? __local_bh_enable_ip+0x67/0xd0 [ 416.114420] sgv_scan_shrink+0x5d/0x120 [scst] [ 416.118853] do_shrink_slab+0x19b/0x5f0 [ 416.122678] ? T.1898+0x4c/0x100 [ 416.125899] ? down_read_trylock+0x60/0x80 [ 416.129985] T.1898+0xb4/0x100 [ 416.133031] shrink_node+0x62/0xa0 [ 416.136424] balance_pgdat+0x1c8/0x2c0 [ 416.140164] kswapd+0xa0/0x2b0 [ 416.143211] ? preempt_count_sub+0x9f/0xe0 [ 416.147409] ? schedule+0x4e/0xc0 [ 416.150715] ? balance_pgdat+0x2c0/0x2c0 [ 416.154627] kthread+0x111/0x150 [ 416.157849] ? call_usermodehelper_exec_work+0xa0/0xa0 [ 416.162974] ? __kthread_init_worker+0x80/0x80 [ 416.167407] ? call_usermodehelper_exec_work+0xa0/0xa0 [ 416.172534] ? call_usermodehelper_exec_work+0xa0/0xa0 [ 416.177660] ret_from_fork+0x2e/0x40 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7194 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+6
-1
@@ -1645,7 +1645,12 @@ struct sgv_pool *sgv_pool_create_node(const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
pool = kmem_cache_alloc_node(sgv_pool_cachep, GFP_KERNEL, nodeid);
|
||||
/*
|
||||
* __sgv_shrink() takes sgv_pools_mutex, so, to prevent deadlock with it
|
||||
* if this allocation will try to reclaim memory, GFP_NOFS has to be used
|
||||
* here.
|
||||
*/
|
||||
pool = kmem_cache_alloc_node(sgv_pool_cachep, GFP_KERNEL|GFP_NOFS, nodeid);
|
||||
if (pool == NULL) {
|
||||
PRINT_ERROR("Allocation of sgv_pool failed (size %zd)",
|
||||
sizeof(*pool));
|
||||
|
||||
Reference in New Issue
Block a user