diff mbox series

[9/9] fsnotify: pass inode to fsnotify_parent()

Message ID 20200722125849.17418-10-amir73il@gmail.com
State New
Headers show
Series Fixes for fanotify name events | expand

Commit Message

Amir Goldstein July 22, 2020, 12:58 p.m. UTC
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@intel.com>
Fixes: c738fbabb0ff ("fsnotify: fold fsnotify() call into fsnotify_parent()")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 include/linux/fsnotify.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Jan Kara July 27, 2020, 9:29 p.m. UTC | #1
On Wed 22-07-20 15:58:49, Amir Goldstein wrote:
> 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@intel.com>
> Fixes: c738fbabb0ff ("fsnotify: fold fsnotify() call into fsnotify_parent()")
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

I didn't take this patch because honestly, I don't think the extra argument
is worth it unless we can prove real performance benefit...

								Honza

> ---
>  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 d9b26c6552ee..4a9b2f5b819b 100644
> --- a/include/linux/fsnotify.h
> +++ b/include/linux/fsnotify.h
> @@ -49,10 +49,9 @@ static inline void fsnotify_inode(struct inode *inode, __u32 mask)
>  
>  /* 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;
>  
> @@ -77,7 +76,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)
> @@ -87,7 +87,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
>
diff mbox series

Patch

diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index d9b26c6552ee..4a9b2f5b819b 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -49,10 +49,9 @@  static inline void fsnotify_inode(struct inode *inode, __u32 mask)
 
 /* 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;
 
@@ -77,7 +76,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)
@@ -87,7 +87,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 */