Skip to content

Commit 0fb9656

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Make tracing_enabled be equal to tracing_on
The tracing_enabled file has been deprecated as it never was able to serve its purpose well. The tracing_on file has taken over. Instead of having code to keep tracing_enabled, have the tracing_enabled file just set tracing_on, and remove the tracing_enabled variable. This allows us to remove the tracing_enabled file. The reason that the remove is in a different change set and not removed here is in case we find some lonely userspace tool that requires the file to exist. Then the removal patch will get reverted, but this one will not. Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent c7b84ec commit 0fb9656

File tree

2 files changed

+5
-86
lines changed

2 files changed

+5
-86
lines changed

kernel/trace/trace.c

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,9 @@ static struct trace_array max_tr;
205205

206206
static DEFINE_PER_CPU(struct trace_array_cpu, max_tr_data);
207207

208-
/* tracer_enabled is used to toggle activation of a tracer */
209-
static int tracer_enabled = 1;
210-
211-
/**
212-
* tracing_is_enabled - return tracer_enabled status
213-
*
214-
* This function is used by other tracers to know the status
215-
* of the tracer_enabled flag. Tracers may use this function
216-
* to know if it should enable their features when starting
217-
* up. See irqsoff tracer for an example (start_irqsoff_tracer).
218-
*/
219208
int tracing_is_enabled(void)
220209
{
221-
return tracer_enabled;
210+
return tracing_is_on();
222211
}
223212

224213
/*
@@ -1112,8 +1101,7 @@ void trace_find_cmdline(int pid, char comm[])
11121101

11131102
void tracing_record_cmdline(struct task_struct *tsk)
11141103
{
1115-
if (atomic_read(&trace_record_cmdline_disabled) || !tracer_enabled ||
1116-
!tracing_is_on())
1104+
if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on())
11171105
return;
11181106

11191107
if (!__this_cpu_read(trace_cmdline_save))
@@ -2966,56 +2954,6 @@ static const struct file_operations tracing_saved_cmdlines_fops = {
29662954
.llseek = generic_file_llseek,
29672955
};
29682956

2969-
static ssize_t
2970-
tracing_ctrl_read(struct file *filp, char __user *ubuf,
2971-
size_t cnt, loff_t *ppos)
2972-
{
2973-
char buf[64];
2974-
int r;
2975-
2976-
r = sprintf(buf, "%u\n", tracer_enabled);
2977-
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2978-
}
2979-
2980-
static ssize_t
2981-
tracing_ctrl_write(struct file *filp, const char __user *ubuf,
2982-
size_t cnt, loff_t *ppos)
2983-
{
2984-
struct trace_array *tr = filp->private_data;
2985-
unsigned long val;
2986-
int ret;
2987-
2988-
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
2989-
if (ret)
2990-
return ret;
2991-
2992-
val = !!val;
2993-
2994-
mutex_lock(&trace_types_lock);
2995-
if (tracer_enabled ^ val) {
2996-
2997-
/* Only need to warn if this is used to change the state */
2998-
WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on");
2999-
3000-
if (val) {
3001-
tracer_enabled = 1;
3002-
if (current_trace->start)
3003-
current_trace->start(tr);
3004-
tracing_start();
3005-
} else {
3006-
tracer_enabled = 0;
3007-
tracing_stop();
3008-
if (current_trace->stop)
3009-
current_trace->stop(tr);
3010-
}
3011-
}
3012-
mutex_unlock(&trace_types_lock);
3013-
3014-
*ppos += cnt;
3015-
3016-
return cnt;
3017-
}
3018-
30192957
static ssize_t
30202958
tracing_set_trace_read(struct file *filp, char __user *ubuf,
30212959
size_t cnt, loff_t *ppos)
@@ -3469,15 +3407,15 @@ static int tracing_wait_pipe(struct file *filp)
34693407
return -EINTR;
34703408

34713409
/*
3472-
* We block until we read something and tracing is disabled.
3410+
* We block until we read something and tracing is enabled.
34733411
* We still block if tracing is disabled, but we have never
34743412
* read anything. This allows a user to cat this file, and
34753413
* then enable tracing. But after we have read something,
34763414
* we give an EOF when tracing is again disabled.
34773415
*
34783416
* iter->pos will be 0 if we haven't read anything.
34793417
*/
3480-
if (!tracer_enabled && iter->pos)
3418+
if (tracing_is_enabled() && iter->pos)
34813419
break;
34823420
}
34833421

