mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
tracing/ftrace: handle more than one stat file per tracer
Impact: new API for tracers Make the stat tracing API reentrant. And also provide the new directory /debugfs/tracing/trace_stat which will contain all the stat files for the current active tracer. Now a tracer will, if desired, want to provide a zero terminated array of tracer_stat structures. Each one contains the callbacks necessary for one stat file. It have to provide at least a name for its stat file, an iterator with stat_start/start_next callback and an output callback for one stat entry. Also adapt the branch tracer to this new API. We create two files "all" and "annotated" inside the /debugfs/tracing/trace_stat directory, making the both stats simultaneously available instead of needing to change an option to switch from one stat file to another. The output of these stats haven't changed. Changes in v2: _ Apply the previous memory leak fix (rebase against tip/master) Changes in v3: _ Merge the patch that adapted the branch tracer to this Api in this patch to not break the kernel build. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
67d347245f
commit
034939b65a
3 changed files with 217 additions and 117 deletions
|
@ -306,19 +306,6 @@ static int annotated_branch_stat_cmp(void *p1, void *p2)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PROFILE_ALL_BRANCHES
|
||||
enum {
|
||||
TRACE_BRANCH_OPT_ALL = 0x1
|
||||
};
|
||||
|
||||
static struct tracer_opt branch_opts[] = {
|
||||
{ TRACER_OPT(stat_all_branch, TRACE_BRANCH_OPT_ALL) },
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct tracer_flags branch_flags = {
|
||||
.val = 0,
|
||||
.opts = branch_opts
|
||||
};
|
||||
|
||||
extern unsigned long __start_branch_profile[];
|
||||
extern unsigned long __stop_branch_profile[];
|
||||
|
@ -352,28 +339,36 @@ all_branch_stat_next(void *v, int idx)
|
|||
return p;
|
||||
}
|
||||
|
||||
static int branch_set_flag(u32 old_flags, u32 bit, int set)
|
||||
{
|
||||
if (bit == TRACE_BRANCH_OPT_ALL) {
|
||||
if (set) {
|
||||
branch_trace.stat_headers = all_branch_stat_headers;
|
||||
branch_trace.stat_start = all_branch_stat_start;
|
||||
branch_trace.stat_next = all_branch_stat_next;
|
||||
branch_trace.stat_cmp = NULL;
|
||||
} else {
|
||||
branch_trace.stat_headers =
|
||||
annotated_branch_stat_headers;
|
||||
branch_trace.stat_start = annotated_branch_stat_start;
|
||||
branch_trace.stat_next = annotated_branch_stat_next;
|
||||
branch_trace.stat_cmp = annotated_branch_stat_cmp;
|
||||
}
|
||||
init_tracer_stat(&branch_trace);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static struct tracer_stat branch_stats[] = {
|
||||
{.name = "annotated",
|
||||
.stat_start = annotated_branch_stat_start,
|
||||
.stat_next = annotated_branch_stat_next,
|
||||
.stat_cmp = annotated_branch_stat_cmp,
|
||||
.stat_headers = annotated_branch_stat_headers,
|
||||
.stat_show = branch_stat_show},
|
||||
|
||||
{.name = "all",
|
||||
.stat_start = all_branch_stat_start,
|
||||
.stat_next = all_branch_stat_next,
|
||||
.stat_headers = all_branch_stat_headers,
|
||||
.stat_show = branch_stat_show},
|
||||
|
||||
{ }
|
||||
};
|
||||
#else
|
||||
static struct tracer_stat branch_stats[] = {
|
||||
{.name = "annotated",
|
||||
.stat_start = annotated_branch_stat_start,
|
||||
.stat_next = annotated_branch_stat_next,
|
||||
.stat_cmp = annotated_branch_stat_cmp,
|
||||
.stat_headers = annotated_branch_stat_headers,
|
||||
.stat_show = branch_stat_show},
|
||||
|
||||
{ }
|
||||
};
|
||||
#endif /* CONFIG_PROFILE_ALL_BRANCHES */
|
||||
|
||||
|
||||
static struct tracer branch_trace __read_mostly =
|
||||
{
|
||||
.name = "branch",
|
||||
|
@ -383,16 +378,8 @@ static struct tracer branch_trace __read_mostly =
|
|||
#ifdef CONFIG_FTRACE_SELFTEST
|
||||
.selftest = trace_selftest_startup_branch,
|
||||
#endif /* CONFIG_FTRACE_SELFTEST */
|
||||
#endif /* CONFIG_BRANCH_TRACER */
|
||||
.stat_start = annotated_branch_stat_start,
|
||||
.stat_next = annotated_branch_stat_next,
|
||||
.stat_show = branch_stat_show,
|
||||
.stat_headers = annotated_branch_stat_headers,
|
||||
.stat_cmp = annotated_branch_stat_cmp,
|
||||
#ifdef CONFIG_PROFILE_ALL_BRANCHES
|
||||
.flags = &branch_flags,
|
||||
.set_flag = branch_set_flag,
|
||||
#endif
|
||||
.stats = branch_stats
|
||||
};
|
||||
|
||||
__init static int init_branch_trace(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue