lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220331190827.48241-2-stephen.s.brennan@oracle.com>
Date:   Thu, 31 Mar 2022 12:08:26 -0700
From:   Stephen Brennan <stephen.s.brennan@...cle.com>
To:     Alexander Viro <viro@...iv.linux.org.uk>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Luis Chamberlain <mcgrof@...nel.org>,
        Stephen Brennan <stephen.s.brennan@...cle.com>,
        Arnd Bergmann <arnd@...db.de>,
        Matthew Wilcox <willy@...radead.org>,
        James Bottomley <James.Bottomley@...senPartnership.com>,
        Gao Xiang <hsiangkao@...ux.alibaba.com>,
        Dave Chinner <david@...morbit.com>,
        Roman Gushchin <roman.gushchin@...ux.dev>,
        Colin Walters <walters@...bum.org>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/2] fs/dcache: make cond_resched in __dentry_kill optional

Some callers of __dentry_kill may be killing single dentries, where a
cond_resched is not strictly necessary (and may result in undesirable
sleeps). Add a check_resched flag so the caller may request that we
do not call cond_resched().

Signed-off-by: Stephen Brennan <stephen.s.brennan@...cle.com>
---
 fs/dcache.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 93f4f5ee07bf..b1480433ddc5 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -575,7 +575,7 @@ static inline void dentry_unlist(struct dentry *dentry, struct dentry *parent)
 	}
 }
 
-static void __dentry_kill(struct dentry *dentry)
+static void __dentry_kill(struct dentry *dentry, bool check_resched)
 {
 	struct dentry *parent = NULL;
 	bool can_free = true;
@@ -619,7 +619,8 @@ static void __dentry_kill(struct dentry *dentry)
 	spin_unlock(&dentry->d_lock);
 	if (likely(can_free))
 		dentry_free(dentry);
-	cond_resched();
+	if (check_resched)
+		cond_resched();
 }
 
 static struct dentry *__lock_parent(struct dentry *dentry)
@@ -730,7 +731,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
 			goto slow_positive;
 		}
 	}
-	__dentry_kill(dentry);
+	__dentry_kill(dentry, true);
 	return parent;
 
 slow_positive:
@@ -742,7 +743,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
 	if (unlikely(dentry->d_lockref.count != 1)) {
 		dentry->d_lockref.count--;
 	} else if (likely(!retain_dentry(dentry))) {
-		__dentry_kill(dentry);
+		__dentry_kill(dentry, true);
 		return parent;
 	}
 	/* we are keeping it, after all */
@@ -1109,7 +1110,7 @@ void d_prune_aliases(struct inode *inode)
 		if (!dentry->d_lockref.count) {
 			struct dentry *parent = lock_parent(dentry);
 			if (likely(!dentry->d_lockref.count)) {
-				__dentry_kill(dentry);
+				__dentry_kill(dentry, true);
 				dput(parent);
 				goto restart;
 			}
@@ -1198,7 +1199,7 @@ void shrink_dentry_list(struct list_head *list)
 		parent = dentry->d_parent;
 		if (parent != dentry)
 			__dput_to_list(parent, list);
-		__dentry_kill(dentry);
+		__dentry_kill(dentry, true);
 	}
 }
 
@@ -1645,7 +1646,7 @@ void shrink_dcache_parent(struct dentry *parent)
 				parent = data.victim->d_parent;
 				if (parent != data.victim)
 					__dput_to_list(parent, &data.dispose);
-				__dentry_kill(data.victim);
+				__dentry_kill(data.victim, true);
 			}
 		}
 		if (!list_empty(&data.dispose))
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