From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-f193.google.com ([209.85.219.193]:40468 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725758AbeJEFBd (ORCPT ); Fri, 5 Oct 2018 01:01:33 -0400 Received: by mail-yb1-f193.google.com with SMTP id w7-v6so4608405ybm.7 for ; Thu, 04 Oct 2018 15:06:08 -0700 (PDT) MIME-Version: 1.0 References: <20181003212539.2384-1-amir73il@gmail.com> <20181003212539.2384-9-amir73il@gmail.com> <20181004090916.GC11529@quack2.suse.cz> <20181004112618.GB28384@quack2.suse.cz> In-Reply-To: <20181004112618.GB28384@quack2.suse.cz> From: Amir Goldstein Date: Fri, 5 Oct 2018 01:05:57 +0300 Message-ID: Subject: Re: [PATCH v3 8/8] fsnotify: optimize away srcu_read_lock() for events on directories To: Jan Kara Cc: linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Oct 4, 2018 at 2:26 PM Jan Kara wrote: > > On Thu 04-10-18 13:30:38, Amir Goldstein wrote: > > On Thu, Oct 4, 2018 at 12:09 PM Jan Kara wrote: > > > > > > On Thu 04-10-18 00:25:39, Amir Goldstein wrote: > > > > inotify and dnotify are always interested in events on directories. > > > > fanotify is interested in events on directories only if user requested > > > > them by flag FAN_ONDIR. > > > > > > > > For the fanotify supported events on directories (open/access/close), > > > > if there is no inotify/dnotify associated marks and if none of the > > > > associated fanotify marks have the FS_ISDIR flag, we can skip iterating > > > > the marks and we avoid taking the srcu_read_lock() for all events on > > > > directories. > > > > > > > > In order to enable this check in fsnotify() we set the FS_ISDIR flag > > > > explicitly on all dnotify/inotify marks. > > > > > > > > Signed-off-by: Amir Goldstein > > > > --- > > > > fs/notify/dnotify/dnotify.c | 5 +++-- > > > > fs/notify/fsnotify.c | 9 ++++++++- > > > > fs/notify/inotify/inotify_user.c | 4 ++-- > > > > 3 files changed, 13 insertions(+), 5 deletions(-) > > > > > > Looks good, except I think you forgot to convert kernel/audit_watch.c and > > > kernel/audit_fsnotify.c which also need to set FS_ISDIR... > > > > > > > Oops. Right. > > So would you rather I come back with a fixed version after I ran > > some performance tests? > > Or will you fix and test it yourself? > > Let's postpone this patch for a bit later. I'll merge the remaining seven > patches to my tree for this merge window. > For the records, On my small test system, I wasn't able to measure a difference in performance of parallel opendir/readdir/closedir workload (filebench listdirs) with and without a mount mark regardless of the optimization patch. Benchmark reports 40K~42K ops/sec for the compound op of "listdir". Perhaps more complex workloads that actually have SRCU sleeps would benefit from this optimization, but it doesn't look like avoiding the memory barrier alone moves the niddle. Not very surprising considering that readdir takes a shared lock anyway. So dropping the patch until further notice. Thanks, Amir.