soft lockup in d_invalidate()

From: Sahitya Tummala
Date: Fri May 05 2017 - 09:21:18 EST


Hi,

We are seeing a soft lock up where a RT task is tight looping in d_invalidate(). The corresponding dentries are claimed by a low priority normal task, but this task is scheduled out. The cond_resched() in d_invalidate() is not taking into effect as this RT task is the highest priority task on the CPU. The below patch resolved this soft lockup issue on my system. Can you please tell if there would be any side effects by doing this?

diff --git a/fs/dcache.c b/fs/dcache.c
index 7b8feb6..3a3b0f37 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1364,7 +1364,7 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry)
goto out;

if (dentry->d_flags & DCACHE_SHRINK_LIST) {
- data->found++;
+ goto out;
} else {
if (dentry->d_flags & DCACHE_LRU_LIST)
d_lru_del(dentry);

Here is the call stack of RT task -

#0 [fffffffa2b5d78c0] __switch_to at ffffff90b6485eec
#1 [fffffffa2b5d78e0] __schedule at ffffff90b7413c44
#2 [fffffffa2b5d7940] preempt_schedule_notrace at ffffff90b7414078
#3 [fffffffa2b5d7960] trace_vbprintk at ffffff90b655c5b4
#4 [fffffffa2b5d79f0] __trace_bprintk at ffffff90b6563194
#5 [fffffffa2b5d7a90] d_invalidate at ffffff90b65f9f58
#6 [fffffffa2b5d7b30] proc_flush_task at ffffff90b66478c0
#7 [fffffffa2b5d7bd0] release_task at ffffff90b64a45a4
#8 [fffffffa2b5d7c40] do_exit at ffffff90b64a638c

Here is the call stack of a low priority normal task which claimed the dentries corresponding to above RT task â

#0 [fffffffa00e37120] __switch_to at ffffff90b6485eec
#1 [fffffffa00e37140] __schedule at ffffff90b7413c44
#2 [fffffffa00e371a0] preempt_schedule_common at ffffff90b7413f48
#3 [fffffffa00e371c0] preempt_schedule at ffffff90b7413f88
#4 [fffffffa00e371d0] _raw_spin_unlock_irqrestore at ffffff90b7418a10
#5 [fffffffa00e371f0] debug_object_active_state at ffffff90b67c91f0
#6 [fffffffa00e37270] __call_rcu.constprop.60 at ffffff90b65133ac
#7 [fffffffa00e372b0] call_rcu at ffffff90b65135f0
#8 [fffffffa00e372e0] dentry_free at ffffff90b65f82b8
#9 [fffffffa00e37300] __dentry_kill at ffffff90b65f84a4
#10 [fffffffa00e37350] shrink_dentry_list at ffffff90b65f9390
#11 [fffffffa00e373e0] prune_dcache_sb at ffffff90b65fa5d4
#12 [fffffffa00e37420] super_cache_scan at ffffff90b65e7ac4
#13 [fffffffa00e37480] do_shrink_slab at ffffff90b6599d50
#14 [fffffffa00e37500] shrink_slab at ffffff90b659a7dc
#15 [fffffffa00e37580] shrink_zone at ffffff90b659d2f4
#16 [fffffffa00e37610] do_try_to_free_pages at ffffff90b659d620
#17 [fffffffa00e376b0] try_to_free_pages at ffffff90b659d93c
#18 [fffffffa00e37740] __alloc_pages_nodemask at ffffff90b6590838
#19 [fffffffa00e37870] new_slab at ffffff90b65cee54
#20 [fffffffa00e378d0] ___slab_alloc at ffffff90b65d0164
#21 [fffffffa00e379f0] __slab_alloc at ffffff90b65d0210

-
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.