aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-05-03 11:41:44 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-05-03 22:15:13 -0400
commit77c0eddeeeee14bf0fb0c0bb97e782981bbcf084 (patch)
tree0e5c2135c8d4364668ede155ee0b7522537f6c24
parent31805c90521ea75dfa3d016fc94f581da6a40fee (diff)
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>
-rw-r--r--kernel/trace/ftrace.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 84286d347cd8..39dca4e86a94 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3631,22 +3631,20 @@ ftrace_match_record(struct dyn_ftrace *rec, struct ftrace_glob *func_g,
3631 /* blank module name to match all modules */ 3631 /* blank module name to match all modules */
3632 if (!mod_g->len) { 3632 if (!mod_g->len) {
3633 /* blank module globbing: modname xor exclude_mod */ 3633 /* blank module globbing: modname xor exclude_mod */
3634 if ((!exclude_mod) != (!modname)) 3634 if (!exclude_mod != !modname)
3635 goto func_match; 3635 goto func_match;
3636 return 0; 3636 return 0;
3637 } 3637 }
3638 3638
3639 /* not matching the module */ 3639 /*
3640 if (!modname || !mod_matches) { 3640 * exclude_mod is set to trace everything but the given
3641 if (exclude_mod) 3641 * module. If it is set and the module matches, then
3642 goto func_match; 3642 * return 0. If it is not set, and the module doesn't match
3643 else 3643 * also return 0. Otherwise, check the function to see if
3644 return 0; 3644 * that matches.
3645 } 3645 */
3646 3646 if (!mod_matches == !exclude_mod)
3647 if (exclude_mod)
3648 return 0; 3647 return 0;
3649
3650func_match: 3648func_match:
3651 /* blank search means to match all funcs in the mod */ 3649 /* blank search means to match all funcs in the mod */
3652 if (!func_g->len) 3650 if (!func_g->len)