From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 0/7] Performance improvement for fanotify merge
Date: Tue, 2 Feb 2021 18:20:03 +0200 [thread overview]
Message-ID: <20210202162010.305971-1-amir73il@gmail.com> (raw)
Jan,
fanotify_merge() has been observed [1] to consume a lot of CPU.
This is not surprising considering that it is implemented as a linear
search on a practically unbounded size list.
The following series improves the linear search for an event to merge
in three different ways:
1. Hash events into as much as to 128 lists
2. Limit linear search to 128 last list elements
3. Use a better key - instead of victim inode ptr, use a hash of all
the compared fields
The end result can be observed in the test run times below.
The test is an extension of your queue overflow LTP test [2].
The timing results use are from the 2nd run of -i 2, where files
are already existing in the test fs.
With an unlimited queue, queueing of 16385 events on unique objects
is ~3 times faster than before the change.
In fact, the run time of queueing 16385 events (~600ms) is almost the
same as the run time of rejecting 16385 events (~550ms) due to full
queue, which suggest a very low overhead for merging events.
The test runs two passes to test event merge, the "create" pass and
the "open" pass.
Before the change (v5.11-rc2) 100% of the events of the "open" pass
are merged (16385 files and 16385 events).
After the change, only %50 of the events of the "open" pass are
merged (16385 files and 25462 events).
This is because 16384 is the maximum number of events that we can
merge when hash table is fully balanced.
When reducing the number of unique objects to 8192, all events
on the "open" pass are merged.
Thanks,
Amir.
v5.11-rc2, run #2 of ./fanotify05 -i 2:
fanotify05.c:109: TINFO: Test #0: Limited queue
fanotify05.c:98: TINFO: Created 16385 files in 1653ms
fanotify05.c:98: TINFO: Opened 16385 files in 543ms
fanotify05.c:77: TINFO: Got event #0 filename=fname_0
fanotify05.c:176: TPASS: Got an overflow event: pid=0 fd=-1
fanotify05.c:182: TINFO: Got 16385 events
fanotify05.c:109: TINFO: Test #1: Unlimited queue
fanotify05.c:98: TINFO: Created 16385 files in 1683ms
fanotify05.c:98: TINFO: Opened 16385 files in 1647ms
fanotify05.c:77: TINFO: Got event #0 filename=fname_0
fanotify05.c:138: TPASS: Overflow event not generated!
fanotify05.c:182: TINFO: Got 16385 events
fanotify_merge branch, run #2 of ./fanotify05 -i 2:
fanotify05.c:109: TINFO: Test #0: Limited queue
fanotify05.c:98: TINFO: Created 16385 files in 616ms
fanotify05.c:98: TINFO: Opened 16385 files in 549ms
fanotify05.c:77: TINFO: Got event #0 filename=fname_0
fanotify05.c:176: TPASS: Got an overflow event: pid=0 fd=-1
fanotify05.c:182: TINFO: Got 16385 events
fanotify05.c:109: TINFO: Test #1: Unlimited queue
fanotify05.c:98: TINFO: Created 16385 files in 614ms
fanotify05.c:98: TINFO: Opened 16385 files in 599ms
fanotify05.c:77: TINFO: Got event #0 filename=fname_0
fanotify05.c:138: TPASS: Overflow event not generated!
fanotify05.c:182: TINFO: Got 25462 events
[1] https://lore.kernel.org/linux-fsdevel/20200714025417.A25EB95C0339@us180.sjc.aristanetworks.com/
[2] https://github.com/amir73il/ltp/commits/fanotify_merge
Amir Goldstein (7):
fsnotify: allow fsnotify_{peek,remove}_first_event with empty queue
fsnotify: support hashed notification queue
fsnotify: read events from hashed notification queue by order of
insertion
fanotify: enable hashed notification queue for FAN_CLASS_NOTIF groups
fanotify: limit number of event merge attempts
fanotify: mix event info into merge key hash
fsnotify: print some debug stats on hashed queue overflow
fs/notify/fanotify/fanotify.c | 40 ++++++-
fs/notify/fanotify/fanotify.h | 24 +++-
fs/notify/fanotify/fanotify_user.c | 55 ++++++---
fs/notify/group.c | 37 ++++--
fs/notify/inotify/inotify_user.c | 22 ++--
fs/notify/notification.c | 175 +++++++++++++++++++++++++----
include/linux/fsnotify_backend.h | 105 +++++++++++++++--
7 files changed, 383 insertions(+), 75 deletions(-)
--
2.25.1
next reply other threads:[~2021-02-02 16:28 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 16:20 Amir Goldstein [this message]
2021-02-02 16:20 ` [PATCH 1/7] fsnotify: allow fsnotify_{peek,remove}_first_event with empty queue Amir Goldstein
2021-02-02 16:20 ` [PATCH 2/7] fsnotify: support hashed notification queue Amir Goldstein
2021-02-16 15:02 ` Jan Kara
2021-02-17 12:33 ` Amir Goldstein
2021-02-17 13:48 ` Jan Kara
2021-02-17 15:42 ` Amir Goldstein
2021-02-17 16:49 ` Jan Kara
2021-02-18 10:52 ` Amir Goldstein
2021-02-02 16:20 ` [PATCH 3/7] fsnotify: read events from hashed notification queue by order of insertion Amir Goldstein
2021-02-16 15:10 ` Jan Kara
2021-02-02 16:20 ` [PATCH 4/7] fanotify: enable hashed notification queue for FAN_CLASS_NOTIF groups Amir Goldstein
2021-02-02 16:20 ` [PATCH 5/7] fanotify: limit number of event merge attempts Amir Goldstein
2021-02-27 8:31 ` Amir Goldstein
2021-03-01 13:08 ` Jan Kara
2021-03-01 13:58 ` Amir Goldstein
2021-09-15 12:39 ` Amir Goldstein
2021-09-15 16:33 ` Jan Kara
2021-02-02 16:20 ` [PATCH 6/7] fanotify: mix event info into merge key hash Amir Goldstein
2021-02-16 15:39 ` Jan Kara
2021-02-17 10:13 ` Amir Goldstein
2021-02-18 10:46 ` Amir Goldstein
2021-02-18 11:11 ` Jan Kara
2021-02-18 12:17 ` Amir Goldstein
2021-02-02 16:20 ` [PATCH 7/7] fsnotify: print some debug stats on hashed queue overflow Amir Goldstein
2021-02-16 16:02 ` [PATCH 0/7] Performance improvement for fanotify merge Jan Kara
2021-02-17 10:52 ` Amir Goldstein
2021-02-17 11:25 ` Jan Kara
2021-02-18 10:56 ` Amir Goldstein
2021-02-18 11:15 ` Jan Kara
2021-02-18 12:35 ` Amir Goldstein
2021-02-19 10:15 ` Jan Kara
2021-02-19 10:21 ` Jan Kara
2021-02-19 13:38 ` Amir Goldstein
2021-02-21 12:53 ` Amir Goldstein
2021-02-22 9:29 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210202162010.305971-1-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).