From patchwork Mon Jun 15 15:54:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Mladek X-Patchwork-Id: 484412 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 989801400A0 for ; Tue, 16 Jun 2015 02:03:43 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4WpA-0007LU-Sq; Mon, 15 Jun 2015 16:01:24 +0000 Received: from cantor2.suse.de ([195.135.220.15] helo=mx2.suse.de) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4Wir-0000OK-GO for linux-mtd@lists.infradead.org; Mon, 15 Jun 2015 15:54:54 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 56446ABC6; Mon, 15 Jun 2015 15:54:30 +0000 (UTC) Date: Mon, 15 Jun 2015 17:54:28 +0200 From: Petr Mladek To: Steven Rostedt Subject: Re: [RFC PATCH 15/18] ring_buffer: Allow to exit the ring buffer benchmark immediately Message-ID: <20150615155428.GD3135@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> <20150615152313.GC3135@pathway.suse.cz> <20150615113343.215bcd43@gandalf.local.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150615113343.215bcd43@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150615_085453_915155_ADE056D8 X-CRM114-Status: GOOD ( 22.33 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [195.135.220.15 listed in list.dnswl.org] Cc: linux-nfs@vger.kernel.org, Borislav Petkov , Thomas Gleixner , Jiri Kosina , Peter Zijlstra , Richard Weinberger , Trond Myklebust , Oleg Nesterov , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Hocko , Chris Mason , Ingo Molnar , linux-mtd@lists.infradead.org, Linus Torvalds , Tejun Heo , live-patching@vger.kernel.org, Andrew Morton , "Paul E. McKenney" , David Woodhouse , Anna Schumaker X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Mon 2015-06-15 11:33:43, Steven Rostedt wrote: > On Mon, 15 Jun 2015 17:23:13 +0200 > Petr Mladek 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 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..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;