diff options
author | Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com> | 2012-12-25 21:52:52 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-01-30 11:02:05 -0500 |
commit | 2fd196ec1eab2623096e7fc7e6f3976160392bce (patch) | |
tree | 1994d70de20c1a1bc296e02d352142414484355b /kernel/trace | |
parent | 5e67b51e3fb22ad43faf9589e9019ad9c6a00413 (diff) |
tracing: Replace static old_tracer check of tracer name
Currently the trace buffer read functions use a static variable
"old_tracer" for detecting if the current tracer changes. This
was suitable for a single trace file ("trace"), but to add a
snapshot feature that will use the same function for its file,
a check against a static variable is not sufficient.
To use the output functions for two different files, instead of
storing the current tracer in a static variable, as the trace
iterator descriptor contains a pointer to the original current
tracer's name, that pointer can now be used to check if the
current tracer has changed between different reads of the trace
file.
Link: http://lkml.kernel.org/r/20121226025252.3252.9276.stgit@liselsia
Signed-off-by: Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 90a1c71fdbfc..2c724662a3e8 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1948,18 +1948,20 @@ void tracing_iter_reset(struct trace_iterator *iter, int cpu) | |||
1948 | static void *s_start(struct seq_file *m, loff_t *pos) | 1948 | static void *s_start(struct seq_file *m, loff_t *pos) |
1949 | { | 1949 | { |
1950 | struct trace_iterator *iter = m->private; | 1950 | struct trace_iterator *iter = m->private; |
1951 | static struct tracer *old_tracer; | ||
1952 | int cpu_file = iter->cpu_file; | 1951 | int cpu_file = iter->cpu_file; |
1953 | void *p = NULL; | 1952 | void *p = NULL; |
1954 | loff_t l = 0; | 1953 | loff_t l = 0; |
1955 | int cpu; | 1954 | int cpu; |
1956 | 1955 | ||
1957 | /* copy the tracer to avoid using a global lock all around */ | 1956 | /* |
1957 | * copy the tracer to avoid using a global lock all around. | ||
1958 | * iter->trace is a copy of current_trace, the pointer to the | ||
1959 | * name may be used instead of a strcmp(), as iter->trace->name | ||
1960 | * will point to the same string as current_trace->name. | ||
1961 | */ | ||
1958 | mutex_lock(&trace_types_lock); | 1962 | mutex_lock(&trace_types_lock); |
1959 | if (unlikely(old_tracer != current_trace && current_trace)) { | 1963 | if (unlikely(current_trace && iter->trace->name != current_trace->name)) |
1960 | old_tracer = current_trace; | ||
1961 | *iter->trace = *current_trace; | 1964 | *iter->trace = *current_trace; |
1962 | } | ||
1963 | mutex_unlock(&trace_types_lock); | 1965 | mutex_unlock(&trace_types_lock); |
1964 | 1966 | ||
1965 | atomic_inc(&trace_record_cmdline_disabled); | 1967 | atomic_inc(&trace_record_cmdline_disabled); |
@@ -3494,7 +3496,6 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, | |||
3494 | size_t cnt, loff_t *ppos) | 3496 | size_t cnt, loff_t *ppos) |
3495 | { | 3497 | { |
3496 | struct trace_iterator *iter = filp->private_data; | 3498 | struct trace_iterator *iter = filp->private_data; |
3497 | static struct tracer *old_tracer; | ||
3498 | ssize_t sret; | 3499 | ssize_t sret; |
3499 | 3500 | ||
3500 | /* return any leftover data */ | 3501 | /* return any leftover data */ |
@@ -3506,10 +3507,8 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, | |||
3506 | 3507 | ||
3507 | /* copy the tracer to avoid using a global lock all around */ | 3508 | /* copy the tracer to avoid using a global lock all around */ |
3508 | mutex_lock(&trace_types_lock); | 3509 | mutex_lock(&trace_types_lock); |
3509 | if (unlikely(old_tracer != current_trace && current_trace)) { | 3510 | if (unlikely(current_trace && iter->trace->name != current_trace->name)) |
3510 | old_tracer = current_trace; | ||
3511 | *iter->trace = *current_trace; | 3511 | *iter->trace = *current_trace; |
3512 | } | ||
3513 | mutex_unlock(&trace_types_lock); | 3512 | mutex_unlock(&trace_types_lock); |
3514 | 3513 | ||
3515 | /* | 3514 | /* |
@@ -3665,7 +3664,6 @@ static ssize_t tracing_splice_read_pipe(struct file *filp, | |||
3665 | .ops = &tracing_pipe_buf_ops, | 3664 | .ops = &tracing_pipe_buf_ops, |
3666 | .spd_release = tracing_spd_release_pipe, | 3665 | .spd_release = tracing_spd_release_pipe, |
3667 | }; | 3666 | }; |
3668 | static struct tracer *old_tracer; | ||
3669 | ssize_t ret; | 3667 | ssize_t ret; |
3670 | size_t rem; | 3668 | size_t rem; |
3671 | unsigned int i; | 3669 | unsigned int i; |
@@ -3675,10 +3673,8 @@ static ssize_t tracing_splice_read_pipe(struct file *filp, | |||
3675 | 3673 | ||
3676 | /* copy the tracer to avoid using a global lock all around */ | 3674 | /* copy the tracer to avoid using a global lock all around */ |
3677 | mutex_lock(&trace_types_lock); | 3675 | mutex_lock(&trace_types_lock); |
3678 | if (unlikely(old_tracer != current_trace && current_trace)) { | 3676 | if (unlikely(current_trace && iter->trace->name != current_trace->name)) |
3679 | old_tracer = current_trace; | ||
3680 | *iter->trace = *current_trace; | 3677 | *iter->trace = *current_trace; |
3681 | } | ||
3682 | mutex_unlock(&trace_types_lock); | 3678 | mutex_unlock(&trace_types_lock); |
3683 | 3679 | ||
3684 | mutex_lock(&iter->mutex); | 3680 | mutex_lock(&iter->mutex); |