From: Vaibhav Nagarnaik <vnagarnaik@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org,
Vaibhav Nagarnaik <vnagarnaik@google.com>,
jbehmer@google.com
Subject: [PATCH] ring-buffer: Allow for rescheduling when removing pages
Date: Fri, 7 Sep 2018 11:21:31 -0700 [thread overview]
Message-ID: <20180907182131.144514-1-vnagarnaik@google.com> (raw)
When reducing ring buffer size, pages are removed by scheduling a work
item on each CPU for the corresponding CPU ring buffer. After the pages
are removed from ring buffer linked list, the pages are free()d in a
tight loop. The loop does not give up CPU until all pages are removed.
In a worst case behavior, when lot of pages are to be freed, it can
cause system stall.
After the pages are removed from the list, the free() can happen while
the work is rescheduled. Add a check for need_sched() within the loop
to prevent the system hangup.
Reported-by: Jason Behmer <jbehmer@google.com>
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
---
kernel/trace/ring_buffer.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 1d92d4a982fd..bc1789df7c53 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1546,6 +1546,9 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned long nr_pages)
tmp_iter_page = first_page;
do {
+ if (need_resched())
+ schedule();
+
to_remove_page = tmp_iter_page;
rb_inc_page(cpu_buffer, &tmp_iter_page);
--
2.19.0.rc2.392.g5ba43deb5a-goog
next reply other threads:[~2018-09-07 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 18:21 Vaibhav Nagarnaik [this message]
2018-09-07 18:30 ` Steven Rostedt
2018-09-07 19:28 ` Vaibhav Nagarnaik
2018-09-07 22:31 ` Vaibhav Nagarnaik
2018-09-17 20:53 ` Vaibhav Nagarnaik
2018-09-17 21:00 ` Steven Rostedt
2018-09-17 21:02 ` Vaibhav Nagarnaik
2018-09-17 21:36 ` Steven Rostedt
2018-09-17 21:42 ` Vaibhav Nagarnaik
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=20180907182131.144514-1-vnagarnaik@google.com \
--to=vnagarnaik@google.com \
--cc=jbehmer@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®