Skip to content

Commit f4ef6a4

Browse files
committed
Merge tag 'trace-v4.17-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Various fixes in tracing: - Tracepoints should not give warning on OOM failures - Use special field for function pointer in trace event - Fix igrab issues in uprobes - Fixes to the new histogram triggers" * tag 'trace-v4.17-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracepoint: Do not warn on ENOMEM tracing: Add field modifier parsing hist error for hist triggers tracing: Add field parsing hist error for hist triggers tracing: Restore proper field flag printing when displaying triggers tracing: initcall: Ordered comparison of function pointers tracing: Remove igrab() iput() call from uprobes.c tracing: Fix bad use of igrab in trace_uprobe.c
2 parents ecd649b + d66a270 commit f4ef6a4

5 files changed

Lines changed: 42 additions & 30 deletions

File tree

‎include/trace/events/initcall.h‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ TRACE_EVENT(initcall_start,
3131
TP_ARGS(func),
3232

3333
TP_STRUCT__entry(
34-
__field(initcall_t, func)
34+
/*
35+
* Use field_struct to avoid is_signed_type()
36+
* comparison of a function pointer
37+
*/
38+
__field_struct(initcall_t, func)
3539
),
3640

3741
TP_fast_assign(
@@ -48,8 +52,12 @@ TRACE_EVENT(initcall_finish,
4852
TP_ARGS(func, ret),
4953

5054
TP_STRUCT__entry(
51-
__field(initcall_t, func)
52-
__field(int, ret)
55+
/*
56+
* Use field_struct to avoid is_signed_type()
57+
* comparison of a function pointer
58+
*/
59+
__field_struct(initcall_t, func)
60+
__field(int, ret)
5361
),
5462

5563
TP_fast_assign(

‎kernel/events/uprobes.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset)
491491
if (!uprobe)
492492
return NULL;
493493

494-
uprobe->inode = igrab(inode);
494+
uprobe->inode = inode;
495495
uprobe->offset = offset;
496496
init_rwsem(&uprobe->register_rwsem);
497497
init_rwsem(&uprobe->consumer_rwsem);
@@ -502,7 +502,6 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset)
502502
if (cur_uprobe) {
503503
kfree(uprobe);
504504
uprobe = cur_uprobe;
505-
iput(inode);
506505
}
507506

508507
return uprobe;
@@ -701,7 +700,6 @@ static void delete_uprobe(struct uprobe *uprobe)
701700
rb_erase(&uprobe->rb_node, &uprobes_tree);
702701
spin_unlock(&uprobes_treelock);
703702
RB_CLEAR_NODE(&uprobe->rb_node); /* for uprobe_is_active() */
704-
iput(uprobe->inode);
705703
put_uprobe(uprobe);
706704
}
707705

@@ -873,7 +871,8 @@ static void __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *u
873871
* tuple). Creation refcount stops uprobe_unregister from freeing the
874872
* @uprobe even before the register operation is complete. Creation
875873
* refcount is released when the last @uc for the @uprobe
876-
* unregisters.
874+
* unregisters. Caller of uprobe_register() is required to keep @inode
875+
* (and the containing mount) referenced.
877876
*
878877
* Return errno if it cannot successully install probes
879878
* else return 0 (success)

‎kernel/trace/trace_events_hist.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,6 +2466,7 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file,
24662466
else if (strcmp(modifier, "usecs") == 0)
24672467
*flags |= HIST_FIELD_FL_TIMESTAMP_USECS;
24682468
else {
2469+
hist_err("Invalid field modifier: ", modifier);
24692470
field = ERR_PTR(-EINVAL);
24702471
goto out;
24712472
}
@@ -2481,6 +2482,7 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file,
24812482
else {
24822483
field = trace_find_event_field(file->event_call, field_name);
24832484
if (!field || !field->size) {
2485+
hist_err("Couldn't find field: ", field_name);
24842486
field = ERR_PTR(-EINVAL);
24852487
goto out;
24862488
}
@@ -4913,6 +4915,16 @@ static void hist_field_print(struct seq_file *m, struct hist_field *hist_field)
49134915
seq_printf(m, "%s", field_name);
49144916
} else if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP)
49154917
seq_puts(m, "common_timestamp");
4918+
4919+
if (hist_field->flags) {
4920+
if (!(hist_field->flags & HIST_FIELD_FL_VAR_REF) &&
4921+
!(hist_field->flags & HIST_FIELD_FL_EXPR)) {
4922+
const char *flags = get_hist_field_flags(hist_field);
4923+
4924+
if (flags)
4925+
seq_printf(m, ".%s", flags);
4926+
}
4927+
}
49164928
}
49174929

