Function test_rec_ops_needs_regs() tests whether ftrace_ops registered on a record needs saved regs. That is, it tests for FTRACE_OPS_FL_SAVE_REGS being set. The same logic will be reused for newly introduced FTRACE_OPS_FL_PERMANENT flag, so make the function generic. Signed-off-by: Miroslav Benes <mbenes@xxxxxxx> --- kernel/trace/ftrace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 62a50bf399d6..a37c1127599c 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1602,24 +1602,24 @@ int ftrace_text_reserved(const void *start, const void *end) return (int)!!ret; } -/* Test if ops registered to this rec needs regs */ -static bool test_rec_ops_needs_regs(struct dyn_ftrace *rec) +/* Test if ops registered to this rec needs to have a specified flag set */ +static bool test_rec_ops_needs_flag(struct dyn_ftrace *rec, int flag) { struct ftrace_ops *ops; - bool keep_regs = false; + bool keep_flag = false; for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) { /* pass rec in as regs to have non-NULL val */ if (ftrace_ops_test(ops, rec->ip, rec)) { - if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) { - keep_regs = true; + if (ops->flags & flag) { + keep_flag = true; break; } } } - return keep_regs; + return keep_flag; } static struct ftrace_ops * @@ -1750,7 +1750,8 @@ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops, if (ftrace_rec_count(rec) > 0 && rec->flags & FTRACE_FL_REGS && ops->flags & FTRACE_OPS_FL_SAVE_REGS) { - if (!test_rec_ops_needs_regs(rec)) + if (!test_rec_ops_needs_flag(rec, + FTRACE_OPS_FL_SAVE_REGS)) rec->flags &= ~FTRACE_FL_REGS; } -- 2.23.0