Skip to content

Fsnotify ignored mask related fixes

Amir Goldstein linux-fsdevel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 1 replyIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2fsnotify: fix merge with parent's ignored maskfs/notify/fanotify/fanotify_user.c fs/notify/mark.c include/linux/fsnotify_backend.h+26 -100 replies
2/2fsnotify: optimize FS_MODIFY events with no ignored masksfs/notify/fanotify/fanotify_user.c fs/notify/fsnotify.c include/linux/fsnotify_backend.h+34 -100 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH v2 0/2] Fsnotify ignored mask related fixes

Jan,

The two patches are functionally unrelated, but they both incorporate information from the ignored mask into the object's interest mask.

The 1st patch is a fix for a minor functional bug. LTP test fanotify10 has a workaround for this bug, see comment:
/* XXX: temporary hack may be removed in the future */
The test is to remove the hack and see that fanotify10 passes.

The 2nd patch is a performance optimization that you suggested. Last time I posted it, you asked for performance numbers [1], so I ran some micro benchmarks (see results below [3]).

Note that the other patch from that first posting ("optimize merging of marks with no ignored masks") did not demonstrate any visible improvements with the benchmarks that I ran so I left it out.

The micro benchmark is a simple program [2] that writes 1 byte at a time in a loop. I ran it on tmpfs once without any mark and once with a mark with a mask for DELETE_SELF event.

On upstream kernel, runtime with a mark is always ~25% longer. With the optimization patch applied, runtime with a mark is most of the time (but not always) very close to the runtime without a mark.

[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
[2] https://github.com/amir73il/fsnotify-utils/blob/master/src/test/ioloop.c
[3] Performance test results:

$ time ./ioloop /tmp/foo 10000000 w
$ inotifywait -e delete_self /tmp/foo &
$ time ./ioloop /tmp/foo 10000000 w
$ rm /tmp/foo

5.17.0-rc2 #1
-------------
ioloop count=10000000 op=write

real 0m24.264s
user 0m3.977s
sys 0m20.278s

Setting up watches.
Watches established.
ioloop count=10000000 op=write

real 0m29.914s
user 0m3.929s
sys 0m25.974s

/tmp/foo DELETE_SELF

5.17.0-rc2 #2
-------------
ioloop count=10000000 op=write

real 0m26.836s
user 0m4.212s
sys 0m22.615s

Setting up watches.
Watches established.
ioloop count=10000000 op=write

real 0m30.206s
user 0m4.110s
sys 0m26.090s

/tmp/foo DELETE_SELF

5.17.0-rc2 #3
-------------
ioloop count=10000000 op=write

real 0m25.359s
user 0m4.386s
sys 0m20.945s

Setting up watches.
Watches established.
ioloop count=10000000 op=write

real 0m30.213s
user 0m4.187s
sys 0m26.020s

/tmp/foo DELETE_SELF

fsnotify-ignored #1
-------------------
ioloop count=10000000 op=write

real 0m25.020s
user 0m3.982s
sys 0m21.028s

Setting up watches.
Watches established.
ioloop count=10000000 op=write

real 0m26.084s
user 0m4.266s
sys 0m21.812s

/tmp/foo DELETE_SELF

fsnotify-ignored #2
-------------------
ioloop count=10000000 op=write

real 0m24.642s
user 0m3.945s
sys 0m20.677s

Setting up watches.
Watches established.
ioloop count=10000000 op=write

real 0m25.790s
user 0m4.209s
sys 0m21.572s

/tmp/foo DELETE_SELF

fsnotify-ignored #3
-------------------
ioloop count=10000000 op=write

real 0m25.233s
user 0m4.315s
sys 0m20.906s

Setting up watches.
Watches established.
ioloop count=10000000 op=write

real 0m28.800s
user 0m4.329s
sys 0m24.462s

/tmp/foo DELETE_SELF

Amir Goldstein (2):
fsnotify: fix merge with parent's ignored mask
fsnotify: optimize FS_MODIFY events with no ignored masks

 fs/notify/fanotify/fanotify_user.c | 47 +++++++++++++++++++++---------
 fs/notify/fsnotify.c               |  8 +++--
 fs/notify/mark.c                   |  4 +--
 include/linux/fsnotify_backend.h   | 19 ++++++++++++
 4 files changed, 59 insertions(+), 19 deletions(-)
Signature · 1 line
2.25.1