Skip to content

Commit 8c9af47

Browse files
committed
ftrace: Handle commands when closing set_ftrace_filter file
# echo switch_mm:traceoff > /sys/kernel/tracing/set_ftrace_filter will cause switch_mm to stop tracing by the traceoff command. # echo -n switch_mm:traceoff > /sys/kernel/tracing/set_ftrace_filter does nothing. The reason is that the parsing in the write function only processes commands if it finished parsing (there is white space written after the command). That's to handle: write(fd, "switch_mm:", 10); write(fd, "traceoff", 8); cases, where the command is broken over multiple writes. The problem is if the file descriptor is closed, then the write call is not processed, and the command needs to be processed in the release code. The release code can handle matching of functions, but does not handle commands. Cc: [email protected] Fixes: eda1e32 ("tracing: handle broken names in ftrace filter") Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent aafe104 commit 8c9af47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/trace/ftrace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5591,7 +5591,10 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
55915591

55925592
parser = &iter->parser;
55935593
if (trace_parser_loaded(parser)) {
5594-
ftrace_match_records(iter->hash, parser->buffer, parser->idx);
5594+
int enable = !(iter->flags & FTRACE_ITER_NOTRACE);
5595+
5596+
ftrace_process_regex(iter, parser->buffer,
5597+
parser->idx, enable);
55955598
}
55965599

55975600
trace_parser_put(parser);

0 commit comments

Comments
 (0)