summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Fang <fangwei1@huawei.com>2016-07-06 11:32:20 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-16 09:35:00 +0200
commit84603f74a6c18be9e7c5bb2548448c42cc28e2c5 (patch)
treed20ec14d42ace2aba89ccaf75162e6b371f77c89
parent378eef490f449c6583ce63e32ac8b9ab27d3cdb4 (diff)
downloadlinux-stable-84603f74a6c18be9e7c5bb2548448c42cc28e2c5.tar.gz
linux-stable-84603f74a6c18be9e7c5bb2548448c42cc28e2c5.tar.bz2
linux-stable-84603f74a6c18be9e7c5bb2548448c42cc28e2c5.zip
fs/dcache.c: avoid soft-lockup in dput()
commit 47be61845c775643f1aa4d2a54343549f943c94c upstream. We triggered soft-lockup under stress test which open/access/write/close one file concurrently on more than five different CPUs: WARN: soft lockup - CPU#0 stuck for 11s! [who:30631] ... [<ffffffc0003986f8>] dput+0x100/0x298 [<ffffffc00038c2dc>] terminate_walk+0x4c/0x60 [<ffffffc00038f56c>] path_lookupat+0x5cc/0x7a8 [<ffffffc00038f780>] filename_lookup+0x38/0xf0 [<ffffffc000391180>] user_path_at_empty+0x78/0xd0 [<ffffffc0003911f4>] user_path_at+0x1c/0x28 [<ffffffc00037d4fc>] SyS_faccessat+0xb4/0x230 ->d_lock trylock may failed many times because of concurrently operations, and dput() may execute a long time. Fix this by replacing cpu_relax() with cond_resched(). dput() used to be sleepable, so make it sleepable again should be safe. Signed-off-by: Wei Fang <fangwei1@huawei.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/dcache.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index d6847d7b123d..1ed81bb80500 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -622,7 +622,6 @@ static struct dentry *dentry_kill(struct dentry *dentry)
failed:
spin_unlock(&dentry->d_lock);
- cpu_relax();
return dentry; /* try again with same dentry */
}
@@ -796,6 +795,8 @@ void dput(struct dentry *dentry)
return;
repeat:
+ might_sleep();
+
rcu_read_lock();
if (likely(fast_dput(dentry))) {
rcu_read_unlock();
@@ -829,8 +830,10 @@ repeat:
kill_it:
dentry = dentry_kill(dentry);
- if (dentry)
+ if (dentry) {
+ cond_resched();
goto repeat;
+ }
}
EXPORT_SYMBOL(dput);