From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Arnd Bergmann <arnd@arndb.de>,
Matthew Wilcox <willy@infradead.org>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Gao Xiang <hsiangkao@linux.alibaba.com>,
Dave Chinner <david@fromorbit.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Colin Walters <walters@verbum.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/2] fs/dcache: make cond_resched in __dentry_kill optional
Date: Thu, 31 Mar 2022 12:08:26 -0700 [thread overview]
Message-ID: <20220331190827.48241-2-stephen.s.brennan@oracle.com> (raw)
In-Reply-To: <20220331190827.48241-1-stephen.s.brennan@oracle.com>
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@oracle.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
next prev parent reply other threads:[~2022-03-31 19:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 19:08 [RFC PATCH 0/2] fs/dcache: Per directory amortized negative dentry pruning Stephen Brennan
2022-03-31 19:08 ` Stephen Brennan [this message]
2022-03-31 19:08 ` [RFC PATCH 2/2] fs/dcache: Add negative-dentry-ratio config Stephen Brennan
2022-03-31 19:45 ` Al Viro
2022-03-31 20:37 ` Stephen Brennan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220331190827.48241-2-stephen.s.brennan@oracle.com \
--to=stephen.s.brennan@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=david@fromorbit.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=walters@verbum.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®