Skip to content

fsnotify: Check parent watches without child dentry flags

Partha Sarathi Satapathy linux-fsdevel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1fsnotify: Check parent watches without child dentry flagsfs/dcache.c fs/notify/fsnotify.c fs/notify/fsnotify.h +4 more+29 -1520 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/1] fsnotify: Check parent watches without child dentry flags

This patch removes the cached-child dentry walk performed when a directory first starts watching child events. Instead, the event path takes a reference to the parent dentry and checks its child-watch mask. It also removes the DCACHE_FSNOTIFY_PARENT_WATCHED flag and its update sites.

On the test host, 12 million files were populated and their positive dentries were warmed before each run. With eight concurrent unlink/recreate workers and 100 sole-watch add/close cycles, inotify_add_watch() measured:

Before After

  run 1 average           107.420 ms            0.004 ms
  run 2 average           125.433 ms            0.004 ms
  run 1 maximum           122.811 ms            0.113 ms
  run 2 maximum           141.198 ms            0.095 ms

The displayed 0.004 ms averages are rounded to three decimal places. Maximum unlink/recreate latency was 777.852 and 770.569 ms before, versus 8.525 and 15.624 ms after. Those mutation maxima are supporting observations:
workers ran only during the watch-add loops, so the pre-change and post-change mutation measurement windows had very different lengths.

One 100,000-iteration, single-worker open/close event-path run per mode gave:

Before After

  none:   p50/p99 ns      9564 / 15703          9684 / 15023
          throughput      102221 ops/s          101432 ops/s
  other:  p50/p99 ns      9554 / 15573          9684 / 14962
          throughput       99442 ops/s          101497 ops/s

parent: p50/p99 ns 12529 / 19179 12499 / 17716
throughput 78196 ops/s 78655 ops/s

The 'other' mode watches a different directory on the same filesystem, so it exercises the superblock watcher path without target-file event delivery. These are single runs; they do not establish a small event-path cost or its absence. No open/close regression is apparent at this measurement resolution. The test used worker CPU 2 and listener CPU 4 on kernels 6.19.0-rc8.V_fsn0.el9.omm0.x86_64 and 6.19.0-rc8.fsn3.el9.omm3.x86_64, respectively. The test host reported XFS for its working directory.

The inotify correctness test and broader fsnotify functional test passed on both kernels. The fanotify permission subtest skipped with EPERM in both runs, so FAN_OPEN_PERM remains unvalidated by these results.

Partha Sarathi Satapathy (1):
fsnotify: Check parent watches without child dentry flags

 fs/dcache.c                      |  4 --
 fs/notify/fsnotify.c             | 99 ++++++++------------------------
 fs/notify/fsnotify.h             |  6 --
 fs/notify/mark.c                 | 35 -----------
 include/linux/dcache.h           |  1 -
 include/linux/fsnotify.h         |  7 +--
 include/linux/fsnotify_backend.h | 29 ++--------
 7 files changed, 29 insertions(+), 152 deletions(-)