public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>
Subject: Re: [RFC][PATCH 07/18 v2] ftrace: Add selftest to check if RCU unsafe functions are filtered properly
Date: Sat, 31 Aug 2013 12:47:23 -0700	[thread overview]
Message-ID: <20130831194723.GO3871@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130831051701.613445493@goodmis.org>

On Sat, Aug 31, 2013 at 01:11:24AM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> 
> Add a boot time start up test that has a RCU safe ftrace_ops as well
> as an unsafe one. Make sure the RCU safe ops can trace RCU unsafe
> functions while the unsafe ftrace_ops can not.
> 
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
>  kernel/trace/trace.h                  |    2 +
>  kernel/trace/trace_selftest.c         |   94 +++++++++++++++++++++++++++++++++
>  kernel/trace/trace_selftest_dynamic.c |    7 +++
>  3 files changed, 103 insertions(+)
> 
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 502fed7..3578be6 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -648,6 +648,8 @@ extern unsigned long ftrace_update_tot_cnt;
>  extern int DYN_FTRACE_TEST_NAME(void);
>  #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
>  extern int DYN_FTRACE_TEST_NAME2(void);
> +#define DYN_FTRACE_TEST_RCU_UNSAFE trace_selftest_dynamic_test_rcu_unsafe
> +extern int DYN_FTRACE_TEST_RCU_UNSAFE(void);
> 
>  extern bool ring_buffer_expanded;
>  extern bool tracing_selftest_disabled;
> diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
> index a7329b7..eeacb47 100644
> --- a/kernel/trace/trace_selftest.c
> +++ b/kernel/trace/trace_selftest.c
> @@ -185,6 +185,97 @@ static void reset_counts(void)
>  	trace_selftest_test_dyn_cnt = 0;
>  }
> 
> +static struct ftrace_ops ftrace_rcu_safe_ops = {
> +	.func		= trace_selftest_test_probe1_func,
> +	.flags		= FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_RCU_SAFE,
> +};
> +
> +static struct ftrace_ops ftrace_rcu_unsafe_ops = {
> +	.func		= trace_selftest_test_probe2_func,
> +	.flags		= FTRACE_OPS_FL_RECURSION_SAFE,
> +};
> +
> +static int test_rcu_safe_unsafe(void)
> +{
> +	int save_ftrace_enabled = ftrace_enabled;
> +	char *func_name;
> +	int len;
> +	int ret = 0;
> +
> +	printk(KERN_CONT "PASSED\n");
> +	pr_info("Testing ftrace rcu safe unsafe: ");
> +
> +	ftrace_enabled = 1;
> +
> +	trace_selftest_test_probe1_cnt = 0;
> +	trace_selftest_test_probe2_cnt = 0;
> +
> +	func_name = "*" __stringify(DYN_FTRACE_TEST_RCU_UNSAFE);
> +	len = strlen(func_name);
> +
> +	ftrace_set_filter(&ftrace_rcu_safe_ops, func_name, len, 1);
> +	ftrace_set_filter(&ftrace_rcu_unsafe_ops, func_name, len, 1);
> +
> +	/* Do single registrations first */
> +	register_ftrace_function(&ftrace_rcu_safe_ops);
> +
> +	DYN_FTRACE_TEST_RCU_UNSAFE();
> +
> +	unregister_ftrace_function(&ftrace_rcu_safe_ops);
> +
> +	if (trace_selftest_test_probe1_cnt != 1) {
> +		printk(KERN_CONT "rcu_safe expected 1 call but had %d ",
> +		       trace_selftest_test_probe1_cnt);
> +		goto out;
> +	}
> +
> +	register_ftrace_function(&ftrace_rcu_unsafe_ops);
> +
> +	DYN_FTRACE_TEST_RCU_UNSAFE();
> +
> +	unregister_ftrace_function(&ftrace_rcu_unsafe_ops);
> +
> +	if (trace_selftest_test_probe2_cnt != 0) {
> +		printk(KERN_CONT "rcu_safe expected 0 calls but had %d ",
> +		       trace_selftest_test_probe2_cnt);
> +		goto out;
> +	}
> +
> +	/* Run both together, which uses the list op */
> +
> +	trace_selftest_test_probe1_cnt = 0;
> +	trace_selftest_test_probe2_cnt = 0;
> +
> +	register_ftrace_function(&ftrace_rcu_safe_ops);
> +	register_ftrace_function(&ftrace_rcu_unsafe_ops);
> +
> +	DYN_FTRACE_TEST_RCU_UNSAFE();
> +	DYN_FTRACE_TEST_RCU_UNSAFE();
> +	DYN_FTRACE_TEST_RCU_UNSAFE();
> +
> +	unregister_ftrace_function(&ftrace_rcu_unsafe_ops);
> +	unregister_ftrace_function(&ftrace_rcu_safe_ops);
> +
> +
> +	if (trace_selftest_test_probe1_cnt != 3) {
> +		printk(KERN_CONT "rcu_safe expected 3 calls but had %d ",
> +		       trace_selftest_test_probe1_cnt);
> +		goto out;
> +	}
> +
> +	if (trace_selftest_test_probe2_cnt != 0) {
> +		printk(KERN_CONT "rcu_safe expected 0 calls but had %d ",
> +		       trace_selftest_test_probe2_cnt);
> +		goto out;
> +	}
> +
> +	ret = 0;
> + out:
> +	ftrace_enabled = save_ftrace_enabled;
> +
> +	return ret;
> +}
> +
>  static int trace_selftest_ops(int cnt)
>  {
>  	int save_ftrace_enabled = ftrace_enabled;
> @@ -401,6 +492,9 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
>  	if (!ret)
>  		ret = trace_selftest_ops(2);
> 
> +	if (!ret)
> +		ret = test_rcu_safe_unsafe();
> +
>  	return ret;
>  }
> 
> diff --git a/kernel/trace/trace_selftest_dynamic.c b/kernel/trace/trace_selftest_dynamic.c
> index b4c475a..5eefa56 100644
> --- a/kernel/trace/trace_selftest_dynamic.c
> +++ b/kernel/trace/trace_selftest_dynamic.c
> @@ -11,3 +11,10 @@ int DYN_FTRACE_TEST_NAME2(void)
>  	/* used to call mcount */
>  	return 0;
>  }
> +
> +int trace_selftest_dynamic_test_rcu_unsafe(void)
> +{
> +	/* used to call mcount */
> +	return 0;
> +}
> +FTRACE_UNSAFE_RCU(trace_selftest_dynamic_test_rcu_unsafe);
> -- 
> 1.7.10.4
> 
> 


  reply	other threads:[~2013-08-31 19:47 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-31  5:11 [RFC][PATCH 00/18 v2] ftrace/rcu: Handle unsafe RCU functions and ftrace callbacks Steven Rostedt
2013-08-31  5:11 ` [RFC][PATCH 01/18 v2] ftrace: Add hash list to save RCU unsafe functions Steven Rostedt
2013-08-31 19:28   ` Paul E. McKenney
2013-09-03 21:15   ` Steven Rostedt
2013-09-03 22:18     ` Paul E. McKenney
2013-09-03 23:57       ` Steven Rostedt
2013-09-04  0:18         ` Steven Rostedt
2013-09-04  1:11           ` [RFC][PATCH 19/18] ftrace: Print a message when the rcu checker is disabled Steven Rostedt
2013-09-04  1:25             ` Paul E. McKenney
2013-09-04  1:24         ` [RFC][PATCH 01/18 v2] ftrace: Add hash list to save RCU unsafe functions Paul E. McKenney
2013-09-04  1:51           ` Steven Rostedt
2013-09-04  1:56             ` Steven Rostedt
2013-09-04  2:01           ` Steven Rostedt
2013-09-04  2:03             ` Steven Rostedt
2013-09-04  4:18               ` Paul E. McKenney
2013-09-04 11:50                 ` Steven Rostedt
2013-09-04  4:12             ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 02/18 v2] ftrace: Do not set ftrace records for unsafe RCU when not allowed Steven Rostedt
2013-08-31 19:29   ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 03/18 v2] ftrace: Set ftrace internal function tracing RCU safe Steven Rostedt
2013-08-31 19:30   ` Paul E. McKenney
2013-08-31 19:44   ` Paul E. McKenney
2013-09-03 13:22     ` Steven Rostedt
2013-09-03 13:54       ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 04/18 v2] ftrace: Add test for ops against unsafe RCU functions in callback Steven Rostedt
2013-08-31 19:45   ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 05/18 v2] ftrace: Do not display non safe RCU functions in available_filter_functions Steven Rostedt
2013-08-31 19:46   ` Paul E. McKenney
2013-08-31 20:35     ` Steven Rostedt
2013-08-31 20:54       ` Paul E. McKenney
2013-09-03 13:26         ` Steven Rostedt
2013-09-03 13:54           ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 06/18 v2] ftrace: Add rcu_unsafe_filter_functions file Steven Rostedt
2013-08-31 19:46   ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 07/18 v2] ftrace: Add selftest to check if RCU unsafe functions are filtered properly Steven Rostedt
2013-08-31 19:47   ` Paul E. McKenney [this message]
2013-08-31  5:11 ` [RFC][PATCH 08/18 v2] ftrace/rcu: Do not trace debug_lockdep_rcu_enabled() Steven Rostedt
2013-08-31 19:21   ` Paul E. McKenney
2013-08-31 20:31     ` Steven Rostedt
2013-08-31  5:11 ` [RFC][PATCH 09/18 v2] ftrace: Fix a slight race in modifying what function callback gets traced Steven Rostedt
2013-08-31  5:11 ` [RFC][PATCH 10/18 v2] ftrace: Create a RCU unsafe checker Steven Rostedt
2013-08-31 19:49   ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 11/18 v2] ftrace: Adde infrastructure to stop RCU unsafe checker from checking Steven Rostedt
2013-08-31 19:52   ` Paul E. McKenney
2013-08-31 20:40     ` Steven Rostedt
2013-09-03 13:43     ` Steven Rostedt
2013-09-03 15:22       ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 12/18 v2] ftrace: Disable RCU unsafe checker when function graph is enabled Steven Rostedt
2013-08-31 19:55   ` Paul E. McKenney
2013-08-31 20:42     ` Steven Rostedt
2013-08-31 20:58       ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 13/18 v2] ftrace: Disable the RCU unsafe checker when irqsoff " Steven Rostedt
2013-08-31 19:58   ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 14/18 v2] ftrace/lockdep: Have the RCU lockdep splat show what function triggered Steven Rostedt
2013-08-31 19:59   ` Paul E. McKenney
2013-09-05 19:18   ` Peter Zijlstra
2013-09-05 19:52     ` Steven Rostedt
2013-09-06 12:57       ` Ingo Molnar
2013-09-06 13:16         ` Steven Rostedt
2013-09-05 19:35   ` Peter Zijlstra
2013-09-05 20:27     ` Steven Rostedt
2013-08-31  5:11 ` [RFC][PATCH 15/18 v2] ftrace/rcu: Mark functions that are RCU unsafe Steven Rostedt
2013-08-31 20:00   ` Paul E. McKenney
2013-08-31 20:43     ` Steven Rostedt
2013-08-31 20:54       ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 16/18 v2] rcu/irq/x86: " Steven Rostedt
2013-08-31 20:01   ` Paul E. McKenney
2013-08-31  5:11 ` [RFC][PATCH 17/18 v2] ftrace/cpuidle/x86: " Steven Rostedt
2013-08-31 11:07   ` Wysocki, Rafael J
2013-08-31 20:02   ` Paul E. McKenney
2013-09-04  0:16   ` H. Peter Anvin
2013-08-31  5:11 ` [RFC][PATCH 18/18 v2] ftrace/sched: " Steven Rostedt
2013-08-31 20:01   ` Paul E. McKenney
2013-08-31 15:50 ` [RFC][PATCH 00/18 v2] ftrace/rcu: Handle unsafe RCU functions and ftrace callbacks Steven Rostedt

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=20130831194723.GO3871@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /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