Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755809AbbFOPXV (ORCPT ); Mon, 15 Jun 2015 11:23:21 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60227 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754246AbbFOPXR (ORCPT ); Mon, 15 Jun 2015 11:23:17 -0400 Date: Mon, 15 Jun 2015 17:23:13 +0200 From: Petr Mladek To: Steven Rostedt Cc: Andrew Morton , Oleg Nesterov , Tejun Heo , Ingo Molnar , Peter Zijlstra , Richard Weinberger , David Woodhouse , linux-mtd@lists.infradead.org, Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org, Chris Mason , "Paul E. McKenney" , Thomas Gleixner , Linus Torvalds , Jiri Kosina , Borislav Petkov , Michal Hocko , 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 Message-ID: <20150615152313.GC3135@pathway.suse.cz> References: <1433516477-5153-1-git-send-email-pmladek@suse.cz> <1433516477-5153-16-git-send-email-pmladek@suse.cz> <20150608134417.3fb7a811@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150608134417.3fb7a811@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4169 Lines: 127 On Mon 2015-06-08 13:44:17, Steven Rostedt wrote: > On Fri, 5 Jun 2015 17:01:14 +0200 > Petr Mladek wrote: > > > 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_terminate() 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. > > > > Also it makes sure that producer does not go into the 10sec sleep > > when it is being killed. > > This patch looks like something I may take regardless of the other > patches (if it applies cleanly). Please, find below a version of the patch that can be applied against current Linus tree and also against your for-next branch. > As for the other patches, the ring buffer benchmark is just that, a > benchmark that I use when making changes to the ring buffer. It's not > something for production systems. I see. > What about just adding a depend on !LIVE_PATCHING to > RING_BUFFER_BENCHMARK, or force it to shut down during patching. > There's no reason to make it safe to be running when you patch the > kernel. Just adds complexity to some simple code. I would like to convert all kthreads into some sane API. I hope that it will make them rather easier. Let's see how it will look like in the end. Anyway, the two kthreads in this benchmark are in the "easy" group regarding patching because they are sleeping only limited time. >From 7c1f80e8389c036a06f35c5fd94a648025b995be Mon Sep 17 00:00:00 2001 From: Petr Mladek 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 --- 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..5b3583a01849 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/