tracing: Prevent buffer overwrite disabled for latency tracers

The latency tracers require the buffers to be in overwrite mode,
otherwise they get screwed up. Force the buffers to stay in overwrite
mode when latency tracers are enabled.

Added a flag_changed() method to the tracer structure to allow
the tracers to see what flags are being changed, and also be able
to prevent the change from happing.

Cc: stable@vger.kernel.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt (Red Hat)
2013-03-14 15:03:53 -04:00
committed by Steven Rostedt
parent 8090282265
commit 613f04a0f5
4 changed files with 65 additions and 16 deletions
+32 -6
View File
@@ -2881,11 +2881,25 @@ static int set_tracer_option(struct tracer *trace, char *cmp, int neg)
return -EINVAL;
}
static void set_tracer_flags(unsigned int mask, int enabled)
/* Some tracers require overwrite to stay enabled */
int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
{
if (tracer->enabled && (mask & TRACE_ITER_OVERWRITE) && !set)
return -1;
return 0;
}
int set_tracer_flag(unsigned int mask, int enabled)
{
/* do nothing if flag is already set */
if (!!(trace_flags & mask) == !!enabled)
return;
return 0;
/* Give the tracer a chance to approve the change */
if (current_trace->flag_changed)
if (current_trace->flag_changed(current_trace, mask, !!enabled))
return -EINVAL;
if (enabled)
trace_flags |= mask;
@@ -2904,13 +2918,15 @@ static void set_tracer_flags(unsigned int mask, int enabled)
if (mask == TRACE_ITER_PRINTK)
trace_printk_start_stop_comm(enabled);
return 0;
}
static int trace_set_options(char *option)
{
char *cmp;
int neg = 0;
int ret = 0;
int ret = -ENODEV;
int i;
cmp = strstrip(option);
@@ -2924,7 +2940,7 @@ static int trace_set_options(char *option)
for (i = 0; trace_options[i]; i++) {
if (strcmp(cmp, trace_options[i]) == 0) {
set_tracer_flags(1 << i, !neg);
ret = set_tracer_flag(1 << i, !neg);
break;
}
}
@@ -2943,6 +2959,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
char buf[64];
int ret;
if (cnt >= sizeof(buf))
return -EINVAL;
@@ -2952,7 +2969,9 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
buf[cnt] = 0;
trace_set_options(buf);
ret = trace_set_options(buf);
if (ret < 0)
return ret;
*ppos += cnt;
@@ -3256,6 +3275,9 @@ static int tracing_set_tracer(const char *buf)
goto out;
trace_branch_disable();
current_trace->enabled = false;
if (current_trace->reset)
current_trace->reset(tr);
@@ -3300,6 +3322,7 @@ static int tracing_set_tracer(const char *buf)
}
current_trace = t;
current_trace->enabled = true;
trace_branch_enable(tr);
out:
mutex_unlock(&trace_types_lock);
@@ -4788,9 +4811,12 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
return -EINVAL;
mutex_lock(&trace_types_lock);
set_tracer_flags(1 << index, val);
ret = set_tracer_flag(1 << index, val);
mutex_unlock(&trace_types_lock);
if (ret < 0)
return ret;
*ppos += cnt;
return cnt;