]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.62/fs-dcache.c-fix-spin-lockup-issue-on-nlru-lock.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.62 / fs-dcache.c-fix-spin-lockup-issue-on-nlru-lock.patch
1 From b17c070fb624cf10162cf92ea5e1ec25cd8ac176 Mon Sep 17 00:00:00 2001
2 From: Sahitya Tummala <stummala@codeaurora.org>
3 Date: Mon, 10 Jul 2017 15:50:00 -0700
4 Subject: fs/dcache.c: fix spin lockup issue on nlru->lock
5
6 From: Sahitya Tummala <stummala@codeaurora.org>
7
8 commit b17c070fb624cf10162cf92ea5e1ec25cd8ac176 upstream.
9
10 __list_lru_walk_one() acquires nlru spin lock (nlru->lock) for longer
11 duration if there are more number of items in the lru list. As per the
12 current code, it can hold the spin lock for upto maximum UINT_MAX
13 entries at a time. So if there are more number of items in the lru
14 list, then "BUG: spinlock lockup suspected" is observed in the below
15 path:
16
17 spin_bug+0x90
18 do_raw_spin_lock+0xfc
19 _raw_spin_lock+0x28
20 list_lru_add+0x28
21 dput+0x1c8
22 path_put+0x20
23 terminate_walk+0x3c
24 path_lookupat+0x100
25 filename_lookup+0x6c
26 user_path_at_empty+0x54
27 SyS_faccessat+0xd0
28 el0_svc_naked+0x24
29
30 This nlru->lock is acquired by another CPU in this path -
31
32 d_lru_shrink_move+0x34
33 dentry_lru_isolate_shrink+0x48
34 __list_lru_walk_one.isra.10+0x94
35 list_lru_walk_node+0x40
36 shrink_dcache_sb+0x60
37 do_remount_sb+0xbc
38 do_emergency_remount+0xb0
39 process_one_work+0x228
40 worker_thread+0x2e0
41 kthread+0xf4
42 ret_from_fork+0x10
43
44 Fix this lockup by reducing the number of entries to be shrinked from
45 the lru list to 1024 at once. Also, add cond_resched() before
46 processing the lru list again.
47
48 Link: http://marc.info/?t=149722864900001&r=1&w=2
49 Link: http://lkml.kernel.org/r/1498707575-2472-1-git-send-email-stummala@codeaurora.org
50 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
51 Suggested-by: Jan Kara <jack@suse.cz>
52 Suggested-by: Vladimir Davydov <vdavydov.dev@gmail.com>
53 Acked-by: Vladimir Davydov <vdavydov.dev@gmail.com>
54 Cc: Alexander Polakov <apolyakov@beget.ru>
55 Cc: Al Viro <viro@zeniv.linux.org.uk>
56 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
57 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
58 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
59
60 ---
61 fs/dcache.c | 5 +++--
62 1 file changed, 3 insertions(+), 2 deletions(-)
63
64 --- a/fs/dcache.c
65 +++ b/fs/dcache.c
66 @@ -1104,11 +1104,12 @@ void shrink_dcache_sb(struct super_block
67 LIST_HEAD(dispose);
68
69 freed = list_lru_walk(&sb->s_dentry_lru,
70 - dentry_lru_isolate_shrink, &dispose, UINT_MAX);
71 + dentry_lru_isolate_shrink, &dispose, 1024);
72
73 this_cpu_sub(nr_dentry_unused, freed);
74 shrink_dentry_list(&dispose);
75 - } while (freed > 0);
76 + cond_resched();
77 + } while (list_lru_count(&sb->s_dentry_lru) > 0);
78 }
79 EXPORT_SYMBOL(shrink_dcache_sb);
80