From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 25/25] tracing: Add trace options for tracer options to instances
Date: Thu, 01 Oct 2015 07:55:49 -0400 [thread overview]
Message-ID: <20151001115640.301036098@goodmis.org> (raw)
In-Reply-To: 20151001115524.066462793@goodmis.org
[-- Attachment #1: 0025-tracing-Add-trace-options-for-tracer-options-to-inst.patch --]
[-- Type: text/plain, Size: 6058 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Add the tracer options to instances options directory as well. Only add the
options for tracers that are allowed to be enabled by an instance. But note,
that tracer options are global. That is, tracer options enabled in an
instance, also take affect at the top level and in other instances.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 80 ++++++++++++++++++++++++++++++++++++++--------------
kernel/trace/trace.h | 9 +++++-
2 files changed, 67 insertions(+), 22 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7b99e36b8973..78022c1a125f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4308,7 +4308,7 @@ int tracing_update_buffers(void)
struct trace_option_dentry;
-static struct trace_option_dentry *
+static void
create_trace_option_files(struct trace_array *tr, struct tracer *tracer);
/*
@@ -4334,15 +4334,7 @@ static void add_tracer_options(struct trace_array *tr, struct tracer *t)
if (!tr->dir)
return;
- /* Currently, only the top instance has options */
- if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL))
- return;
-
- /* Ignore if they were already created */
- if (t->topts)
- return;
-
- t->topts = create_trace_option_files(tr, t);
+ create_trace_option_files(tr, t);
}
static int tracing_set_tracer(struct trace_array *tr, const char *buf)
@@ -6341,21 +6333,39 @@ create_trace_option_file(struct trace_array *tr,
}
-static struct trace_option_dentry *
+static void
create_trace_option_files(struct trace_array *tr, struct tracer *tracer)
{
struct trace_option_dentry *topts;
+ struct trace_options *tr_topts;
struct tracer_flags *flags;
struct tracer_opt *opts;
int cnt;
+ int i;
if (!tracer)
- return NULL;
+ return;
flags = tracer->flags;
if (!flags || !flags->opts)
- return NULL;
+ return;
+
+ /*
+ * If this is an instance, only create flags for tracers
+ * the instance may have.
+ */
+ if (!trace_ok_for_array(tracer, tr))
+ return;
+
+ for (i = 0; i < tr->nr_topts; i++) {
+ /*
+ * Check if these flags have already been added.
+ * Some tracers share flags.
+ */
+ if (tr->topts[i].tracer->flags == tracer->flags)
+ return;
+ }
opts = flags->opts;
@@ -6364,7 +6374,19 @@ create_trace_option_files(struct trace_array *tr, struct tracer *tracer)
topts = kcalloc(cnt + 1, sizeof(*topts), GFP_KERNEL);
if (!topts)
- return NULL;
+ return;
+
+ tr_topts = krealloc(tr->topts, sizeof(*tr->topts) * (tr->nr_topts + 1),
+ GFP_KERNEL);
+ if (!tr_topts) {
+ kfree(topts);
+ return;
+ }
+
+ tr->topts = tr_topts;
+ tr->topts[tr->nr_topts].tracer = tracer;
+ tr->topts[tr->nr_topts].topts = topts;
+ tr->nr_topts++;
for (cnt = 0; opts[cnt].name; cnt++) {
create_trace_option_file(tr, &topts[cnt], flags,
@@ -6373,8 +6395,6 @@ create_trace_option_files(struct trace_array *tr, struct tracer *tracer)
"Failed to create trace option: %s",
opts[cnt].name);
}
-
- return topts;
}
static struct dentry *
@@ -6552,6 +6572,21 @@ static void init_trace_flags_index(struct trace_array *tr)
tr->trace_flags_index[i] = i;
}
+static void __update_tracer_options(struct trace_array *tr)
+{
+ struct tracer *t;
+
+ for (t = trace_types; t; t = t->next)
+ add_tracer_options(tr, t);
+}
+
+static void update_tracer_options(struct trace_array *tr)
+{
+ mutex_lock(&trace_types_lock);
+ __update_tracer_options(tr);
+ mutex_unlock(&trace_types_lock);
+}
+
static int instance_mkdir(const char *name)
{
struct trace_array *tr;
@@ -6605,6 +6640,7 @@ static int instance_mkdir(const char *name)
init_tracer_tracefs(tr, tr->dir);
init_trace_flags_index(tr);
+ __update_tracer_options(tr);
list_add(&tr->list, &ftrace_trace_arrays);
@@ -6630,6 +6666,7 @@ static int instance_rmdir(const char *name)
struct trace_array *tr;
int found = 0;
int ret;
+ int i;
mutex_lock(&trace_types_lock);
@@ -6655,6 +6692,11 @@ static int instance_rmdir(const char *name)
debugfs_remove_recursive(tr->dir);
free_trace_buffers(tr);
+ for (i = 0; i < tr->nr_topts; i++) {
+ kfree(tr->topts[i].topts);
+ }
+ kfree(tr->topts);
+
kfree(tr->name);
kfree(tr);
@@ -6877,7 +6919,6 @@ static struct notifier_block trace_module_nb = {
static __init int tracer_init_tracefs(void)
{
struct dentry *d_tracer;
- struct tracer *t;
trace_access_lock_init();
@@ -6914,10 +6955,7 @@ static __init int tracer_init_tracefs(void)
create_trace_instances(d_tracer);
- mutex_lock(&trace_types_lock);
- for (t = trace_types; t; t = t->next)
- add_tracer_options(&global_trace, t);
- mutex_unlock(&trace_types_lock);
+ update_tracer_options(&global_trace);
return 0;
}
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 423cb48a1d6d..fb8a61c710ea 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -159,6 +159,7 @@ struct trace_array_cpu {
};
struct tracer;
+struct trace_option_dentry;
struct trace_buffer {
struct trace_array *tr;
@@ -170,6 +171,11 @@ struct trace_buffer {
#define TRACE_FLAGS_MAX_SIZE 32
+struct trace_options {
+ struct tracer *tracer;
+ struct trace_option_dentry *topts;
+};
+
/*
* The trace array - an array of per-CPU trace arrays. This is the
* highest level data structure that individual tracers deal with.
@@ -218,6 +224,7 @@ struct trace_array {
#endif
int stop_count;
int clock_id;
+ int nr_topts;
struct tracer *current_trace;
unsigned int trace_flags;
unsigned char trace_flags_index[TRACE_FLAGS_MAX_SIZE];
@@ -227,6 +234,7 @@ struct trace_array {
struct dentry *options;
struct dentry *percpu_dir;
struct dentry *event_dir;
+ struct trace_options *topts;
struct list_head systems;
struct list_head events;
cpumask_var_t tracing_cpumask; /* only trace on set CPUs */
@@ -398,7 +406,6 @@ struct tracer {
u32 mask, int set);
struct tracer *next;
struct tracer_flags *flags;
- struct trace_option_dentry *topts;
int enabled;
int ref;
bool print_max;
--
2.5.1
prev parent reply other threads:[~2015-10-01 11:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 11:55 [for-next][PATCH 00/25] tracing: Have instances have their own options + clean ups Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 01/25] kernel/trace_probe: is_good_name can be boolean Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 02/25] tracing: Move non perf code out of perf.h Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 03/25] tracing: Remove ftrace_trace_stack_regs() Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 04/25] tracing: Remove unused function trace_current_buffer_lock_reserve() Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 05/25] tracing: Pass trace_array into trace_buffer_unlock_commit() Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 06/25] tracing: Make ftrace_trace_stack() static Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 07/25] tracing: Inject seq_print_userip_objs() into its only user Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 08/25] tracing: Turn seq_print_user_ip() into a static function Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 09/25] tracing: Move "display-graph" option to main options Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 10/25] tracing: Remove unused tracing option "ftrace_preempt" Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 11/25] tracing: Use enums instead of hard coded bitmasks for TRACE_ITER flags Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 12/25] tracing: Use TRACE_FLAGS macro to keep enums and strings matched Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 13/25] tracing: Only create function graph options when it is compiled in Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 14/25] tracing: Only create branch tracer options when " Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 15/25] tracing: Do not create function tracer options when not " Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 16/25] tracing: Only create stacktrace option when STACKTRACE is configured Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 17/25] tracing: Always show all tracer options in the options directory Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 18/25] tracing: Add build bug if we have more trace_flags than bits Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 19/25] tracing: Remove access to trace_flags in trace_printk.c Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 20/25] tracing: Move sleep-time and graph-time options out of the core trace_flags Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 21/25] tracing: Move trace_flags from global to a trace_array field Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 22/25] tracing: Add a method to pass in trace_array descriptor to option files Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 23/25] tracing: Make ftrace_trace_stack() depend on general trace_array flag Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 24/25] tracing: Add trace options for core options to instances Steven Rostedt
2015-10-01 11:55 ` Steven Rostedt [this message]
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=20151001115640.301036098@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.