]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0168-fs-dcache-Use-cpu_chill-in-trylock-loops.patch
Fix memguard and related syscalls
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0168-fs-dcache-Use-cpu_chill-in-trylock-loops.patch
1 From eb48fbfdea1555dbca8763fe221d42659b5f3113 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Wed, 7 Mar 2012 21:00:34 +0100
4 Subject: [PATCH 168/366] fs: dcache: Use cpu_chill() in trylock loops
5
6 Retry loops on RT might loop forever when the modifying side was
7 preempted. Use cpu_chill() instead of cpu_relax() to let the system
8 make progress.
9
10 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
11 ---
12  fs/autofs4/autofs_i.h |  1 +
13  fs/autofs4/expire.c   |  2 +-
14  fs/dcache.c           | 10 ++++++++--
15  fs/namespace.c        |  3 ++-
16  4 files changed, 12 insertions(+), 4 deletions(-)
17
18 diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
19 index 502d389..05af8d3 100644
20 --- a/fs/autofs4/autofs_i.h
21 +++ b/fs/autofs4/autofs_i.h
22 @@ -34,6 +34,7 @@
23  #include <linux/sched.h>
24  #include <linux/mount.h>
25  #include <linux/namei.h>
26 +#include <linux/delay.h>
27  #include <asm/current.h>
28  #include <asm/uaccess.h>
29  
30 diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
31 index 7a5a598..d08bcdc 100644
32 --- a/fs/autofs4/expire.c
33 +++ b/fs/autofs4/expire.c
34 @@ -150,7 +150,7 @@ again:
35                         parent = p->d_parent;
36                         if (!spin_trylock(&parent->d_lock)) {
37                                 spin_unlock(&p->d_lock);
38 -                               cpu_relax();
39 +                               cpu_chill();
40                                 goto relock;
41                         }
42                         spin_unlock(&p->d_lock);
43 diff --git a/fs/dcache.c b/fs/dcache.c
44 index 9e50999..2ee5a8e6 100644
45 --- a/fs/dcache.c
46 +++ b/fs/dcache.c
47 @@ -19,6 +19,7 @@
48  #include <linux/mm.h>
49  #include <linux/fs.h>
50  #include <linux/fsnotify.h>
51 +#include <linux/delay.h>
52  #include <linux/slab.h>
53  #include <linux/init.h>
54  #include <linux/hash.h>
55 @@ -785,7 +786,12 @@ repeat:
56  kill_it:
57         dentry = dentry_kill(dentry);
58         if (dentry) {
59 -               cond_resched();
60 +               int r;
61 +
62 +               /* the task with the highest priority won't schedule */
63 +               r = cond_resched();
64 +               if (!r)
65 +                       cpu_chill();
66                 goto repeat;
67         }
68  }
69 @@ -2394,7 +2400,7 @@ again:
70         if (dentry->d_lockref.count == 1) {
71                 if (!spin_trylock(&inode->i_lock)) {
72                         spin_unlock(&dentry->d_lock);
73 -                       cpu_relax();
74 +                       cpu_chill();
75                         goto again;
76                 }
77                 dentry->d_flags &= ~DCACHE_CANT_MOUNT;
78 diff --git a/fs/namespace.c b/fs/namespace.c
79 index 97f7f9f..1f3725b 100644
80 --- a/fs/namespace.c
81 +++ b/fs/namespace.c
82 @@ -14,6 +14,7 @@
83  #include <linux/mnt_namespace.h>
84  #include <linux/user_namespace.h>
85  #include <linux/namei.h>
86 +#include <linux/delay.h>
87  #include <linux/security.h>
88  #include <linux/idr.h>
89  #include <linux/init.h>                /* init_rootfs */
90 @@ -355,7 +356,7 @@ int __mnt_want_write(struct vfsmount *m)
91         smp_mb();
92         while (ACCESS_ONCE(mnt->mnt.mnt_flags) & MNT_WRITE_HOLD) {
93                 preempt_enable();
94 -               cpu_relax();
95 +               cpu_chill();
96                 preempt_disable();
97         }
98         /*
99 -- 
100 1.9.1
101