Skip to content

Commit 29a1548

Browse files
Tom Zanussirostedt
authored andcommitted
tracing: Change trace_boot to use kprobe_event interface
Have trace_boot_add_kprobe_event() use the kprobe_event interface. Also, rename kprobe_event_run_cmd() to kprobe_event_run_command() now that trace_boot's version is gone. Link: http://lkml.kernel.org/r/af5429d11291ab1e9a85a0ff944af3b2bcf193c7.1580323897.git.zanussi@kernel.org Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 2a588dd commit 29a1548

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

kernel/trace/trace_boot.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,32 @@ trace_boot_enable_events(struct trace_array *tr, struct xbc_node *node)
8888
}
8989

9090
#ifdef CONFIG_KPROBE_EVENTS
91-
extern int trace_kprobe_run_command(const char *command);
92-
9391
static int __init
9492
trace_boot_add_kprobe_event(struct xbc_node *node, const char *event)
9593
{
94+
struct dynevent_cmd cmd;
9695
struct xbc_node *anode;
9796
char buf[MAX_BUF_LEN];
9897
const char *val;
99-
char *p;
100-
int len;
98+
int ret;
10199

102-
len = snprintf(buf, ARRAY_SIZE(buf) - 1, "p:kprobes/%s ", event);
103-
if (len >= ARRAY_SIZE(buf)) {
104-
pr_err("Event name is too long: %s\n", event);
105-
return -E2BIG;
106-
}
107-
p = buf + len;
108-
len = ARRAY_SIZE(buf) - len;
100+
kprobe_event_cmd_init(&cmd, buf, MAX_BUF_LEN);
101+
102+
ret = kprobe_event_gen_cmd_start(&cmd, event, NULL);
103+
if (ret)
104+
return ret;
109105

110106
xbc_node_for_each_array_value(node, "probes", anode, val) {
111-
if (strlcpy(p, val, len) >= len) {
112-
pr_err("Probe definition is too long: %s\n", val);
113-
return -E2BIG;
114-
}
115-
if (trace_kprobe_run_command(buf) < 0) {
116-
pr_err("Failed to add probe: %s\n", buf);
117-
return -EINVAL;
118-
}
107+
ret = kprobe_event_add_field(&cmd, val);
108+
if (ret)
109+
return ret;
119110
}
120111

121-
return 0;
112+
ret = kprobe_event_gen_cmd_end(&cmd);
113+
if (ret)
114+
pr_err("Failed to add probe: %s\n", buf);
115+
116+
return ret;
122117
}
123118
#else
124119
static inline int __init

kernel/trace/trace_kprobe.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,12 +901,7 @@ static int create_or_delete_trace_kprobe(int argc, char **argv)
901901
return ret == -ECANCELED ? -EINVAL : ret;
902902
}
903903

904-
int trace_kprobe_run_command(const char *command)
905-
{
906-
return trace_run_command(command, create_or_delete_trace_kprobe);
907-
}
908-
909-
static int trace_kprobe_run_cmd(struct dynevent_cmd *cmd)
904+
static int trace_kprobe_run_command(struct dynevent_cmd *cmd)
910905
{
911906
return trace_run_command(cmd->buf, create_or_delete_trace_kprobe);
912907
}
@@ -923,7 +918,7 @@ static int trace_kprobe_run_cmd(struct dynevent_cmd *cmd)
923918
void kprobe_event_cmd_init(struct dynevent_cmd *cmd, char *buf, int maxlen)
924919
{
925920
dynevent_cmd_init(cmd, buf, maxlen, DYNEVENT_TYPE_KPROBE,
926-
trace_kprobe_run_cmd);
921+
trace_kprobe_run_command);
927922
}
928923
EXPORT_SYMBOL_GPL(kprobe_event_cmd_init);
929924

0 commit comments

Comments
 (0)