@@ -4076,13 +4014,6 @@ static const struct file_operations tracing_max_lat_fops = {
40764014
.llseek = generic_file_llseek,
40774015
};
40784016

4079-
static const struct file_operations tracing_ctrl_fops = {
4080-
.open = tracing_open_generic,
4081-
.read = tracing_ctrl_read,
4082-
.write = tracing_ctrl_write,
4083-
.llseek = generic_file_llseek,
4084-
};
4085-
40864017
static const struct file_operations set_tracer_fops = {
40874018
.open = tracing_open_generic,
40884019
.read = tracing_set_trace_read,
@@ -4858,7 +4789,7 @@ static __init int tracer_init_debugfs(void)
48584789
d_tracer = tracing_init_dentry();
48594790

48604791
trace_create_file("tracing_enabled", 0644, d_tracer,
4861-
&global_trace, &tracing_ctrl_fops);
4792+
&global_trace, &rb_simple_fops);
48624793

48634794
trace_create_file("trace_options", 0644, d_tracer,
48644795
NULL, &tracing_iter_fops);

kernel/trace/trace_selftest.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
320320
int (*func)(void))
321321
{
322322
int save_ftrace_enabled = ftrace_enabled;
323-
int save_tracer_enabled = tracer_enabled;
324323
unsigned long count;
325324
char *func_name;
326325
int ret;
@@ -331,7 +330,6 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
331330

332331
/* enable tracing, and record the filter function */
333332
ftrace_enabled = 1;
334-
tracer_enabled = 1;
335333

336334
/* passed in by parameter to fool gcc from optimizing */
337335
func();
@@ -395,7 +393,6 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
395393

396394
out:
397395
ftrace_enabled = save_ftrace_enabled;
398-
tracer_enabled = save_tracer_enabled;
399396

400397
/* Enable tracing on all functions again */
401398
ftrace_set_global_filter(NULL, 0, 1);
@@ -452,7 +449,6 @@ static int
452449
trace_selftest_function_recursion(void)
453450
{
454451
int save_ftrace_enabled = ftrace_enabled;
455-
int save_tracer_enabled = tracer_enabled;
456452
char *func_name;
457453
int len;
458454
int ret;
@@ -465,7 +461,6 @@ trace_selftest_function_recursion(void)
465461

466462
/* enable tracing, and record the filter function */
467463
ftrace_enabled = 1;
468-
tracer_enabled = 1;
469464

470465
/* Handle PPC64 '.' name */
471466
func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
@@ -534,7 +529,6 @@ trace_selftest_function_recursion(void)
534529
ret = 0;
535530
out:
536531
ftrace_enabled = save_ftrace_enabled;
537-
tracer_enabled = save_tracer_enabled;
538532

539533
return ret;
540534
}
@@ -569,7 +563,6 @@ static int
569563
trace_selftest_function_regs(void)
570564
{
571565
int save_ftrace_enabled = ftrace_enabled;
572-
int save_tracer_enabled = tracer_enabled;
573566
char *func_name;
574567
int len;
575568
int ret;
@@ -586,7 +579,6 @@ trace_selftest_function_regs(void)
586579

587580
/* enable tracing, and record the filter function */
588581
ftrace_enabled = 1;
589-
tracer_enabled = 1;
590582

591583
/* Handle PPC64 '.' name */
592584
func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
@@ -648,7 +640,6 @@ trace_selftest_function_regs(void)
648640
ret = 0;
649641
out:
650642
ftrace_enabled = save_ftrace_enabled;
651-
tracer_enabled = save_tracer_enabled;
652643

653644
return ret;
654645
}
@@ -662,7 +653,6 @@ int
662653
trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
663654
{
664655
int save_ftrace_enabled = ftrace_enabled;
665-
int save_tracer_enabled = tracer_enabled;
666656
unsigned long count;
667657
int ret;
668658

@@ -671,7 +661,6 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
671661

672662
/* start the tracing */
673663
ftrace_enabled = 1;
674-
tracer_enabled = 1;
675664

676665
ret = tracer_init(trace, tr);
677666
if (ret) {
@@ -708,7 +697,6 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
708697
ret = trace_selftest_function_regs();
709698
out:
710699
ftrace_enabled = save_ftrace_enabled;
711-
tracer_enabled = save_tracer_enabled;
712700

713701
/* kill ftrace totally if we failed */
714702
if (ret)

0 commit comments

Comments
 (0)