Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205325
b: refs/heads/master
c: ef710e1
h: refs/heads/master
i:
  205323: 76cf36c
v: v3
  • Loading branch information
KOSAKI Motohiro authored and Steven Rostedt committed Jul 21, 2010
1 parent af7712d commit 277d773
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bc289ae98b75d93228d24f521ef02a076e506e94
refs/heads/master: ef710e100c1068d3dd5774d2b34c5485219e06ce
38 changes: 32 additions & 6 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
return;

WARN_ON_ONCE(!irqs_disabled());
if (!current_trace->use_max_tr) {
WARN_ON_ONCE(1);
return;
}
arch_spin_lock(&ftrace_max_lock);

tr->buffer = max_tr.buffer;
Expand All @@ -686,6 +690,11 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
return;

WARN_ON_ONCE(!irqs_disabled());
if (!current_trace->use_max_tr) {
WARN_ON_ONCE(1);
return;
}

arch_spin_lock(&ftrace_max_lock);

ftrace_disable_cpu();
Expand Down Expand Up @@ -2801,6 +2810,9 @@ static int tracing_resize_ring_buffer(unsigned long size)
if (ret < 0)
return ret;

if (!current_trace->use_max_tr)
goto out;

ret = ring_buffer_resize(max_tr.buffer, size);
if (ret < 0) {
int r;
Expand Down Expand Up @@ -2828,11 +2840,14 @@ static int tracing_resize_ring_buffer(unsigned long size)
return ret;
}

max_tr.entries = size;
out:
global_trace.entries = size;

return ret;
}


/**
* tracing_update_buffers - used by tracing facility to expand ring buffers
*
Expand Down Expand Up @@ -2893,12 +2908,26 @@ static int tracing_set_tracer(const char *buf)
trace_branch_disable();
if (current_trace && current_trace->reset)
current_trace->reset(tr);

if (current_trace && current_trace->use_max_tr) {
/*
* We don't free the ring buffer. instead, resize it because
* The max_tr ring buffer has some state (e.g. ring->clock) and
* we want preserve it.
*/
ring_buffer_resize(max_tr.buffer, 1);
max_tr.entries = 1;
}
destroy_trace_option_files(topts);

current_trace = t;

topts = create_trace_option_files(current_trace);
if (current_trace->use_max_tr) {
ret = ring_buffer_resize(max_tr.buffer, global_trace.entries);
if (ret < 0)
goto out;
max_tr.entries = global_trace.entries;
}

if (t->init) {
ret = tracer_init(t, tr);
Expand Down Expand Up @@ -3480,7 +3509,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
}

tracing_start();
max_tr.entries = global_trace.entries;
mutex_unlock(&trace_types_lock);

return cnt;
Expand Down Expand Up @@ -4578,16 +4606,14 @@ __init static int tracer_alloc_buffers(void)


#ifdef CONFIG_TRACER_MAX_TRACE
max_tr.buffer = ring_buffer_alloc(ring_buf_size,
TRACE_BUFFER_FLAGS);
max_tr.buffer = ring_buffer_alloc(1, TRACE_BUFFER_FLAGS);
if (!max_tr.buffer) {
printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n");
WARN_ON(1);
ring_buffer_free(global_trace.buffer);
goto out_free_cpumask;
}
max_tr.entries = ring_buffer_size(max_tr.buffer);
WARN_ON(max_tr.entries != global_trace.entries);
max_tr.entries = 1;
#endif

/* Allocate the first page for all buffers */
Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ struct tracer {
struct tracer *next;
int print_max;
struct tracer_flags *flags;
int use_max_tr;
};


Expand Down
3 changes: 3 additions & 0 deletions trunk/kernel/trace/trace_irqsoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ static struct tracer irqsoff_tracer __read_mostly =
#endif
.open = irqsoff_trace_open,
.close = irqsoff_trace_close,
.use_max_tr = 1,
};
# define register_irqsoff(trace) register_tracer(&trace)
#else
Expand Down Expand Up @@ -681,6 +682,7 @@ static struct tracer preemptoff_tracer __read_mostly =
#endif
.open = irqsoff_trace_open,
.close = irqsoff_trace_close,
.use_max_tr = 1,
};
# define register_preemptoff(trace) register_tracer(&trace)
#else
Expand Down Expand Up @@ -715,6 +717,7 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
#endif
.open = irqsoff_trace_open,
.close = irqsoff_trace_close,
.use_max_tr = 1,
};

# define register_preemptirqsoff(trace) register_tracer(&trace)
Expand Down
2 changes: 2 additions & 0 deletions trunk/kernel/trace/trace_sched_wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ static struct tracer wakeup_tracer __read_mostly =
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_wakeup,
#endif
.use_max_tr = 1,
};

static struct tracer wakeup_rt_tracer __read_mostly =
Expand All @@ -396,6 +397,7 @@ static struct tracer wakeup_rt_tracer __read_mostly =
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_wakeup,
#endif
.use_max_tr = 1,
};

__init static int init_wakeup_tracer(void)
Expand Down

0 comments on commit 277d773

Please sign in to comment.