]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0358-fs-dcache-resched-chill-only-if-we-make-no-progress.patch
rt_patches: required rebase due to printk change
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0358-fs-dcache-resched-chill-only-if-we-make-no-progress.patch
1 From 73d999505705cdbe4850a6fd98522de820937c7a Mon Sep 17 00:00:00 2001
2 From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
3 Date: Thu, 8 Sep 2016 18:33:52 +0200
4 Subject: [PATCH 358/366] fs/dcache: resched/chill only if we make no progress
5
6 Upstream commit 47be61845c77 ("fs/dcache.c: avoid soft-lockup in
7 dput()") changed the condition _when_ cpu_relax() / cond_resched() was
8 invoked. This change was adapted in -RT into mostly the same thing
9 except that if cond_resched() did nothing we had to do cpu_chill() to
10 force the task off CPU for a tiny little bit in case the task had RT
11 priority and did not want to leave the CPU.
12 This change resulted in a performance regression (in my testcase the
13 build time on /dev/shm increased from 19min to 24min). The reason is
14 that with this change cpu_chill() was invoked even dput() made progress
15 (dentry_kill() returned a different dentry) instead only if we were
16 trying this operation on the same dentry over and over again.
17
18 This patch brings back to the old behavior back to cond_resched() &
19 chill if we make no progress. A little improvement is to invoke
20 cpu_chill() only if we are a RT task (and avoid the sleep otherwise).
21 Otherwise the scheduler should remove us from the CPU if we make no
22 progress.
23
24 Cc: stable-rt@vger.kernel.org
25 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
26 Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
27 ---
28  fs/dcache.c | 19 +++++++++++++------
29  1 file changed, 13 insertions(+), 6 deletions(-)
30
31 diff --git a/fs/dcache.c b/fs/dcache.c
32 index 2ee5a8e6..e8d9522 100644
33 --- a/fs/dcache.c
34 +++ b/fs/dcache.c
35 @@ -40,6 +40,8 @@
36  #include <linux/ratelimit.h>
37  #include <linux/list_lru.h>
38  #include <linux/kasan.h>
39 +#include <linux/sched/rt.h>
40 +#include <linux/sched/deadline.h>
41  
42  #include "internal.h"
43  #include "mount.h"
44 @@ -748,6 +750,8 @@ static inline bool fast_dput(struct dentry *dentry)
45   */
46  void dput(struct dentry *dentry)
47  {
48 +       struct dentry *parent;
49 +
50         if (unlikely(!dentry))
51                 return;
52  
53 @@ -784,14 +788,17 @@ repeat:
54         return;
55  
56  kill_it:
57 -       dentry = dentry_kill(dentry);
58 -       if (dentry) {
59 +       parent = dentry_kill(dentry);
60 +       if (parent) {
61                 int r;
62  
63 -               /* the task with the highest priority won't schedule */
64 -               r = cond_resched();
65 -               if (!r)
66 -                       cpu_chill();
67 +               if (parent == dentry) {
68 +                       /* the task with the highest priority won't schedule */
69 +                       r = cond_resched();
70 +                       if (!r && (rt_task(current) || dl_task(current)))
71 +                               cpu_chill();
72 +               } else
73 +                       dentry = parent;
74                 goto repeat;
75         }
76  }
77 -- 
78 1.9.1
79