linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [for-next][PATCH 0/2] tracing: Minor fixes to the start up tests
@ 2014-10-09  1:10 Steven Rostedt
  2014-10-09  1:10 ` [for-next][PATCH 1/2] tracing: Robustify wait loop Steven Rostedt
  2014-10-09  1:10 ` [for-next][PATCH 2/2] tracing: Clean up scheduling in trace_wakeup_test_thread() Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: Steven Rostedt @ 2014-10-09  1:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: 0cd8f5614fbf8a598a0a47526ac7dc42ab2ba8cd


Peter Zijlstra (1):
      tracing: Robustify wait loop

Steven Rostedt (1):
      tracing: Clean up scheduling in trace_wakeup_test_thread()

----
 kernel/trace/trace_events.c   |  5 ++++-
 kernel/trace/trace_selftest.c | 47 +++++++++++++++++++++++++++----------------
 2 files changed, 34 insertions(+), 18 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [for-next][PATCH 1/2] tracing: Robustify wait loop
  2014-10-09  1:10 [for-next][PATCH 0/2] tracing: Minor fixes to the start up tests Steven Rostedt
@ 2014-10-09  1:10 ` Steven Rostedt
  2014-10-09  1:10 ` [for-next][PATCH 2/2] tracing: Clean up scheduling in trace_wakeup_test_thread() Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2014-10-09  1:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Fengguang Wu, Peter Zijlstra (Intel)

[-- Attachment #1: 0001-tracing-Robustify-wait-loop.patch --]
[-- Type: text/plain, Size: 1216 bytes --]

From: Peter Zijlstra <peterz@infradead.org>

The pending nested sleep debugging triggered on the potential stale
TASK_INTERRUPTIBLE in this code.

While there, fix the loop such that we won't revert to a while(1)
yield() 'spin' loop if we ever get a spurious wakeup.

And fix the actual issue by properly terminating the 'wait' loop by
setting TASK_RUNNING.

Link: http://lkml.kernel.org/p/20141008165110.GA14547@worktop.programming.kicks-ass.net

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ef06ce7e9cf8..0cc51edde3a8 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2513,8 +2513,11 @@ static __init int event_test_thread(void *unused)
 	kfree(test_malloc);
 
 	set_current_state(TASK_INTERRUPTIBLE);
-	while (!kthread_should_stop())
+	while (!kthread_should_stop()) {
 		schedule();
+		set_current_state(TASK_INTERRUPTIBLE);
+	}
+	__set_current_state(TASK_RUNNING);
 
 	return 0;
 }
