]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/dlm-don-t-swamp-the-cpu-with-callbacks-queued-during.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / dlm-don-t-swamp-the-cpu-with-callbacks-queued-during.patch
1 From 51f6e15573004ce9a32edcb5f2b19fa3fba8ca8e Mon Sep 17 00:00:00 2001
2 From: Bob Peterson <rpeterso@redhat.com>
3 Date: Thu, 8 Nov 2018 14:04:50 -0500
4 Subject: dlm: Don't swamp the CPU with callbacks queued during recovery
5
6 [ Upstream commit 216f0efd19b9cc32207934fd1b87a45f2c4c593e ]
7
8 Before this patch, recovery would cause all callbacks to be delayed,
9 put on a queue, and afterward they were all queued to the callback
10 work queue. This patch does the same thing, but occasionally takes
11 a break after 25 of them so it won't swamp the CPU at the expense
12 of other RT processes like corosync.
13
14 Signed-off-by: Bob Peterson <rpeterso@redhat.com>
15 Signed-off-by: David Teigland <teigland@redhat.com>
16 Signed-off-by: Sasha Levin <sashal@kernel.org>
17 ---
18 fs/dlm/ast.c | 10 ++++++++++
19 1 file changed, 10 insertions(+)
20
21 diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
22 index 07fed838d8fd..15fa4239ae9f 100644
23 --- a/fs/dlm/ast.c
24 +++ b/fs/dlm/ast.c
25 @@ -290,6 +290,8 @@ void dlm_callback_suspend(struct dlm_ls *ls)
26 flush_workqueue(ls->ls_callback_wq);
27 }
28
29 +#define MAX_CB_QUEUE 25
30 +
31 void dlm_callback_resume(struct dlm_ls *ls)
32 {
33 struct dlm_lkb *lkb, *safe;
34 @@ -300,15 +302,23 @@ void dlm_callback_resume(struct dlm_ls *ls)
35 if (!ls->ls_callback_wq)
36 return;
37
38 +more:
39 mutex_lock(&ls->ls_cb_mutex);
40 list_for_each_entry_safe(lkb, safe, &ls->ls_cb_delay, lkb_cb_list) {
41 list_del_init(&lkb->lkb_cb_list);
42 queue_work(ls->ls_callback_wq, &lkb->lkb_cb_work);
43 count++;
44 + if (count == MAX_CB_QUEUE)
45 + break;
46 }
47 mutex_unlock(&ls->ls_cb_mutex);
48
49 if (count)
50 log_rinfo(ls, "dlm_callback_resume %d", count);
51 + if (count == MAX_CB_QUEUE) {
52 + count = 0;
53 + cond_resched();
54 + goto more;
55 + }
56 }
57
58 --
59 2.19.1
60