49184930
static int event_hist_trigger_print(struct seq_file *m,

‎kernel/trace/trace_uprobe.c‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct trace_uprobe {
5555
struct list_head list;
5656
struct trace_uprobe_filter filter;
5757
struct uprobe_consumer consumer;
58+
struct path path;
5859
struct inode *inode;
5960
char *filename;
6061
unsigned long offset;
@@ -289,7 +290,7 @@ static void free_trace_uprobe(struct trace_uprobe *tu)
289290
for (i = 0; i < tu->tp.nr_args; i++)
290291
traceprobe_free_probe_arg(&tu->tp.args[i]);
291292

292-
iput(tu->inode);
293+
path_put(&tu->path);
293294
kfree(tu->tp.call.class->system);
294295
kfree(tu->tp.call.name);
295296
kfree(tu->filename);
@@ -363,15 +364,13 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
363364
static int create_trace_uprobe(int argc, char **argv)
364365
{
365366
struct trace_uprobe *tu;
366-
struct inode *inode;
367367
char *arg, *event, *group, *filename;
368368
char buf[MAX_EVENT_NAME_LEN];
369369
struct path path;
370370
unsigned long offset;
371371
bool is_delete, is_return;
372372
int i, ret;
373373

374-
inode = NULL;
375374
ret = 0;
376375
is_delete = false;
377376
is_return = false;
@@ -437,21 +436,16 @@ static int create_trace_uprobe(int argc, char **argv)
437436
}
438437
/* Find the last occurrence, in case the path contains ':' too. */
439438
arg = strrchr(argv[1], ':');
440-
if (!arg) {
441-
ret = -EINVAL;
442-
goto fail_address_parse;
443-
}
439+
if (!arg)
440+
return -EINVAL;
444441

445442
*arg++ = '\0';
446443
filename = argv[1];
447444
ret = kern_path(filename, LOOKUP_FOLLOW, &path);
448445
if (ret)
449-
goto fail_address_parse;
450-
451-
inode = igrab(d_real_inode(path.dentry));
452-
path_put(&path);
446+
return ret;
453447

454-
if (!inode || !S_ISREG(inode->i_mode)) {
448+
if (!d_is_reg(path.dentry)) {
455449
ret = -EINVAL;
456450
goto fail_address_parse;
457451
}
@@ -490,7 +484,7 @@ static int create_trace_uprobe(int argc, char **argv)
490484
goto fail_address_parse;
491485
}
492486
tu->offset = offset;
493-
tu->inode = inode;
487+
tu->path = path;
494488
tu->filename = kstrdup(filename, GFP_KERNEL);
495489

496490
if (!tu->filename) {
@@ -558,7 +552,7 @@ static int create_trace_uprobe(int argc, char **argv)
558552
return ret;
559553

560554
fail_address_parse:
561-
iput(inode);
555+
path_put(&path);
562556

563557
pr_info("Failed to parse address or file.\n");
564558

@@ -922,6 +916,7 @@ probe_event_enable(struct trace_uprobe *tu, struct trace_event_file *file,
922916
goto err_flags;
923917

924918
tu->consumer.filter = filter;
919+
tu->inode = d_real_inode(tu->path.dentry);
925920
ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
926921
if (ret)
927922
goto err_buffer;
@@ -967,6 +962,7 @@ probe_event_disable(struct trace_uprobe *tu, struct trace_event_file *file)
967962
WARN_ON(!uprobe_filter_is_empty(&tu->filter));
968963

969964
uprobe_unregister(tu->inode, tu->offset, &tu->consumer);
965+
tu->inode = NULL;
970966
tu->tp.flags &= file ? ~TP_FLAG_TRACE : ~TP_FLAG_PROFILE;
971967

972968
uprobe_buffer_disable();
@@ -1337,19 +1333,15 @@ struct trace_event_call *
13371333
create_local_trace_uprobe(char *name, unsigned long offs, bool is_return)
13381334
{
13391335
struct trace_uprobe *tu;
1340-
struct inode *inode;
13411336
struct path path;
13421337
int ret;
13431338

13441339
ret = kern_path(name, LOOKUP_FOLLOW, &path);
13451340
if (ret)
13461341
return ERR_PTR(ret);
13471342

1348-
inode = igrab(d_inode(path.dentry));
1349-
path_put(&path);
1350-
1351-
if (!inode || !S_ISREG(inode->i_mode)) {
1352-
iput(inode);
1343+
if (!d_is_reg(path.dentry)) {
1344+
path_put(&path);
13531345
return ERR_PTR(-EINVAL);
13541346
}
13551347

@@ -1364,11 +1356,12 @@ create_local_trace_uprobe(char *name, unsigned long offs, bool is_return)
13641356
if (IS_ERR(tu)) {
13651357
pr_info("Failed to allocate trace_uprobe.(%d)\n",
13661358
(int)PTR_ERR(tu));
1359+
path_put(&path);
13671360
return ERR_CAST(tu);
13681361
}
13691362

13701363
tu->offset = offs;
1371-
tu->inode = inode;
1364+
tu->path = path;
13721365
tu->filename = kstrdup(name, GFP_KERNEL);
13731366
init_trace_event_call(tu, &tu->tp.call);
13741367

‎kernel/tracepoint.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
207207
lockdep_is_held(&tracepoints_mutex));
208208
old = func_add(&tp_funcs, func, prio);
209209
if (IS_ERR(old)) {
210-
WARN_ON_ONCE(1);
210+
WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
211211
return PTR_ERR(old);
212212
}
213213

@@ -239,7 +239,7 @@ static int tracepoint_remove_func(struct tracepoint *tp,
239239
lockdep_is_held(&tracepoints_mutex));
240240
old = func_remove(&tp_funcs, func);
241241
if (IS_ERR(old)) {
242-
WARN_ON_ONCE(1);
242+
WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
243243
return PTR_ERR(old);
244244
}
245245

0 commit comments

Comments
 (0)