Skip to content

Commit 8c1a49a

Browse files
committed
tracing: Pass trace_array to set_flag callback
As options (flags) may affect instances instead of being global the set_flag() callbacks need to receive the trace_array descriptor of the instance they will be modifying. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 6d0abec commit 8c1a49a

8 files changed

Lines changed: 27 additions & 17 deletions

File tree

‎kernel/trace/blktrace.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,8 @@ static enum print_line_t blk_tracer_print_line(struct trace_iterator *iter)
14271427
return print_one_line(iter, true);
14281428
}
14291429

1430-
static int blk_tracer_set_flag(u32 old_flags, u32 bit, int set)
1430+
static int
1431+
blk_tracer_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
14311432
{
14321433
/* don't output context-info for blk_classic output */
14331434
if (bit == TRACE_BLK_OPT_CLASSIC) {

‎kernel/trace/trace.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ static struct tracer_flags dummy_tracer_flags = {
7373
.opts = dummy_tracer_opt
7474
};
7575

76-
static int dummy_set_flag(u32 old_flags, u32 bit, int set)
76+
static int
77+
dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
7778
{
7879
return 0;
7980
}
@@ -3339,13 +3340,14 @@ static int tracing_trace_options_show(struct seq_file *m, void *v)
33393340
return 0;
33403341
}
33413342

3342-
static int __set_tracer_option(struct tracer *trace,
3343+
static int __set_tracer_option(struct trace_array *tr,
33433344
struct tracer_flags *tracer_flags,
33443345
struct tracer_opt *opts, int neg)
33453346
{
3347+
struct tracer *trace = tr->current_trace;
33463348
int ret;
33473349

3348-
ret = trace->set_flag(tracer_flags->val, opts->bit, !neg);
3350+
ret = trace->set_flag(tr, tracer_flags->val, opts->bit, !neg);
33493351
if (ret)
33503352
return ret;
33513353

@@ -3357,8 +3359,9 @@ static int __set_tracer_option(struct tracer *trace,
33573359
}
33583360

33593361
/* Try to assign a tracer specific option */
3360-
static int set_tracer_option(struct tracer *trace, char *cmp, int neg)
3362+
static int set_tracer_option(struct trace_array *tr, char *cmp, int neg)
33613363
{
3364+
struct tracer *trace = tr->current_trace;
33623365
struct tracer_flags *tracer_flags = trace->flags;
33633366
struct tracer_opt *opts = NULL;
33643367
int i;
@@ -3367,8 +3370,7 @@ static int set_tracer_option(struct tracer *trace, char *cmp, int neg)
33673370
opts = &tracer_flags->opts[i];
33683371

33693372
if (strcmp(cmp, opts->name) == 0)
3370-
return __set_tracer_option(trace, trace->flags,
3371-
opts, neg);
3373+
return __set_tracer_option(tr, trace->flags, opts, neg);
33723374
}
33733375

33743376
return -EINVAL;
@@ -3440,7 +3442,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
34403442

34413443
/* If no option could be set, test the specific tracer options */
34423444
if (!trace_options[i])
3443-
ret = set_tracer_option(tr->current_trace, cmp, neg);
3445+
ret = set_tracer_option(tr, cmp, neg);
34443446

34453447
mutex_unlock(&trace_types_lock);
34463448

@@ -5689,7 +5691,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
56895691

56905692
if (!!(topt->flags->val & topt->opt->bit) != val) {
56915693
mutex_lock(&trace_types_lock);
5692-
ret = __set_tracer_option(topt->tr->current_trace, topt->flags,
5694+
ret = __set_tracer_option(topt->tr, topt->flags,
56935695
topt->opt, !val);
56945696
mutex_unlock(&trace_types_lock);
56955697
if (ret)

‎kernel/trace/trace.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ struct tracer {
355355
void (*print_header)(struct seq_file *m);
356356
enum print_line_t (*print_line)(struct trace_iterator *iter);
357357
/* If you handled the flag setting, return 0 */
358-
int (*set_flag)(u32 old_flags, u32 bit, int set);
358+
int (*set_flag)(struct trace_array *tr,
359+
u32 old_flags, u32 bit, int set);
359360
/* Return 0 if OK with change, else return non-zero */
360361
int (*flag_changed)(struct tracer *tracer,
361362
u32 mask, int set);

‎kernel/trace/trace_functions.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ static void tracing_stop_function_trace(void)
175175
unregister_ftrace_function(&trace_ops);
176176
}
177177

178-
static int func_set_flag(u32 old_flags, u32 bit, int set)
178+
static int
179+
func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
179180
{
180181
switch (bit) {
181182
case TRACE_FUNC_OPT_STACK:

‎kernel/trace/trace_functions_graph.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,8 @@ void graph_trace_close(struct trace_iterator *iter)
14761476
}
14771477
}
14781478

1479-
static int func_graph_set_flag(u32 old_flags, u32 bit, int set)
1479+
static int
1480+
func_graph_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
14801481
{
14811482
if (bit == TRACE_GRAPH_PRINT_IRQS)
14821483
ftrace_graph_skip_irqs = !set;

‎kernel/trace/trace_irqsoff.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ static struct ftrace_ops trace_ops __read_mostly =
160160
#endif /* CONFIG_FUNCTION_TRACER */
161161

162162
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
163-
static int irqsoff_set_flag(u32 old_flags, u32 bit, int set)
163+
static int
164+
irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
164165
{
165166
int cpu;
166167

@@ -266,7 +267,8 @@ __trace_function(struct trace_array *tr,
266267
#else
267268
#define __trace_function trace_function
268269

269-
static int irqsoff_set_flag(u32 old_flags, u32 bit, int set)
270+
static int
271+
irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
270272
{
271273
return -EINVAL;
272274
}

‎kernel/trace/trace_nop.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void nop_trace_reset(struct trace_array *tr)
6262
* If you don't implement it, then the flag setting will be
6363
* automatically accepted.
6464
*/
65-
static int nop_set_flag(u32 old_flags, u32 bit, int set)
65+
static int nop_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
6666
{
6767
/*
6868
* Note that you don't need to update nop_flags.val yourself.

‎kernel/trace/trace_sched_wakeup.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ static void stop_func_tracer(int graph)
209209
}
210210

211211
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
212-
static int wakeup_set_flag(u32 old_flags, u32 bit, int set)
212+
static int
213+
wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
213214
{
214215

215216
if (!(bit & TRACE_DISPLAY_GRAPH))
@@ -311,7 +312,8 @@ __trace_function(struct trace_array *tr,
311312
#else
312313
#define __trace_function trace_function
313314

314-
static int wakeup_set_flag(u32 old_flags, u32 bit, int set)
315+
static int
316+
wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
315317
{
316318
return -EINVAL;
317319
}

0 commit comments

Comments
 (0)