Skip to content

Commit 2fd196e

Browse files
toyookarostedt
authored andcommitted
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 <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 5e67b51 commit 2fd196e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

kernel/trace/trace.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,18 +1948,20 @@ void tracing_iter_reset(struct trace_iterator *iter, int cpu)
19481948
static void *s_start(struct seq_file *m, loff_t *pos)
19491949
{
19501950
struct trace_iterator *iter = m->private;
1951-
static struct tracer *old_tracer;
19521951
int cpu_file = iter->cpu_file;
19531952
void *p = NULL;
19541953
loff_t l = 0;
19551954
int cpu;
19561955

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+
*/
19581962
mutex_lock(&trace_types_lock);
1959-
if (unlikely(old_tracer != current_trace && current_trace)) {
1960-
old_tracer = current_trace;
1963+
if (unlikely(current_trace && iter->trace->name != current_trace->name))
19611964
*iter->trace = *current_trace;
1962-
}
19631965
mutex_unlock(&trace_types_lock);
19641966

19651967
atomic_inc(&trace_record_cmdline_disabled);
@@ -3494,7 +3496,6 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
34943496
size_t cnt, loff_t *ppos)
34953497
{
34963498
struct trace_iterator *iter = filp->private_data;
3497-
static struct tracer *old_tracer;
34983499
ssize_t sret;
34993500

35003501
/* return any leftover data */
@@ -3506,10 +3507,8 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
35063507

35073508
/* copy the tracer to avoid using a global lock all around */
35083509
mutex_lock(&trace_types_lock);
3509-
if (unlikely(old_tracer != current_trace && current_trace)) {
3510-
old_tracer = current_trace;
3510+
if (unlikely(current_trace && iter->trace->name != current_trace->name))
35113511
*iter->trace = *current_trace;
3512-
}
35133512
mutex_unlock(&trace_types_lock);
35143513

35153514
/*
@@ -3665,7 +3664,6 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
36653664
.ops = &tracing_pipe_buf_ops,
36663665
.spd_release = tracing_spd_release_pipe,
36673666
};
3668-
static struct tracer *old_tracer;
36693667
ssize_t ret;
36703668
size_t rem;
36713669
unsigned int i;
@@ -3675,10 +3673,8 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
36753673

36763674
/* copy the tracer to avoid using a global lock all around */
36773675
mutex_lock(&trace_types_lock);
3678-
if (unlikely(old_tracer != current_trace && current_trace)) {
3679-
old_tracer = current_trace;
3676+
if (unlikely(current_trace && iter->trace->name != current_trace->name))
36803677
*iter->trace = *current_trace;
3681-
}
36823678
mutex_unlock(&trace_types_lock);
36833679

36843680
mutex_lock(&iter->mutex);

0 commit comments

Comments
 (0)