Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing/probe: Add probe event name and group name accesses APIs

Add trace_probe_name() and trace_probe_group_name() functions
for accessing probe name and group name of trace_probe.

Link: http://lkml.kernel.org/r/155931586717.28323.8738615064952254761.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
b55ce203 747774d6

+33 -23
+12 -12
kernel/trace/trace_kprobe.c
··· 142 142 { 143 143 struct trace_kprobe *tk = to_trace_kprobe(ev); 144 144 145 - return strcmp(trace_event_name(&tk->tp.call), event) == 0 && 146 - (!system || strcmp(tk->tp.call.class->system, system) == 0); 145 + return strcmp(trace_probe_name(&tk->tp), event) == 0 && 146 + (!system || strcmp(trace_probe_group_name(&tk->tp), system) == 0); 147 147 } 148 148 149 149 static nokprobe_inline unsigned long trace_kprobe_nhit(struct trace_kprobe *tk) ··· 263 263 struct trace_kprobe *tk; 264 264 265 265 for_each_trace_kprobe(tk, pos) 266 - if (strcmp(trace_event_name(&tk->tp.call), event) == 0 && 267 - strcmp(tk->tp.call.class->system, group) == 0) 266 + if (strcmp(trace_probe_name(&tk->tp), event) == 0 && 267 + strcmp(trace_probe_group_name(&tk->tp), group) == 0) 268 268 return tk; 269 269 return NULL; 270 270 } ··· 453 453 mutex_lock(&event_mutex); 454 454 455 455 /* Delete old (same name) event if exist */ 456 - old_tk = find_trace_kprobe(trace_event_name(&tk->tp.call), 457 - tk->tp.call.class->system); 456 + old_tk = find_trace_kprobe(trace_probe_name(&tk->tp), 457 + trace_probe_group_name(&tk->tp)); 458 458 if (old_tk) { 459 459 ret = unregister_trace_kprobe(old_tk); 460 460 if (ret < 0) ··· 507 507 ret = __register_trace_kprobe(tk); 508 508 if (ret) 509 509 pr_warn("Failed to re-register probe %s on %s: %d\n", 510 - trace_event_name(&tk->tp.call), 510 + trace_probe_name(&tk->tp), 511 511 mod->name, ret); 512 512 } 513 513 } ··· 737 737 int i; 738 738 739 739 seq_putc(m, trace_kprobe_is_return(tk) ? 'r' : 'p'); 740 - seq_printf(m, ":%s/%s", tk->tp.call.class->system, 741 - trace_event_name(&tk->tp.call)); 740 + seq_printf(m, ":%s/%s", trace_probe_group_name(&tk->tp), 741 + trace_probe_name(&tk->tp)); 742 742 743 743 if (!tk->symbol) 744 744 seq_printf(m, " 0x%p", tk->rp.kp.addr); ··· 812 812 813 813 tk = to_trace_kprobe(ev); 814 814 seq_printf(m, " %-44s %15lu %15lu\n", 815 - trace_event_name(&tk->tp.call), 815 + trace_probe_name(&tk->tp), 816 816 trace_kprobe_nhit(tk), 817 817 tk->rp.kp.nmissed); 818 818 ··· 1084 1084 field = (struct kprobe_trace_entry_head *)iter->ent; 1085 1085 tp = container_of(event, struct trace_probe, call.event); 1086 1086 1087 - trace_seq_printf(s, "%s: (", trace_event_name(&tp->call)); 1087 + trace_seq_printf(s, "%s: (", trace_probe_name(tp)); 1088 1088 1089 1089 if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET)) 1090 1090 goto out; ··· 1111 1111 field = (struct kretprobe_trace_entry_head *)iter->ent; 1112 1112 tp = container_of(event, struct trace_probe, call.event); 1113 1113 1114 - trace_seq_printf(s, "%s: (", trace_event_name(&tp->call)); 1114 + trace_seq_printf(s, "%s: (", trace_probe_name(tp)); 1115 1115 1116 1116 if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET)) 1117 1117 goto out;
+10
kernel/trace/trace_probe.h
··· 266 266 return trace_probe_test_flag(tp, TP_FLAG_REGISTERED); 267 267 } 268 268 269 + static inline const char *trace_probe_name(struct trace_probe *tp) 270 + { 271 + return trace_event_name(&tp->call); 272 + } 273 + 274 + static inline const char *trace_probe_group_name(struct trace_probe *tp) 275 + { 276 + return tp->call.class->system; 277 + } 278 + 269 279 static inline int trace_probe_unregister_event_call(struct trace_probe *tp) 270 280 { 271 281 /* tp->event is unregistered in trace_remove_event_call() */
+11 -11
kernel/trace/trace_uprobe.c
··· 289 289 { 290 290 struct trace_uprobe *tu = to_trace_uprobe(ev); 291 291 292 - return strcmp(trace_event_name(&tu->tp.call), event) == 0 && 293 - (!system || strcmp(tu->tp.call.class->system, system) == 0); 292 + return strcmp(trace_probe_name(&tu->tp), event) == 0 && 293 + (!system || strcmp(trace_probe_group_name(&tu->tp), system) == 0); 294 294 } 295 295 296 296 /* ··· 340 340 struct trace_uprobe *tu; 341 341 342 342 for_each_trace_uprobe(tu, pos) 343 - if (strcmp(trace_event_name(&tu->tp.call), event) == 0 && 344 - strcmp(tu->tp.call.class->system, group) == 0) 343 + if (strcmp(trace_probe_name(&tu->tp), event) == 0 && 344 + strcmp(trace_probe_group_name(&tu->tp), group) == 0) 345 345 return tu; 346 346 347 347 return NULL; ··· 376 376 struct trace_uprobe *tmp, *old = NULL; 377 377 struct inode *new_inode = d_real_inode(new->path.dentry); 378 378 379 - old = find_probe_event(trace_event_name(&new->tp.call), 380 - new->tp.call.class->system); 379 + old = find_probe_event(trace_probe_name(&new->tp), 380 + trace_probe_group_name(&new->tp)); 381 381 382 382 for_each_trace_uprobe(tmp, pos) { 383 383 if ((old ? old != tmp : true) && ··· 624 624 char c = is_ret_probe(tu) ? 'r' : 'p'; 625 625 int i; 626 626 627 - seq_printf(m, "%c:%s/%s %s:0x%0*lx", c, tu->tp.call.class->system, 628 - trace_event_name(&tu->tp.call), tu->filename, 627 + seq_printf(m, "%c:%s/%s %s:0x%0*lx", c, trace_probe_group_name(&tu->tp), 628 + trace_probe_name(&tu->tp), tu->filename, 629 629 (int)(sizeof(void *) * 2), tu->offset); 630 630 631 631 if (tu->ref_ctr_offset) ··· 695 695 696 696 tu = to_trace_uprobe(ev); 697 697 seq_printf(m, " %s %-44s %15lu\n", tu->filename, 698 - trace_event_name(&tu->tp.call), tu->nhit); 698 + trace_probe_name(&tu->tp), tu->nhit); 699 699 return 0; 700 700 } 701 701 ··· 896 896 897 897 if (is_ret_probe(tu)) { 898 898 trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)", 899 - trace_event_name(&tu->tp.call), 899 + trace_probe_name(&tu->tp), 900 900 entry->vaddr[1], entry->vaddr[0]); 901 901 data = DATAOF_TRACE_ENTRY(entry, true); 902 902 } else { 903 903 trace_seq_printf(s, "%s: (0x%lx)", 904 - trace_event_name(&tu->tp.call), 904 + trace_probe_name(&tu->tp), 905 905 entry->vaddr[0]); 906 906 data = DATAOF_TRACE_ENTRY(entry, false); 907 907 }