Skip to content

Commit

Permalink
ftrace: Consolidate some duplicate code for updating ftrace ops
Browse files Browse the repository at this point in the history
When ftrace ops modifies the functions that it will trace, the update
to the function mcount callers may need to be modified. Consolidate
the two places that do the checks to see if an update is required
with a wrapper function for those checks.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Jul 30, 2013
1 parent bf682c3 commit 1c80c43
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,12 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
return add_hash_entry(hash, ip);
}

static void ftrace_ops_update_code(struct ftrace_ops *ops)
{
if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
ftrace_run_update_code(FTRACE_UPDATE_CALLS);
}

static int
ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
unsigned long ip, int remove, int reset, int enable)
Expand Down Expand Up @@ -3426,9 +3432,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,

mutex_lock(&ftrace_lock);
ret = ftrace_hash_move(ops, enable, orig_hash, hash);
if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED
&& ftrace_enabled)
ftrace_run_update_code(FTRACE_UPDATE_CALLS);
if (!ret)
ftrace_ops_update_code(ops);

mutex_unlock(&ftrace_lock);

Expand Down Expand Up @@ -3655,9 +3660,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
mutex_lock(&ftrace_lock);
ret = ftrace_hash_move(iter->ops, filter_hash,
orig_hash, iter->hash);
if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED)
&& ftrace_enabled)
ftrace_run_update_code(FTRACE_UPDATE_CALLS);
if (!ret)
ftrace_ops_update_code(iter->ops);

mutex_unlock(&ftrace_lock);
}
Expand Down

0 comments on commit 1c80c43

Please sign in to comment.