]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Sep 2021 14:03:50 +0000 (16:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Sep 2021 14:03:50 +0000 (16:03 +0200)
added patches:
fanotify-limit-number-of-event-merge-attempts.patch

queue-5.10/fanotify-limit-number-of-event-merge-attempts.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/fanotify-limit-number-of-event-merge-attempts.patch b/queue-5.10/fanotify-limit-number-of-event-merge-attempts.patch
new file mode 100644 (file)
index 0000000..2573646
--- /dev/null
@@ -0,0 +1,64 @@
+From b8cd0ee8cda68a888a317991c1e918a8cba1a568 Mon Sep 17 00:00:00 2001
+From: Amir Goldstein <amir73il@gmail.com>
+Date: Thu, 4 Mar 2021 12:48:26 +0200
+Subject: fanotify: limit number of event merge attempts
+
+From: Amir Goldstein <amir73il@gmail.com>
+
+commit b8cd0ee8cda68a888a317991c1e918a8cba1a568 upstream.
+
+Event merges are expensive when event queue size is large, so limit the
+linear search to 128 merge tests.
+
+[Stable backport notes] The following statement from upstream commit is
+irrelevant for backport:
+-
+-In combination with 128 size hash table, there is a potential to merge
+-with up to 16K events in the hashed queue.
+-
+[Stable backport notes] The problem is as old as fanotify and described
+in the linked cover letter "Performance improvement for fanotify merge".
+This backported patch fixes the performance issue at the cost of merging
+fewer potential events.  Fixing the performance issue is more important
+than preserving the "event merge" behavior, which was not predictable in
+any way that applications could rely on.
+
+Link: https://lore.kernel.org/r/20210304104826.3993892-6-amir73il@gmail.com
+Signed-off-by: Amir Goldstein <amir73il@gmail.com>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/linux-fsdevel/20210202162010.305971-1-amir73il@gmail.com/
+Link: https://lore.kernel.org/linux-fsdevel/20210915163334.GD6166@quack2.suse.cz/
+Signed-off-by: Amir Goldstein <amir73il@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/notify/fanotify/fanotify.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/fs/notify/fanotify/fanotify.c
++++ b/fs/notify/fanotify/fanotify.c
+@@ -129,11 +129,15 @@ static bool fanotify_should_merge(struct
+       return false;
+ }
++/* Limit event merges to limit CPU overhead per event */
++#define FANOTIFY_MAX_MERGE_EVENTS 128
++
+ /* and the list better be locked by something too! */
+ static int fanotify_merge(struct list_head *list, struct fsnotify_event *event)
+ {
+       struct fsnotify_event *test_event;
+       struct fanotify_event *new;
++      int i = 0;
+       pr_debug("%s: list=%p event=%p\n", __func__, list, event);
+       new = FANOTIFY_E(event);
+@@ -147,6 +151,8 @@ static int fanotify_merge(struct list_he
+               return 0;
+       list_for_each_entry_reverse(test_event, list, list) {
++              if (++i > FANOTIFY_MAX_MERGE_EVENTS)
++                      break;
+               if (fanotify_should_merge(test_event, event)) {
+                       FANOTIFY_E(test_event)->mask |= new->mask;
+                       return 1;
index b20a6a41e4ca262e7e709209d57958f5106323b1..2a7a9104aab9c4a1eda55c6d7957ba9b9ad4e98b 100644 (file)
@@ -305,3 +305,4 @@ drm-amd-display-update-bounding-box-states-v2.patch
 drm-panfrost-simplify-lock_region-calculation.patch
 drm-panfrost-use-u64-for-size-in-lock_region.patch
 drm-panfrost-clamp-lock-region-to-bifrost-minimum.patch
+fanotify-limit-number-of-event-merge-attempts.patch