Re: [fsnotify] c738fbabb0: will-it-scale.per_process_ops -9.5% regression

From: Amir Goldstein
Date: Tue Jul 21 2020 - 11:59:46 EST


On Tue, Jul 21, 2020 at 3:15 AM kernel test robot <rong.a.chen@xxxxxxxxx> wrote:
>
> Greeting,
>
> FYI, we noticed a -9.5% regression of will-it-scale.per_process_ops due to commit:
>
>
> commit: c738fbabb0ff62d0f9a9572e56e65d05a1b34c6a ("fsnotify: fold fsnotify() call into fsnotify_parent()")

Strange, that's a pretty dumb patch moving some inlined code from one
function to
another (assuming there are no fsnotify marks in this test).

Unless I am missing something the only thing that changes slightly is
an extra d_inode(file->f_path.dentry) deference.
I can get rid of it.

Is it possible to ask for a re-test with fix patch (attached)?

Thanks,
Amir.
From 26dc3d2bff623768cbbd0c8053ddd6390fd828d2 Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@xxxxxxxxx>
Date: Tue, 21 Jul 2020 18:52:18 +0300
Subject: [PATCH] fsnotify: pass inode to fsnotify_parent()

We can get inode by dereferenceing dentry->d_inode, but that may have
performance impact in the fast path of non watched file.

Kernel test robot reported a performance regression in concurrent open
workload, so maybe that can fix it.

Reported-by: kernel test robot <rong.a.chen@xxxxxxxxx>
Fixes: c738fbabb0ff ("fsnotify: fold fsnotify() call into fsnotify_parent()")
Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
include/linux/fsnotify.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 316c9b820517..d49e5318aad9 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -46,10 +46,9 @@ static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,

/* Notify this dentry's parent about a child's events. */
static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
- const void *data, int data_type)
+ const void *data, int data_type,
+ struct inode *inode)
{
- struct inode *inode = d_inode(dentry);
-
if (S_ISDIR(inode->i_mode))
mask |= FS_ISDIR;

@@ -68,7 +67,8 @@ static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
*/
static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask)
{
- fsnotify_parent(dentry, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE);
+ fsnotify_parent(dentry, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
+ d_inode(dentry));
}

static inline int fsnotify_file(struct file *file, __u32 mask)
@@ -78,7 +78,8 @@ static inline int fsnotify_file(struct file *file, __u32 mask)
if (file->f_mode & FMODE_NONOTIFY)
return 0;

- return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
+ return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH,
+ file_inode(file));
}

/* Simple call site for access decisions */
--
2.17.1