Commit 0376bde1 authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt

ftrace: Add ftrace_rec_counter() macro to simplify the code

The ftrace dynamic record has a flags element that also has a counter.
Instead of hard coding "rec->flags & ~FTRACE_FL_MASK" all over the
place. Use a macro instead.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent cf2cb0b2
...@@ -328,6 +328,8 @@ enum { ...@@ -328,6 +328,8 @@ enum {
#define FTRACE_FL_MASK (FTRACE_FL_MASKED_BITS << FTRACE_REF_MAX_SHIFT) #define FTRACE_FL_MASK (FTRACE_FL_MASKED_BITS << FTRACE_REF_MAX_SHIFT)
#define FTRACE_REF_MAX ((1UL << FTRACE_REF_MAX_SHIFT) - 1) #define FTRACE_REF_MAX ((1UL << FTRACE_REF_MAX_SHIFT) - 1)
#define ftrace_rec_count(rec) ((rec)->flags & ~FTRACE_FL_MASK)
struct dyn_ftrace { struct dyn_ftrace {
unsigned long ip; /* address of mcount call-site */ unsigned long ip; /* address of mcount call-site */
unsigned long flags; unsigned long flags;
......
...@@ -1592,7 +1592,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops, ...@@ -1592,7 +1592,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
if (inc) { if (inc) {
rec->flags++; rec->flags++;
if (FTRACE_WARN_ON((rec->flags & ~FTRACE_FL_MASK) == FTRACE_REF_MAX)) if (FTRACE_WARN_ON(ftrace_rec_count(rec) == FTRACE_REF_MAX))
return; return;
/* /*
* If any ops wants regs saved for this function * If any ops wants regs saved for this function
...@@ -1601,7 +1601,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops, ...@@ -1601,7 +1601,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) if (ops->flags & FTRACE_OPS_FL_SAVE_REGS)
rec->flags |= FTRACE_FL_REGS; rec->flags |= FTRACE_FL_REGS;
} else { } else {
if (FTRACE_WARN_ON((rec->flags & ~FTRACE_FL_MASK) == 0)) if (FTRACE_WARN_ON(ftrace_rec_count(rec) == 0))
return; return;
rec->flags--; rec->flags--;
/* /*
...@@ -1610,7 +1610,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops, ...@@ -1610,7 +1610,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
* still any ops for this record that wants regs. * still any ops for this record that wants regs.
* If not, we can stop recording them. * If not, we can stop recording them.
*/ */
if ((rec->flags & ~FTRACE_FL_MASK) > 0 && if (ftrace_rec_count(rec) > 0 &&
rec->flags & FTRACE_FL_REGS && rec->flags & FTRACE_FL_REGS &&
ops->flags & FTRACE_OPS_FL_SAVE_REGS) { ops->flags & FTRACE_OPS_FL_SAVE_REGS) {
if (!test_rec_ops_needs_regs(rec)) if (!test_rec_ops_needs_regs(rec))
...@@ -1700,7 +1700,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update) ...@@ -1700,7 +1700,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update)
* If we are disabling calls, then disable all records that * If we are disabling calls, then disable all records that
* are enabled. * are enabled.
*/ */
if (enable && (rec->flags & ~FTRACE_FL_MASK)) if (enable && ftrace_rec_count(rec))
flag = FTRACE_FL_ENABLED; flag = FTRACE_FL_ENABLED;
/* /*
...@@ -1746,7 +1746,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update) ...@@ -1746,7 +1746,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update)
if (update) { if (update) {
/* If there's no more users, clear all flags */ /* If there's no more users, clear all flags */
if (!(rec->flags & ~FTRACE_FL_MASK)) if (!ftrace_rec_count(rec))
rec->flags = 0; rec->flags = 0;
else else
/* Just disable the record (keep REGS state) */ /* Just disable the record (keep REGS state) */
...@@ -2685,7 +2685,7 @@ static int t_show(struct seq_file *m, void *v) ...@@ -2685,7 +2685,7 @@ static int t_show(struct seq_file *m, void *v)
seq_printf(m, "%ps", (void *)rec->ip); seq_printf(m, "%ps", (void *)rec->ip);
if (iter->flags & FTRACE_ITER_ENABLED) if (iter->flags & FTRACE_ITER_ENABLED)
seq_printf(m, " (%ld)%s", seq_printf(m, " (%ld)%s",
rec->flags & ~FTRACE_FL_MASK, ftrace_rec_count(rec),
rec->flags & FTRACE_FL_REGS ? " R" : ""); rec->flags & FTRACE_FL_REGS ? " R" : "");
seq_printf(m, "\n"); seq_printf(m, "\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment