]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - kernel/trace/trace_uprobe.c
uprobes/tracing: Kill uprobe_trace_consumer, embed uprobe_consumer into trace_uprobe
[mirror_ubuntu-bionic-kernel.git] / kernel / trace / trace_uprobe.c
CommitLineData
f3f096cf
SD
1/*
2 * uprobes-based tracing events
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Copyright (C) IBM Corporation, 2010-2012
18 * Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
19 */
20
21#include <linux/module.h>
22#include <linux/uaccess.h>
23#include <linux/uprobes.h>
24#include <linux/namei.h>
b2e902f0 25#include <linux/string.h>
f3f096cf
SD
26
27#include "trace_probe.h"
28
29#define UPROBE_EVENT_SYSTEM "uprobes"
30
31/*
32 * uprobe event core functions
33 */
f3f096cf
SD
34struct trace_uprobe {
35 struct list_head list;
36 struct ftrace_event_class class;
37 struct ftrace_event_call call;
a932b738 38 struct uprobe_consumer consumer;
f3f096cf
SD
39 struct inode *inode;
40 char *filename;
41 unsigned long offset;
42 unsigned long nhit;
43 unsigned int flags; /* For TP_FLAG_* */
44 ssize_t size; /* trace entry size */
45 unsigned int nr_args;
46 struct probe_arg args[];
47};
48
49#define SIZEOF_TRACE_UPROBE(n) \
50 (offsetof(struct trace_uprobe, args) + \
51 (sizeof(struct probe_arg) * (n)))
52
53static int register_uprobe_event(struct trace_uprobe *tu);
54static void unregister_uprobe_event(struct trace_uprobe *tu);
55
56static DEFINE_MUTEX(uprobe_lock);
57static LIST_HEAD(uprobe_list);
58
59static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs);
60
61/*
62 * Allocate new trace_uprobe and initialize it (including uprobes).
63 */
64static struct trace_uprobe *
65alloc_trace_uprobe(const char *group, const char *event, int nargs)
66{
67 struct trace_uprobe *tu;
68
69 if (!event || !is_good_name(event))
70 return ERR_PTR(-EINVAL);
71
72 if (!group || !is_good_name(group))
73 return ERR_PTR(-EINVAL);
74
75 tu = kzalloc(SIZEOF_TRACE_UPROBE(nargs), GFP_KERNEL);
76 if (!tu)
77 return ERR_PTR(-ENOMEM);
78
79 tu->call.class = &tu->class;
80 tu->call.name = kstrdup(event, GFP_KERNEL);
81 if (!tu->call.name)
82 goto error;
83
84 tu->class.system = kstrdup(group, GFP_KERNEL);
85 if (!tu->class.system)
86 goto error;
87
88 INIT_LIST_HEAD(&tu->list);
a932b738 89 tu->consumer.handler = uprobe_dispatcher;
f3f096cf
SD
90 return tu;
91
92error:
93 kfree(tu->call.name);
94 kfree(tu);
95
96 return ERR_PTR(-ENOMEM);
97}
98
99static void free_trace_uprobe(struct trace_uprobe *tu)
100{
101 int i;
102
103 for (i = 0; i < tu->nr_args; i++)
104 traceprobe_free_probe_arg(&tu->args[i]);
105
106 iput(tu->inode);
107 kfree(tu->call.class->system);
108 kfree(tu->call.name);
109 kfree(tu->filename);
110 kfree(tu);
111}
112
113static struct trace_uprobe *find_probe_event(const char *event, const char *group)
114{
115 struct trace_uprobe *tu;
116
117 list_for_each_entry(tu, &uprobe_list, list)
118 if (strcmp(tu->call.name, event) == 0 &&
119 strcmp(tu->call.class->system, group) == 0)
120 return tu;
121
122 return NULL;
123}
124
125/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
126static void unregister_trace_uprobe(struct trace_uprobe *tu)
127{
128 list_del(&tu->list);
129 unregister_uprobe_event(tu);
130 free_trace_uprobe(tu);
131}
132
133/* Register a trace_uprobe and probe_event */
134static int register_trace_uprobe(struct trace_uprobe *tu)
135{
136 struct trace_uprobe *old_tp;
137 int ret;
138
139 mutex_lock(&uprobe_lock);
140
141 /* register as an event */
142 old_tp = find_probe_event(tu->call.name, tu->call.class->system);
143 if (old_tp)
144 /* delete old event */
145 unregister_trace_uprobe(old_tp);
146
147 ret = register_uprobe_event(tu);
148 if (ret) {
149 pr_warning("Failed to register probe event(%d)\n", ret);
150 goto end;
151 }
152
153 list_add_tail(&tu->list, &uprobe_list);
154
155end:
156 mutex_unlock(&uprobe_lock);
157
158 return ret;
159}
160
161/*
162 * Argument syntax:
163 * - Add uprobe: p[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS]
164 *
165 * - Remove uprobe: -:[GRP/]EVENT
166 */
167static int create_trace_uprobe(int argc, char **argv)
168{
169 struct trace_uprobe *tu;
170 struct inode *inode;
171 char *arg, *event, *group, *filename;
172 char buf[MAX_EVENT_NAME_LEN];
173 struct path path;
174 unsigned long offset;
175 bool is_delete;
176 int i, ret;
177
178 inode = NULL;
179 ret = 0;
180 is_delete = false;
181 event = NULL;
182 group = NULL;
183
184 /* argc must be >= 1 */
185 if (argv[0][0] == '-')
186 is_delete = true;
187 else if (argv[0][0] != 'p') {
0d13ac96 188 pr_info("Probe definition must be started with 'p' or '-'.\n");
f3f096cf
SD
189 return -EINVAL;
190 }
191
192 if (argv[0][1] == ':') {
193 event = &argv[0][2];
194 arg = strchr(event, '/');
195
196 if (arg) {
197 group = event;
198 event = arg + 1;
199 event[-1] = '\0';
200
201 if (strlen(group) == 0) {
202 pr_info("Group name is not specified\n");
203 return -EINVAL;
204 }
205 }
206 if (strlen(event) == 0) {
207 pr_info("Event name is not specified\n");
208 return -EINVAL;
209 }
210 }
211 if (!group)
212 group = UPROBE_EVENT_SYSTEM;
213
214 if (is_delete) {
215 if (!event) {
216 pr_info("Delete command needs an event name.\n");
217 return -EINVAL;
218 }
219 mutex_lock(&uprobe_lock);
220 tu = find_probe_event(event, group);
221
222 if (!tu) {
223 mutex_unlock(&uprobe_lock);
224 pr_info("Event %s/%s doesn't exist.\n", group, event);
225 return -ENOENT;
226 }
227 /* delete an event */
228 unregister_trace_uprobe(tu);
229 mutex_unlock(&uprobe_lock);
230 return 0;
231 }
232
233 if (argc < 2) {
234 pr_info("Probe point is not specified.\n");
235 return -EINVAL;
236 }
237 if (isdigit(argv[1][0])) {
238 pr_info("probe point must be have a filename.\n");
239 return -EINVAL;
240 }
241 arg = strchr(argv[1], ':');
242 if (!arg)
243 goto fail_address_parse;
244
245 *arg++ = '\0';
246 filename = argv[1];
247 ret = kern_path(filename, LOOKUP_FOLLOW, &path);
248 if (ret)
249 goto fail_address_parse;
250
f3f096cf 251 inode = igrab(path.dentry->d_inode);
84d7ed79
ON
252 path_put(&path);
253
7e4e28c5 254 if (!inode || !S_ISREG(inode->i_mode)) {
d24d7dbf
JZ
255 ret = -EINVAL;
256 goto fail_address_parse;
257 }
f3f096cf 258
84d7ed79
ON
259 ret = kstrtoul(arg, 0, &offset);
260 if (ret)
261 goto fail_address_parse;
262
f3f096cf
SD
263 argc -= 2;
264 argv += 2;
265
266 /* setup a probe */
267 if (!event) {
b2e902f0 268 char *tail;
f3f096cf
SD
269 char *ptr;
270
b2e902f0
AS
271 tail = kstrdup(kbasename(filename), GFP_KERNEL);
272 if (!tail) {
f3f096cf
SD
273 ret = -ENOMEM;
274 goto fail_address_parse;
275 }
276
f3f096cf
SD
277 ptr = strpbrk(tail, ".-_");
278 if (ptr)
279 *ptr = '\0';
280
281 snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_0x%lx", 'p', tail, offset);
282 event = buf;
283 kfree(tail);
284 }
285
286 tu = alloc_trace_uprobe(group, event, argc);
287 if (IS_ERR(tu)) {
288 pr_info("Failed to allocate trace_uprobe.(%d)\n", (int)PTR_ERR(tu));
289 ret = PTR_ERR(tu);
290 goto fail_address_parse;
291 }
292 tu->offset = offset;
293 tu->inode = inode;
294 tu->filename = kstrdup(filename, GFP_KERNEL);
295
296 if (!tu->filename) {
297 pr_info("Failed to allocate filename.\n");
298 ret = -ENOMEM;
299 goto error;
300 }
301
302 /* parse arguments */
303 ret = 0;
304 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
305 /* Increment count for freeing args in error case */
306 tu->nr_args++;
307
308 /* Parse argument name */
309 arg = strchr(argv[i], '=');
310 if (arg) {
311 *arg++ = '\0';
312 tu->args[i].name = kstrdup(argv[i], GFP_KERNEL);
313 } else {
314 arg = argv[i];
315 /* If argument name is omitted, set "argN" */
316 snprintf(buf, MAX_EVENT_NAME_LEN, "arg%d", i + 1);
317 tu->args[i].name = kstrdup(buf, GFP_KERNEL);
318 }
319
320 if (!tu->args[i].name) {
321 pr_info("Failed to allocate argument[%d] name.\n", i);
322 ret = -ENOMEM;
323 goto error;
324 }
325
326 if (!is_good_name(tu->args[i].name)) {
327 pr_info("Invalid argument[%d] name: %s\n", i, tu->args[i].name);
328 ret = -EINVAL;
329 goto error;
330 }
331
332 if (traceprobe_conflict_field_name(tu->args[i].name, tu->args, i)) {
333 pr_info("Argument[%d] name '%s' conflicts with "
334 "another field.\n", i, argv[i]);
335 ret = -EINVAL;
336 goto error;
337 }
338
339 /* Parse fetch argument */
340 ret = traceprobe_parse_probe_arg(arg, &tu->size, &tu->args[i], false, false);
341 if (ret) {
342 pr_info("Parse error at argument[%d]. (%d)\n", i, ret);
343 goto error;
344 }
345 }
346
347 ret = register_trace_uprobe(tu);
348 if (ret)
349 goto error;
350 return 0;
351
352error:
353 free_trace_uprobe(tu);
354 return ret;
355
356fail_address_parse:
357 if (inode)
358 iput(inode);
359
d24d7dbf 360 pr_info("Failed to parse address or file.\n");
f3f096cf
SD
361
362 return ret;
363}
364
365static void cleanup_all_probes(void)
366{
367 struct trace_uprobe *tu;
368
369 mutex_lock(&uprobe_lock);
370 while (!list_empty(&uprobe_list)) {
371 tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
372 unregister_trace_uprobe(tu);
373 }
374 mutex_unlock(&uprobe_lock);
375}
376
377/* Probes listing interfaces */
378static void *probes_seq_start(struct seq_file *m, loff_t *pos)
379{
380 mutex_lock(&uprobe_lock);
381 return seq_list_start(&uprobe_list, *pos);
382}
383
384static void *probes_seq_next(struct seq_file *m, void *v, loff_t *pos)
385{
386 return seq_list_next(v, &uprobe_list, pos);
387}
388
389static void probes_seq_stop(struct seq_file *m, void *v)
390{
391 mutex_unlock(&uprobe_lock);
392}
393
394static int probes_seq_show(struct seq_file *m, void *v)
395{
396 struct trace_uprobe *tu = v;
397 int i;
398
399 seq_printf(m, "p:%s/%s", tu->call.class->system, tu->call.name);
400 seq_printf(m, " %s:0x%p", tu->filename, (void *)tu->offset);
401
402 for (i = 0; i < tu->nr_args; i++)
403 seq_printf(m, " %s=%s", tu->args[i].name, tu->args[i].comm);
404
405 seq_printf(m, "\n");
406 return 0;
407}
408
409static const struct seq_operations probes_seq_op = {
410 .start = probes_seq_start,
411 .next = probes_seq_next,
412 .stop = probes_seq_stop,
413 .show = probes_seq_show
414};
415
416static int probes_open(struct inode *inode, struct file *file)
417{
418 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC))
419 cleanup_all_probes();
420
421 return seq_open(file, &probes_seq_op);
422}
423
424static ssize_t probes_write(struct file *file, const char __user *buffer,
425 size_t count, loff_t *ppos)
426{
427 return traceprobe_probes_write(file, buffer, count, ppos, create_trace_uprobe);
428}
429
430static const struct file_operations uprobe_events_ops = {
431 .owner = THIS_MODULE,
432 .open = probes_open,
433 .read = seq_read,
434 .llseek = seq_lseek,
435 .release = seq_release,
436 .write = probes_write,
437};
438
439/* Probes profiling interfaces */
440static int probes_profile_seq_show(struct seq_file *m, void *v)
441{
442 struct trace_uprobe *tu = v;
443
444 seq_printf(m, " %s %-44s %15lu\n", tu->filename, tu->call.name, tu->nhit);
445 return 0;
446}
447
448static const struct seq_operations profile_seq_op = {
449 .start = probes_seq_start,
450 .next = probes_seq_next,
451 .stop = probes_seq_stop,
452 .show = probes_profile_seq_show
453};
454
455static int profile_open(struct inode *inode, struct file *file)
456{
457 return seq_open(file, &profile_seq_op);
458}
459
460static const struct file_operations uprobe_profile_ops = {
461 .owner = THIS_MODULE,
462 .open = profile_open,
463 .read = seq_read,
464 .llseek = seq_lseek,
465 .release = seq_release,
466};
467
468/* uprobe handler */
469static void uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
470{
471 struct uprobe_trace_entry_head *entry;
472 struct ring_buffer_event *event;
473 struct ring_buffer *buffer;
474 u8 *data;
475 int size, i, pc;
476 unsigned long irq_flags;
477 struct ftrace_event_call *call = &tu->call;
478
479 tu->nhit++;
480
481 local_save_flags(irq_flags);
482 pc = preempt_count();
483
484 size = sizeof(*entry) + tu->size;
485
486 event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
487 size, irq_flags, pc);
488 if (!event)
489 return;
490
491 entry = ring_buffer_event_data(event);
74e59dfc 492 entry->ip = instruction_pointer(task_pt_regs(current));
f3f096cf
SD
493 data = (u8 *)&entry[1];
494 for (i = 0; i < tu->nr_args; i++)
495 call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);
496
497 if (!filter_current_check_discard(buffer, call, entry, event))
498 trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
499}
500
501/* Event entry printers */
502static enum print_line_t
503print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *event)
504{
505 struct uprobe_trace_entry_head *field;
506 struct trace_seq *s = &iter->seq;
507 struct trace_uprobe *tu;
508 u8 *data;
509 int i;
510
511 field = (struct uprobe_trace_entry_head *)iter->ent;
512 tu = container_of(event, struct trace_uprobe, call.event);
513
514 if (!trace_seq_printf(s, "%s: (", tu->call.name))
515 goto partial;
516
517 if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET))
518 goto partial;
519
520 if (!trace_seq_puts(s, ")"))
521 goto partial;
522
523 data = (u8 *)&field[1];
524 for (i = 0; i < tu->nr_args; i++) {
525 if (!tu->args[i].type->print(s, tu->args[i].name,
526 data + tu->args[i].offset, field))
527 goto partial;
528 }
529
530 if (trace_seq_puts(s, "\n"))
531 return TRACE_TYPE_HANDLED;
532
533partial:
534 return TRACE_TYPE_PARTIAL_LINE;
535}
536
b64b0077
ON
537static inline bool is_trace_uprobe_enabled(struct trace_uprobe *tu)
538{
539 return tu->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE);
540}
541
f3f096cf
SD
542static int probe_event_enable(struct trace_uprobe *tu, int flag)
543{
f3f096cf
SD
544 int ret = 0;
545
b64b0077 546 if (is_trace_uprobe_enabled(tu))
f3f096cf
SD
547 return -EINTR;
548
4161824f 549 tu->flags |= flag;
a932b738
ON
550 ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
551 if (ret)
4161824f 552 tu->flags &= ~flag;
f3f096cf 553
4161824f 554 return ret;
f3f096cf
SD
555}
556
557static void probe_event_disable(struct trace_uprobe *tu, int flag)
558{
b64b0077 559 if (!is_trace_uprobe_enabled(tu))
f3f096cf
SD
560 return;
561
a932b738 562 uprobe_unregister(tu->inode, tu->offset, &tu->consumer);
f3f096cf 563 tu->flags &= ~flag;
f3f096cf
SD
564}
565
566static int uprobe_event_define_fields(struct ftrace_event_call *event_call)
567{
568 int ret, i;
569 struct uprobe_trace_entry_head field;
570 struct trace_uprobe *tu = (struct trace_uprobe *)event_call->data;
571
572 DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0);
573 /* Set argument names as fields */
574 for (i = 0; i < tu->nr_args; i++) {
575 ret = trace_define_field(event_call, tu->args[i].type->fmttype,
576 tu->args[i].name,
577 sizeof(field) + tu->args[i].offset,
578 tu->args[i].type->size,
579 tu->args[i].type->is_signed,
580 FILTER_OTHER);
581
582 if (ret)
583 return ret;
584 }
585 return 0;
586}
587
588#define LEN_OR_ZERO (len ? len - pos : 0)
589static int __set_print_fmt(struct trace_uprobe *tu, char *buf, int len)
590{
591 const char *fmt, *arg;
592 int i;
593 int pos = 0;
594
595 fmt = "(%lx)";
596 arg = "REC->" FIELD_STRING_IP;
597
598 /* When len=0, we just calculate the needed length */
599
600 pos += snprintf(buf + pos, LEN_OR_ZERO, "\"%s", fmt);
601
602 for (i = 0; i < tu->nr_args; i++) {
603 pos += snprintf(buf + pos, LEN_OR_ZERO, " %s=%s",
604 tu->args[i].name, tu->args[i].type->fmt);
605 }
606
607 pos += snprintf(buf + pos, LEN_OR_ZERO, "\", %s", arg);
608
609 for (i = 0; i < tu->nr_args; i++) {
610 pos += snprintf(buf + pos, LEN_OR_ZERO, ", REC->%s",
611 tu->args[i].name);
612 }
613
614 return pos; /* return the length of print_fmt */
615}
616#undef LEN_OR_ZERO
617
618static int set_print_fmt(struct trace_uprobe *tu)
619{
620 char *print_fmt;
621 int len;
622
623 /* First: called with 0 length to calculate the needed length */
624 len = __set_print_fmt(tu, NULL, 0);
625 print_fmt = kmalloc(len + 1, GFP_KERNEL);
626 if (!print_fmt)
627 return -ENOMEM;
628
629 /* Second: actually write the @print_fmt */
630 __set_print_fmt(tu, print_fmt, len + 1);
631 tu->call.print_fmt = print_fmt;
632
633 return 0;
634}
635
636#ifdef CONFIG_PERF_EVENTS
637/* uprobe profile handler */
638static void uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
639{
640 struct ftrace_event_call *call = &tu->call;
641 struct uprobe_trace_entry_head *entry;
642 struct hlist_head *head;
643 u8 *data;
644 int size, __size, i;
645 int rctx;
646
647 __size = sizeof(*entry) + tu->size;
648 size = ALIGN(__size + sizeof(u32), sizeof(u64));
649 size -= sizeof(u32);
650 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
651 return;
652
653 preempt_disable();
654
655 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
656 if (!entry)
657 goto out;
658
74e59dfc 659 entry->ip = instruction_pointer(task_pt_regs(current));
f3f096cf
SD
660 data = (u8 *)&entry[1];
661 for (i = 0; i < tu->nr_args; i++)
662 call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);
663
664 head = this_cpu_ptr(call->perf_events);
e6dab5ff 665 perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs, head, NULL);
f3f096cf
SD
666
667 out:
668 preempt_enable();
669}
670#endif /* CONFIG_PERF_EVENTS */
671
672static
673int trace_uprobe_register(struct ftrace_event_call *event, enum trace_reg type, void *data)
674{
675 struct trace_uprobe *tu = (struct trace_uprobe *)event->data;
676
677 switch (type) {
678 case TRACE_REG_REGISTER:
679 return probe_event_enable(tu, TP_FLAG_TRACE);
680
681 case TRACE_REG_UNREGISTER:
682 probe_event_disable(tu, TP_FLAG_TRACE);
683 return 0;
684
685#ifdef CONFIG_PERF_EVENTS
686 case TRACE_REG_PERF_REGISTER:
687 return probe_event_enable(tu, TP_FLAG_PROFILE);
688
689 case TRACE_REG_PERF_UNREGISTER:
690 probe_event_disable(tu, TP_FLAG_PROFILE);
691 return 0;
692#endif
693 default:
694 return 0;
695 }
696 return 0;
697}
698
699static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
700{
f3f096cf
SD
701 struct trace_uprobe *tu;
702
a932b738 703 tu = container_of(con, struct trace_uprobe, consumer);
f3f096cf
SD
704
705 if (tu->flags & TP_FLAG_TRACE)
706 uprobe_trace_func(tu, regs);
707
708#ifdef CONFIG_PERF_EVENTS
709 if (tu->flags & TP_FLAG_PROFILE)
710 uprobe_perf_func(tu, regs);
711#endif
712 return 0;
713}
714
715static struct trace_event_functions uprobe_funcs = {
716 .trace = print_uprobe_event
717};
718
719static int register_uprobe_event(struct trace_uprobe *tu)
720{
721 struct ftrace_event_call *call = &tu->call;
722 int ret;
723
724 /* Initialize ftrace_event_call */
725 INIT_LIST_HEAD(&call->class->fields);
726 call->event.funcs = &uprobe_funcs;
727 call->class->define_fields = uprobe_event_define_fields;
728
729 if (set_print_fmt(tu) < 0)
730 return -ENOMEM;
731
732 ret = register_ftrace_event(&call->event);
733 if (!ret) {
734 kfree(call->print_fmt);
735 return -ENODEV;
736 }
737 call->flags = 0;
738 call->class->reg = trace_uprobe_register;
739 call->data = tu;
740 ret = trace_add_event_call(call);
741
742 if (ret) {
743 pr_info("Failed to register uprobe event: %s\n", call->name);
744 kfree(call->print_fmt);
745 unregister_ftrace_event(&call->event);
746 }
747
748 return ret;
749}
750
751static void unregister_uprobe_event(struct trace_uprobe *tu)
752{
753 /* tu->event is unregistered in trace_remove_event_call() */
754 trace_remove_event_call(&tu->call);
755 kfree(tu->call.print_fmt);
756 tu->call.print_fmt = NULL;
757}
758
759/* Make a trace interface for controling probe points */
760static __init int init_uprobe_trace(void)
761{
762 struct dentry *d_tracer;
763
764 d_tracer = tracing_init_dentry();
765 if (!d_tracer)
766 return 0;
767
768 trace_create_file("uprobe_events", 0644, d_tracer,
769 NULL, &uprobe_events_ops);
770 /* Profile interface */
771 trace_create_file("uprobe_profile", 0444, d_tracer,
772 NULL, &uprobe_profile_ops);
773 return 0;
774}
775
776fs_initcall(init_uprobe_trace);