-- 
2.0.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [for-next][PATCH 2/2] tracing: Clean up scheduling in trace_wakeup_test_thread()
  2014-10-09  1:10 [for-next][PATCH 0/2] tracing: Minor fixes to the start up tests Steven Rostedt
  2014-10-09  1:10 ` [for-next][PATCH 1/2] tracing: Robustify wait loop Steven Rostedt
@ 2014-10-09  1:10 ` Steven Rostedt
  2014-10-09  9:39   ` Peter Zijlstra
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2014-10-09  1:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra

[-- Attachment #1: 0002-tracing-Clean-up-scheduling-in-trace_wakeup_test_thr.patch --]
[-- Type: text/plain, Size: 3537 bytes --]

From: Steven Rostedt <rostedt@goodmis.org>

Peter's new debugging tool triggers when tasks exit with !TASK_RUNNING.
The code in trace_wakeup_test_thread() also has a single schedule() call
that should be encompassed by a loop.

This cleans up the code a little to make it a bit more robust and
also makes the return exit properly with TASK_RUNNING.

Link: http://lkml.kernel.org/p/20141008135216.76142204@gandalf.local.home

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_selftest.c | 47 +++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 5ef60499dc8e..593f52b73551 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -1025,6 +1025,12 @@ trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
 #endif
 
 #ifdef CONFIG_SCHED_TRACER
+
+struct wakeup_test_data {
+	struct completion	is_ready;
+	int			go;
+};
+
 static int trace_wakeup_test_thread(void *data)
 {
 	/* Make this a -deadline thread */
@@ -1034,51 +1040,56 @@ static int trace_wakeup_test_thread(void *data)
 		.sched_deadline = 10000000ULL,
 		.sched_period = 10000000ULL
 	};
-	struct completion *x = data;
+	struct wakeup_test_data *x = data;
 
 	sched_setattr(current, &attr);
 
 	/* Make it know we have a new prio */
-	complete(x);
+	complete(&x->is_ready);
 
 	/* now go to sleep and let the test wake us up */
 	set_current_state(TASK_INTERRUPTIBLE);
-	schedule();
+	while (!x->go) {
+		schedule();
+		set_current_state(TASK_INTERRUPTIBLE);
+	}
 
-	complete(x);
+	complete(&x->is_ready);
+
+	set_current_state(TASK_INTERRUPTIBLE);
 
 	/* we are awake, now wait to disappear */
 	while (!kthread_should_stop()) {
-		/*
-		 * This will likely be the system top priority
-		 * task, do short sleeps to let others run.
-		 */
-		msleep(100);
+		schedule();
+		set_current_state(TASK_INTERRUPTIBLE);
 	}
 
+	__set_current_state(TASK_RUNNING);
+
 	return 0;
 }
-
 int
 trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
 {
 	unsigned long save_max = tr->max_latency;
 	struct task_struct *p;
-	struct completion is_ready;
+	struct wakeup_test_data data;
 	unsigned long count;
 	int ret;
 
-	init_completion(&is_ready);
+	memset(&data, 0, sizeof(data));
+
+	init_completion(&data.is_ready);
 
 	/* create a -deadline thread */
-	p = kthread_run(trace_wakeup_test_thread, &is_ready, "ftrace-test");
+	p = kthread_run(trace_wakeup_test_thread, &data, "ftrace-test");
 	if (IS_ERR(p)) {
 		printk(KERN_CONT "Failed to create ftrace wakeup test thread ");
 		return -1;
 	}
 
 	/* make sure the thread is running at -deadline policy */
-	wait_for_completion(&is_ready);
+	wait_for_completion(&data.is_ready);
 
 	/* start the tracing */
 	ret = tracer_init(trace, tr);
@@ -1099,18 +1110,20 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
 		msleep(100);
 	}
 
-	init_completion(&is_ready);
+	init_completion(&data.is_ready);
+
+	data.go = 1;
+	/* memory barrier is in the wake_up_process() */
 
 	wake_up_process(p);
 
 	/* Wait for the task to wake up */
-	wait_for_completion(&is_ready);
+	wait_for_completion(&data.is_ready);
 
 	/* stop the tracing. */
 	tracing_stop();
 	/* check both trace buffers */
 	ret = trace_test_buffer(&tr->trace_buffer, NULL);
-	printk("ret = %d\n", ret);
 	if (!ret)
 		ret = trace_test_buffer(&tr->max_buffer, &count);
 
-- 
2.0.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [for-next][PATCH 2/2] tracing: Clean up scheduling in trace_wakeup_test_thread()
  2014-10-09  1:10 ` [for-next][PATCH 2/2] tracing: Clean up scheduling in trace_wakeup_test_thread() Steven Rostedt
@ 2014-10-09  9:39   ` Peter Zijlstra
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2014-10-09  9:39 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Ingo Molnar, Andrew Morton

On Wed, Oct 08, 2014 at 09:10:12PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
> 
> Peter's new debugging tool triggers when tasks exit with !TASK_RUNNING.
> The code in trace_wakeup_test_thread() also has a single schedule() call
> that should be encompassed by a loop.
> 
> This cleans up the code a little to make it a bit more robust and
> also makes the return exit properly with TASK_RUNNING.
> 
> Link: http://lkml.kernel.org/p/20141008135216.76142204@gandalf.local.home
> 
> Reported-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Acked-by: Peter Zijlstra <peterz@infreadead.org>

> ---
>  kernel/trace/trace_selftest.c | 47 +++++++++++++++++++++++++++----------------
>  1 file changed, 30 insertions(+), 17 deletions(-)
> 
> diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
> index 5ef60499dc8e..593f52b73551 100644
> --- a/kernel/trace/trace_selftest.c
> +++ b/kernel/trace/trace_selftest.c
> @@ -1025,6 +1025,12 @@ trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
>  #endif
>  
>  #ifdef CONFIG_SCHED_TRACER
> +
> +struct wakeup_test_data {
> +	struct completion	is_ready;
> +	int			go;
> +};

Yeah that works.. 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-09  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-09  1:10 [for-next][PATCH 0/2] tracing: Minor fixes to the start up tests Steven Rostedt
2014-10-09  1:10 ` [for-next][PATCH 1/2] tracing: Robustify wait loop Steven Rostedt
2014-10-09  1:10 ` [for-next][PATCH 2/2] tracing: Clean up scheduling in trace_wakeup_test_thread() Steven Rostedt
2014-10-09  9:39   ` Peter Zijlstra

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).