summaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-03 22:09:43 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-20 22:06:38 -0400
commit1a93f8bd19bd24f9b41136e70188d8f4de90c6a2 (patch)
treed9e0142c4e5ac7f5f38b789d45c3cd65f67bbfb8 /kernel/trace/trace.c
parent41794f190780c28784fa62b22001691e5876d149 (diff)
tracing: Have the snapshot trigger use the mapping helper functions
As the data pointer for individual ips will soon be removed and no longer passed to the callback function probe handlers, convert the snapshot trigger counter over to the new ftrace_func_mapper helper functions. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 41e9a20f91f0..7febeb823c62 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6745,13 +6745,19 @@ static void
6745ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip, 6745ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip,
6746 struct ftrace_probe_ops *ops, void **data) 6746 struct ftrace_probe_ops *ops, void **data)
6747{ 6747{
6748 unsigned long *count = (long *)data; 6748 struct ftrace_func_mapper *mapper = ops->private_data;
6749 long *count = NULL;
6749 6750
6750 if (!*count) 6751 if (mapper)
6751 return; 6752 count = (long *)ftrace_func_mapper_find_ip(mapper, ip);
6753
6754 if (count) {
6755
6756 if (*count <= 0)
6757 return;
6752 6758
6753 if (*count != -1)
6754 (*count)--; 6759 (*count)--;
6760 }
6755 6761
6756 tracing_snapshot(); 6762 tracing_snapshot();
6757} 6763}
@@ -6760,20 +6766,42 @@ static int
6760ftrace_snapshot_print(struct seq_file *m, unsigned long ip, 6766ftrace_snapshot_print(struct seq_file *m, unsigned long ip,
6761 struct ftrace_probe_ops *ops, void *data) 6767 struct ftrace_probe_ops *ops, void *data)
6762{ 6768{
6763 long count = (long)data; 6769 struct ftrace_func_mapper *mapper = ops->private_data;
6770 long *count = NULL;
6764 6771
6765 seq_printf(m, "%ps:", (void *)ip); 6772 seq_printf(m, "%ps:", (void *)ip);
6766 6773
6767 seq_puts(m, "snapshot"); 6774 seq_puts(m, "snapshot");
6768 6775
6769 if (count == -1) 6776 if (mapper)
6770 seq_puts(m, ":unlimited\n"); 6777 count = (long *)ftrace_func_mapper_find_ip(mapper, ip);
6778
6779 if (count)
6780 seq_printf(m, ":count=%ld\n", *count);
6771 else 6781 else
6772 seq_printf(m, ":count=%ld\n", count); 6782 seq_puts(m, ":unlimited\n");
6773 6783
6774 return 0; 6784 return 0;
6775} 6785}
6776 6786
6787static int
6788ftrace_snapshot_init(struct ftrace_probe_ops *ops, unsigned long ip,
6789 void **data)
6790{
6791 struct ftrace_func_mapper *mapper = ops->private_data;
6792
6793 return ftrace_func_mapper_add_ip(mapper, ip, *data);
6794}
6795
6796static void
6797ftrace_snapshot_free(struct ftrace_probe_ops *ops, unsigned long ip,
6798 void **_data)
6799{
6800 struct ftrace_func_mapper *mapper = ops->private_data;
6801
6802 ftrace_func_mapper_remove_ip(mapper, ip);
6803}
6804
6777static struct ftrace_probe_ops snapshot_probe_ops = { 6805static struct ftrace_probe_ops snapshot_probe_ops = {
6778 .func = ftrace_snapshot, 6806 .func = ftrace_snapshot,
6779 .print = ftrace_snapshot_print, 6807 .print = ftrace_snapshot_print,
@@ -6782,6 +6810,8 @@ static struct ftrace_probe_ops snapshot_probe_ops = {
6782static struct ftrace_probe_ops snapshot_count_probe_ops = { 6810static struct ftrace_probe_ops snapshot_count_probe_ops = {
6783 .func = ftrace_count_snapshot, 6811 .func = ftrace_count_snapshot,
6784 .print = ftrace_snapshot_print, 6812 .print = ftrace_snapshot_print,
6813 .init = ftrace_snapshot_init,
6814 .free = ftrace_snapshot_free,
6785}; 6815};
6786 6816
6787static int 6817static int
@@ -6812,6 +6842,12 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
6812 if (!strlen(number)) 6842 if (!strlen(number))
6813 goto out_reg; 6843 goto out_reg;
6814 6844
6845 if (!ops->private_data) {
6846 ops->private_data = allocate_ftrace_func_mapper();
6847 if (!ops->private_data)
6848 return -ENOMEM;
6849 }
6850
6815 /* 6851 /*
6816 * We use the callback data field (which is a pointer) 6852 * We use the callback data field (which is a pointer)
6817 * as our counter. 6853 * as our counter.