Skip to content

Commit 7d5fda1

Browse files
committed
tracing: Fix event probe removal from dynamic events
When an event probe is to be removed via the API that created it via the dynamic events, an -ENOENT error is returned. This is because the removal of the event probe does not expect to see the event system and name that the event probe is attached to, even though that's part of the API to create it. As the removal of probes is to use the same API as they are created. In fact, the removal is not consistent with the kprobes and uprobes removal. Fix that by allowing various ways to remove the eprobe. The eprobe is created with: e:[GROUP/]NAME SYSTEM/EVENT [OPTIONS] Have it get removed by echoing in the following into dynamic_events: # Remove all eprobes with NAME echo '-:NAME' >> dynamic_events # Remove a specific eprobe echo '-:GROUP/NAME' >> dynamic_events echo '-:GROUP/NAME SYSTEM/EVENT' >> dynamic_events echo '-:NAME SYSTEM/EVENT' >> dynamic_events echo '-:GROUP/NAME SYSTEM/EVENT OPTIONS' >> dynamic_events echo '-:NAME SYSTEM/EVENT OPTIONS' >> dynamic_events Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Suggested-by: Masami Hiramatsu <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Fixes: 7491e2c ("tracing: Add a probe that attaches to trace events") Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent b26503b commit 7d5fda1

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

kernel/trace/trace_eprobe.c

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,58 @@ static bool eprobe_dyn_event_match(const char *system, const char *event,
119119
int argc, const char **argv, struct dyn_event *ev)
120120
{
121121
struct trace_eprobe *ep = to_trace_eprobe(ev);
122+
const char *slash;
122123

123-
return strcmp(trace_probe_name(&ep->tp), event) == 0 &&
124-
(!system || strcmp(trace_probe_group_name(&ep->tp), system) == 0) &&
125-
trace_probe_match_command_args(&ep->tp, argc, argv);
124+
/*
125+
* We match the following:
126+
* event only - match all eprobes with event name
127+
* system and event only - match all system/event probes
128+
*
129+
* The below has the above satisfied with more arguments:
130+
*
131+
* attached system/event - If the arg has the system and event
132+
* the probe is attached to, match
133+
* probes with the attachment.
134+
*
135+
* If any more args are given, then it requires a full match.
136+
*/
137+
138+
/*
139+
* If system exists, but this probe is not part of that system
140+
* do not match.
141+
*/
142+
if (system && strcmp(trace_probe_group_name(&ep->tp), system) != 0)
143+
return false;
144+
145+
/* Must match the event name */
146+
if (strcmp(trace_probe_name(&ep->tp), event) != 0)
147+
return false;
148+
149+
/* No arguments match all */
150+
if (argc < 1)
151+
return true;
152+
153+
/* First argument is the system/event the probe is attached to */
154+
155+
slash = strchr(argv[0], '/');
156+
if (!slash)
157+
slash = strchr(argv[0], '.');
158+
if (!slash)
159+
return false;
160+
161+
if (strncmp(ep->event_system, argv[0], slash - argv[0]))
162+
return false;
163+
if (strcmp(ep->event_name, slash + 1))
164+
return false;
165+
166+
argc--;
167+
argv++;
168+
169+
/* If there are no other args, then match */
170+
if (argc < 1)
171+
return true;
172+
173+
return trace_probe_match_command_args(&ep->tp, argc, argv);
126174
}
127175

128176
static struct dyn_event_operations eprobe_dyn_event_ops = {

0 commit comments

Comments
 (0)