From: Petr Mladek <pmladek@suse.cz>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>, Tejun Heo <tj@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
linux-mtd@lists.infradead.org,
Trond Myklebust <trond.myklebust@primarydata.com>,
Anna Schumaker <anna.schumaker@netapp.com>,
linux-nfs@vger.kernel.org, Chris Mason <clm@fb.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Kosina <jkosina@suse.cz>, Borislav Petkov <bp@suse.de>,
Michal Hocko <mhocko@suse.cz>,
live-patching@vger.kernel.org, linux-api@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 15/18] ring_buffer: Allow to exit the ring buffer benchmark immediately
Date: Mon, 15 Jun 2015 17:54:28 +0200 [thread overview]
Message-ID: <20150615155428.GD3135@pathway.suse.cz> (raw)
In-Reply-To: <20150615113343.215bcd43@gandalf.local.home>
On Mon 2015-06-15 11:33:43, Steven Rostedt wrote:
> On Mon, 15 Jun 2015 17:23:13 +0200
> Petr Mladek <pmladek@suse.cz> wrote:
>
>
> > Please, find below a version of the patch that can be applied against
> > current Linus tree and also against your for-next branch.
> >
>
> Thanks, just on Friday, I was testing ring buffer changes with the
> ringbuffer benchmark, and was bitching about how I had to wait the 10
> seconds before the module would unload ;-)
I am glad that it will be useful.
Please, find below a version with a small typo fix. Heh, I spent a lot
of time with doulbe checking the patch and then decided to do a last
minute change. It produced "only" compilation warning that I missed.
It was not visible with my testing :-(
>From 0049043e740c22bddc4306e448a015a9b8450825 Mon Sep 17 00:00:00 2001
From: Petr Mladek <pmladek@suse.cz>
Date: Mon, 15 Jun 2015 15:53:10 +0200
Subject: [PATCH] ring_buffer: Allow to exit the ring buffer benchmark
immediately
It takes a while until the ring_buffer_benchmark module is removed
when the ring buffer hammer is running. It is because it takes
few seconds and kthread_should_stop() is not being checked.
This patch adds the check for kthread termination into the producer.
It uses the existing @kill_test flag to finish the kthreads as
cleanly as possible.
It disables printing the "ERROR" message when the kthread is going.
It makes sure that producer does not go into the 10sec sleep
when it is being killed.
Finally, it does not call wait_to_die() when kthread_should_stop()
already returns true.
Signed-off-by: Petr Mladek <pmladek@suse.cz>
---
kernel/trace/ring_buffer_benchmark.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index 1b28df2d9104..c17f9c8d4908 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -263,6 +263,8 @@ static void ring_buffer_producer(void)
if (cnt % wakeup_interval)
cond_resched();
#endif
+ if (kthread_should_stop())
+ kill_test = 1;
} while (ktime_before(end_time, timeout) && !kill_test);
trace_printk("End ring buffer hammer\n");
@@ -285,7 +287,7 @@ static void ring_buffer_producer(void)
entries = ring_buffer_entries(buffer);
overruns = ring_buffer_overruns(buffer);
- if (kill_test)
+ if (kill_test && !kthread_should_stop())
trace_printk("ERROR!\n");
if (!disable_reader) {
@@ -379,7 +381,7 @@ static int ring_buffer_consumer_thread(void *arg)
}
__set_current_state(TASK_RUNNING);
- if (kill_test)
+ if (!kthread_should_stop())
wait_to_die();
return 0;
@@ -399,13 +401,16 @@ static int ring_buffer_producer_thread(void *arg)
}
ring_buffer_producer();
+ if (kill_test)
+ goto out_kill;
trace_printk("Sleeping for 10 secs\n");
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ * SLEEP_TIME);
}
- if (kill_test)
+out_kill:
+ if (!kthread_should_stop())
wait_to_die();
return 0;
--
1.8.5.6
next prev parent reply other threads:[~2015-06-15 15:54 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 15:00 [RFC PATCH 00/18] kthreads/signal: Safer kthread API and signal handling Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 01/18] kthread: Allow to call __kthread_create_on_node() with va_list args Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 03/18] kthread: Add kthread_stop_current() Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 04/18] signal: Rename kernel_sigaction() to kthread_sigaction() and clean it up Petr Mladek
[not found] ` <1433516477-5153-1-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-05 15:01 ` [RFC PATCH 02/18] kthread: Add API for iterant kthreads Petr Mladek
[not found] ` <1433516477-5153-3-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-09 6:23 ` Tejun Heo
[not found] ` <20150609062349.GW21465-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-15 12:46 ` Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 05/18] freezer/scheduler: Add freezable_cond_resched() Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 06/18] signal/kthread: Initial implementation of kthread signal handling Petr Mladek
[not found] ` <1433516477-5153-7-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-06 21:58 ` Oleg Nesterov
[not found] ` <20150606215816.GB15591-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-08 13:51 ` Petr Mladek
[not found] ` <20150608135107.GB3135-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-08 21:13 ` Oleg Nesterov
[not found] ` <20150608211336.GB24869-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-15 13:13 ` Petr Mladek
[not found] ` <20150615131341.GN9409-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-15 19:14 ` Oleg Nesterov
[not found] ` <20150615191429.GA29727-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-16 7:54 ` Petr Mladek
2015-06-09 7:10 ` Tejun Heo
[not found] ` <20150609071022.GX21465-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-09 12:15 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1506091405360.12753-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-06-10 3:13 ` Tejun Heo
2015-06-05 15:01 ` [RFC PATCH 08/18] kthread: Allow to get struct kthread_iterant from task_struct Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 12/18] lockd: Convert the central lockd service to kthread_iterant API Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 15/18] ring_buffer: Allow to exit the ring buffer benchmark immediately Petr Mladek
[not found] ` <1433516477-5153-16-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-08 17:44 ` Steven Rostedt
[not found] ` <20150608134417.3fb7a811-f9ZlEuEWxVcJvu8Pb33WZ0EMvNT87kid@public.gmane.org>
2015-06-15 15:23 ` Petr Mladek
[not found] ` <20150615152313.GC3135-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-15 15:33 ` Steven Rostedt
2015-06-15 15:54 ` Petr Mladek [this message]
2015-06-05 15:01 ` [RFC PATCH 17/18] ring_buffer: Use the new API for a sleep with a timeout in the benchmark Petr Mladek
2015-06-09 6:10 ` [RFC PATCH 00/18] kthreads/signal: Safer kthread API and signal handling Tejun Heo
[not found] ` <20150609061025.GU21465-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-09 7:58 ` Tejun Heo
2015-06-17 11:34 ` Christoph Hellwig
2015-06-05 15:01 ` [RFC PATCH 07/18] kthread: Make iterant kthreads freezable by default Petr Mladek
[not found] ` <1433516477-5153-8-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-09 7:20 ` Tejun Heo
[not found] ` <20150609072003.GY21465-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-09 15:53 ` Petr Mladek
[not found] ` <20150609155313.GC9409-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-10 4:31 ` Tejun Heo
[not found] ` <20150610043154.GG11955-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-12 13:24 ` Petr Mladek
[not found] ` <20150612132440.GH9409-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-13 23:22 ` Tejun Heo
[not found] ` <20150613232222.GB346-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-15 9:28 ` Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 09/18] kthread: Make it easier to correctly sleep in iterant kthreads Petr Mladek
[not found] ` <1433516477-5153-10-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-05 16:10 ` Peter Zijlstra
[not found] ` <20150605161021.GJ19282-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2015-06-08 10:01 ` Petr Mladek
2015-06-08 11:39 ` Peter Zijlstra
2015-06-09 15:25 ` Petr Mladek
[not found] ` <20150609152526.GB9409-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-10 9:05 ` Peter Zijlstra
[not found] ` <20150608100107.GA3135-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-06-09 7:32 ` Tejun Heo
2015-06-08 17:48 ` Steven Rostedt
[not found] ` <20150608134810.3abd862b-f9ZlEuEWxVcJvu8Pb33WZ0EMvNT87kid@public.gmane.org>
2015-06-10 9:07 ` Peter Zijlstra
2015-06-10 14:07 ` Steven Rostedt
[not found] ` <20150610100729.6a674c15-f9ZlEuEWxVcJvu8Pb33WZ0EMvNT87kid@public.gmane.org>
2015-06-11 4:28 ` Jiri Kosina
2015-06-05 15:01 ` [RFC PATCH 10/18] jffs2: Remove forward definition of jffs2_garbage_collect_thread() Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 11/18] jffs2: Convert jffs2_gcd_mtd kthread into the iterant API Petr Mladek
[not found] ` <1433516477-5153-12-git-send-email-pmladek-AlSwsSmVLrQ@public.gmane.org>
2015-06-06 21:16 ` Oleg Nesterov
[not found] ` <20150606211648.GA15591-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-06 21:32 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1506062322550.12753-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-06-06 22:30 ` Oleg Nesterov
[not found] ` <20150606223001.GA18838-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-06 22:44 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1506070034100.12753-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-06-06 22:58 ` Oleg Nesterov
2015-06-05 15:01 ` [RFC PATCH 13/18] ring_buffer: Use iterant kthreads API in the ring buffer benchmark Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 14/18] ring_buffer: Allow to cleanly freeze the ring buffer benchmark kthreads Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 16/18] kthread: Support interruptible sleep with a timeout by iterant kthreads Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 18/18] jffs2: Use the new API for a sleep with a timeout Petr Mladek
2015-06-05 16:22 ` [RFC PATCH 00/18] kthreads/signal: Safer kthread API and signal handling Peter Zijlstra
[not found] ` <20150605162216.GK19282-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2015-06-09 6:14 ` Tejun Heo
[not found] ` <20150609061446.GV21465-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-06-10 10:40 ` Peter Zijlstra
[not found] ` <20150610104057.GE3644-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2015-06-11 22:02 ` Tejun Heo
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=20150615155428.GD3135@pathway.suse.cz \
--to=pmladek@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=anna.schumaker@netapp.com \
--cc=bp@suse.de \
--cc=clm@fb.com \
--cc=dwmw2@infradead.org \
--cc=jkosina@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mhocko@suse.cz \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=richard@nod.at \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=trond.myklebust@primarydata.com \
/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).