Skip to content

Commit 77c0edd

Browse files
committed
ftrace: Simplify ftrace_match_record() even more
Dan Carpenter sent a patch to remove a check in ftrace_match_record() because the logic of the code made the check redundant. I looked deeper into the code, and made the following logic table, with the three variables and the result of the original code. modname mod_matches exclude_mod result ------- ----------- ----------- ------ 0 0 0 return 0 0 0 1 func_match 0 1 * < cannot exist > 1 0 0 return 0 1 0 1 func_match 1 1 0 func_match 1 1 1 return 0 Notice that when mod_matches == exclude mod, the result is always to return 0, and when mod_matches != exclude_mod, then the result is to test the function. This means we only need test if mod_matches is equal to exclude_mod. Cc: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 31805c9 commit 77c0edd

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

kernel/trace/ftrace.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,22 +3631,20 @@ ftrace_match_record(struct dyn_ftrace *rec, struct ftrace_glob *func_g,
36313631
/* blank module name to match all modules */
36323632
if (!mod_g->len) {
36333633
/* blank module globbing: modname xor exclude_mod */
3634-
if ((!exclude_mod) != (!modname))
3634+
if (!exclude_mod != !modname)
36353635
goto func_match;
36363636
return 0;
36373637
}
36383638

3639-
/* not matching the module */
3640-
if (!modname || !mod_matches) {
3641-
if (exclude_mod)
3642-
goto func_match;
3643-
else
3644-
return 0;
3645-
}
3646-
3647-
if (exclude_mod)
3639+
/*
3640+
* exclude_mod is set to trace everything but the given
3641+
* module. If it is set and the module matches, then
3642+
* return 0. If it is not set, and the module doesn't match
3643+
* also return 0. Otherwise, check the function to see if
3644+
* that matches.
3645+
*/
3646+
if (!mod_matches == !exclude_mod)
36483647
return 0;
3649-
36503648
func_match:
36513649
/* blank search means to match all funcs in the mod */
36523650
if (!func_g->len)

0 commit comments

Comments
 (0)