__fsnotify_parent() has an optimization in place to avoid unneeded take_dentry_name_snapshot(). When fsnotify_nameremove() was changed not to call __fsnotify_parent(), we left out the optimization. Kernel test robot reported a 5% performance regression in concurrent unlink() workload. Reported-by: kernel test robot <rong.a.chen@xxxxxxxxx> Link: https://lore.kernel.org/lkml/20190505062153.GG29809@shao2-debian/ Link: https://lore.kernel.org/linux-fsdevel/20190104090357.GD22409@xxxxxxxxxxxxxx/ Fixes: 5f02a8776384 ("fsnotify: annotate directory entry modification events") Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> --- Jan, The linked 5.1-rc1 performance regression report came with bad timing. Not sure if Linus is planning an rc8. If not, you will probably not see this before the 5.1 release and we shall have to queue it for 5.2 and backport to stable 5.1. I crafted the patch so it applies cleanly both to master and Al's for-next branch (there are some fsnotify changes in work.dcache). Thanks, Amir. include/linux/fsnotify.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 09587e2860b5..2272c8c2023c 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -175,12 +175,19 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) mask |= FS_ISDIR; parent = dget_parent(dentry); + /* Avoid unneeded take_dentry_name_snapshot() */ + if (!(d_inode(parent)->i_fsnotify_mask & FS_DELETE) && + !(dentry->d_sb->s_fsnotify_mask & FS_DELETE)) + goto out_dput; + take_dentry_name_snapshot(&name, dentry); fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, name.name, 0); release_dentry_name_snapshot(&name); + +out_dput: dput(parent); } -- 2.17.1