lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1433516477-5153-15-git-send-email-pmladek@suse.cz>
Date:	Fri,  5 Jun 2015 17:01:13 +0200
From:	Petr Mladek <pmladek@...e.cz>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Oleg Nesterov <oleg@...hat.com>, Tejun Heo <tj@...nel.org>,
	Ingo Molnar <mingo@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>
Cc:	Richard Weinberger <richard@....at>,
	Steven Rostedt <rostedt@...dmis.org>,
	David Woodhouse <dwmw2@...radead.org>,
	linux-mtd@...ts.infradead.org,
	Trond Myklebust <trond.myklebust@...marydata.com>,
	Anna Schumaker <anna.schumaker@...app.com>,
	linux-nfs@...r.kernel.org, Chris Mason <clm@...com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Jiri Kosina <jkosina@...e.cz>, Borislav Petkov <bp@...e.de>,
	Michal Hocko <mhocko@...e.cz>, live-patching@...r.kernel.org,
	linux-api@...r.kernel.org, linux-kernel@...r.kernel.org,
	Petr Mladek <pmladek@...e.cz>
Subject: [RFC PATCH 14/18] ring_buffer: Allow to cleanly freeze the ring buffer benchmark kthreads

One target of the switch to the kthread iterant API is to make
most kthreads cleanly freezable.

This patch adds try_to_freeze() where appropriate and enables
freezing.

Signed-off-by: Petr Mladek <pmladek@...e.cz>
---
 kernel/trace/ring_buffer_benchmark.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index 164f3762cc82..2d276b892aea 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -6,6 +6,7 @@
 #include <linux/ring_buffer.h>
 #include <linux/completion.h>
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 #include <linux/module.h>
 #include <linux/ktime.h>
 #include <asm/local.h>
@@ -207,6 +208,7 @@ static void ring_buffer_consumer(void)
 			break;
 
 		schedule();
+		try_to_freeze();
 	}
 	reader_finish = 0;
 	complete(&read_done);
@@ -252,19 +254,21 @@ static void ring_buffer_producer(void)
 		if (consumer && !(cnt % wakeup_interval))
 			wake_up_process(consumer);
 
+		if (cnt % wakeup_interval) {
 #ifndef CONFIG_PREEMPT
-		/*
-		 * If we are a non preempt kernel, the 10 second run will
-		 * stop everything while it runs. Instead, we will call
-		 * cond_resched and also add any time that was lost by a
-		 * rescedule.
-		 *
-		 * Do a cond resched at the same frequency we would wake up
-		 * the reader.
-		 */
-		if (cnt % wakeup_interval)
+			/*
+			 * If we are a non preempt kernel, the 10 second run
+			 * will stop everything while it runs. Instead, we will
+			 * call cond_resched and also add any time that was
+			 * lost by a rescedule.
+			 *
+			 * Do a cond resched at the same frequency we would
+			 * wake up the reader.
+			 */
 			cond_resched();
 #endif
+			try_to_freeze();
+		}
 
 	} while (ktime_before(end_time, timeout) && !kill_test);
 	trace_printk("End ring buffer hammer\n");
@@ -356,12 +360,6 @@ static void ring_buffer_producer(void)
 	}
 }
 
-static void ring_buffer_consumer_thread_init(void *arg)
-{
-	/* it does not matter where we freeze */
-	current->flags |= PF_NOFREEZE;
-}
-
 static void ring_buffer_consumer_thread_func(void *arg)
 {
 	if (kill_test)
@@ -375,9 +373,6 @@ static void ring_buffer_consumer_thread_func(void *arg)
 static void ring_buffer_producer_thread_init(void *arg)
 {
 	init_completion(&read_start);
-
-	/* it does not matter where we freeze */
-	current->flags |= PF_NOFREEZE;
 }
 
 static void ring_buffer_producer_thread_func(void *arg)
@@ -413,7 +408,6 @@ static int __init ring_buffer_benchmark_init(void)
 		return -ENOMEM;
 
 	consumer_kti.type = KTI_INT_SLEEP;
-	consumer_kti.func = ring_buffer_consumer_thread_init;
 	consumer_kti.func = ring_buffer_consumer_thread_func;
 
 	if (!disable_reader) {
-- 
1.8.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