From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Rostedt Subject: [PATCH RT 4/7] fs: dcache: Use cpu_chill() in trylock loops Date: Tue, 13 Mar 2012 22:27:02 -0400 Message-ID: <20120314022945.223176076@goodmis.org> References: <20120314022658.783312660@goodmis.org> Cc: Thomas Gleixner , Carsten Emde , John Kacur , stable-rt@vger.kernel.org To: linux-kernel@vger.kernel.org, linux-rt-users Return-path: Content-Disposition: inline; filename=0004-fs-dcache-Use-cpu_chill-in-trylock-loops.patch Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-rt-users.vger.kernel.org From: Thomas Gleixner Retry loops on RT might loop forever when the modifying side was preempted. Use cpu_chill() instead of cpu_relax() to let the system make progress. Signed-off-by: Thomas Gleixner Cc: stable-rt@vger.kernel.org Signed-off-by: Steven Rostedt --- fs/autofs4/autofs_i.h | 1 + fs/autofs4/expire.c | 2 +- fs/dcache.c | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h index b620114..83424ab 100644 --- a/fs/autofs4/autofs_i.h +++ b/fs/autofs4/autofs_i.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index d8b6184..f4abda3 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c @@ -170,7 +170,7 @@ again: parent = p->d_parent; if (!seq_spin_trylock(&parent->d_lock)) { seq_spin_unlock(&p->d_lock); - cpu_relax(); + cpu_chill(); goto relock; } seq_spin_unlock(&p->d_lock); diff --git a/fs/dcache.c b/fs/dcache.c index 10580be..eedf276 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "internal.h" /* @@ -360,7 +361,7 @@ static inline struct dentry *dentry_kill(struct dentry *dentry, int ref) if (inode && !spin_trylock(&inode->i_lock)) { relock: seq_spin_unlock(&dentry->d_lock); - cpu_relax(); + cpu_chill(); return dentry; /* try again with same dentry */ } if (IS_ROOT(dentry)) @@ -738,7 +739,7 @@ relock: if (!seq_spin_trylock(&dentry->d_lock)) { spin_unlock(&dcache_lru_lock); - cpu_relax(); + cpu_chill(); goto relock; } @@ -2053,7 +2054,7 @@ again: if (dentry->d_count == 1) { if (inode && !spin_trylock(&inode->i_lock)) { seq_spin_unlock(&dentry->d_lock); - cpu_relax(); + cpu_chill(); goto again; } dentry->d_flags &= ~DCACHE_CANT_MOUNT; -- 1.7.8.3