| Subject: fs: dcache: Use cpu_chill() in trylock loops | 
 | From: Thomas Gleixner <tglx@linutronix.de> | 
 | Date: Wed, 07 Mar 2012 21:00:34 +0100 | 
 |  | 
 | 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 <tglx@linutronix.de> | 
 | Cc: stable-rt@vger.kernel.org | 
 | --- | 
 |  fs/autofs4/autofs_i.h |    1 + | 
 |  fs/autofs4/expire.c   |    2 +- | 
 |  fs/dcache.c           |    7 ++++--- | 
 |  fs/namespace.c        |    3 ++- | 
 |  4 files changed, 8 insertions(+), 5 deletions(-) | 
 |  | 
 | Index: linux-stable/fs/autofs4/autofs_i.h | 
 | =================================================================== | 
 | --- linux-stable.orig/fs/autofs4/autofs_i.h | 
 | +++ linux-stable/fs/autofs4/autofs_i.h | 
 | @@ -34,6 +34,7 @@ | 
 |  #include <linux/sched.h> | 
 |  #include <linux/mount.h> | 
 |  #include <linux/namei.h> | 
 | +#include <linux/delay.h> | 
 |  #include <asm/current.h> | 
 |  #include <asm/uaccess.h> | 
 |   | 
 | Index: linux-stable/fs/autofs4/expire.c | 
 | =================================================================== | 
 | --- linux-stable.orig/fs/autofs4/expire.c | 
 | +++ linux-stable/fs/autofs4/expire.c | 
 | @@ -166,7 +166,7 @@ again: | 
 |  			parent = p->d_parent; | 
 |  			if (!spin_trylock(&parent->d_lock)) { | 
 |  				spin_unlock(&p->d_lock); | 
 | -				cpu_relax(); | 
 | +				cpu_chill(); | 
 |  				goto relock; | 
 |  			} | 
 |  			spin_unlock(&p->d_lock); | 
 | Index: linux-stable/fs/dcache.c | 
 | =================================================================== | 
 | --- linux-stable.orig/fs/dcache.c | 
 | +++ linux-stable/fs/dcache.c | 
 | @@ -37,6 +37,7 @@ | 
 |  #include <linux/rculist_bl.h> | 
 |  #include <linux/prefetch.h> | 
 |  #include <linux/ratelimit.h> | 
 | +#include <linux/delay.h> | 
 |  #include "internal.h" | 
 |  #include "mount.h" | 
 |   | 
 | @@ -488,7 +489,7 @@ static inline struct dentry *dentry_kill | 
 |  	if (inode && !spin_trylock(&inode->i_lock)) { | 
 |  relock: | 
 |  		spin_unlock(&dentry->d_lock); | 
 | -		cpu_relax(); | 
 | +		cpu_chill(); | 
 |  		return dentry; /* try again with same dentry */ | 
 |  	} | 
 |  	if (IS_ROOT(dentry)) | 
 | @@ -876,7 +877,7 @@ relock: | 
 |   | 
 |  		if (!spin_trylock(&dentry->d_lock)) { | 
 |  			spin_unlock(&dcache_lru_lock); | 
 | -			cpu_relax(); | 
 | +			cpu_chill(); | 
 |  			goto relock; | 
 |  		} | 
 |   | 
 | @@ -2115,7 +2116,7 @@ again: | 
 |  	if (dentry->d_count == 1) { | 
 |  		if (inode && !spin_trylock(&inode->i_lock)) { | 
 |  			spin_unlock(&dentry->d_lock); | 
 | -			cpu_relax(); | 
 | +			cpu_chill(); | 
 |  			goto again; | 
 |  		} | 
 |  		dentry->d_flags &= ~DCACHE_CANT_MOUNT; | 
 | Index: linux-stable/fs/namespace.c | 
 | =================================================================== | 
 | --- linux-stable.orig/fs/namespace.c | 
 | +++ linux-stable/fs/namespace.c | 
 | @@ -20,6 +20,7 @@ | 
 |  #include <linux/fs_struct.h>	/* get_fs_root et.al. */ | 
 |  #include <linux/fsnotify.h>	/* fsnotify_vfsmount_delete */ | 
 |  #include <linux/uaccess.h> | 
 | +#include <linux/delay.h> | 
 |  #include "pnode.h" | 
 |  #include "internal.h" | 
 |   | 
 | @@ -313,7 +314,7 @@ int __mnt_want_write(struct vfsmount *m) | 
 |  	smp_mb(); | 
 |  	while (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) { | 
 |  		preempt_enable(); | 
 | -		cpu_relax(); | 
 | +		cpu_chill(); | 
 |  		preempt_disable(); | 
 |  	} | 
 |  	/* |