Skip to content

Commit c20489d

Browse files
committed
ftrace: Assign iter->hash to filter or notrace hashes on seq read
Instead of testing if the hash to use is the filter_hash or the notrace_hash at each iteration, do the test at open, and set the iter->hash to point to the corresponding filter or notrace hash. Then use that directly instead of testing which hash needs to be used each iteration. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent c1bc591 commit c20489d

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

kernel/trace/ftrace.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,6 @@ static void *
31573157
t_next(struct seq_file *m, void *v, loff_t *pos)
31583158
{
31593159
struct ftrace_iterator *iter = m->private;
3160-
struct ftrace_ops *ops = iter->ops;
31613160
struct dyn_ftrace *rec = NULL;
31623161

31633162
if (unlikely(ftrace_disabled))
@@ -3181,11 +3180,8 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
31813180
}
31823181
} else {
31833182
rec = &iter->pg->records[iter->idx++];
3184-
if (((iter->flags & FTRACE_ITER_FILTER) &&
3185-
!(ftrace_lookup_ip(ops->func_hash->filter_hash, rec->ip))) ||
3186-
3187-
((iter->flags & FTRACE_ITER_NOTRACE) &&
3188-
!ftrace_lookup_ip(ops->func_hash->notrace_hash, rec->ip)) ||
3183+
if (((iter->flags & (FTRACE_ITER_FILTER | FTRACE_ITER_NOTRACE)) &&
3184+
!ftrace_lookup_ip(iter->hash, rec->ip)) ||
31893185

31903186
((iter->flags & FTRACE_ITER_ENABLED) &&
31913187
!(rec->flags & FTRACE_FL_ENABLED))) {
@@ -3213,7 +3209,6 @@ static void reset_iter_read(struct ftrace_iterator *iter)
32133209
static void *t_start(struct seq_file *m, loff_t *pos)
32143210
{
32153211
struct ftrace_iterator *iter = m->private;
3216-
struct ftrace_ops *ops = iter->ops;
32173212
void *p = NULL;
32183213
loff_t l;
32193214

@@ -3233,10 +3228,8 @@ static void *t_start(struct seq_file *m, loff_t *pos)
32333228
* off, we can short cut and just print out that all
32343229
* functions are enabled.
32353230
*/
3236-
if ((iter->flags & FTRACE_ITER_FILTER &&
3237-
ftrace_hash_empty(ops->func_hash->filter_hash)) ||
3238-
(iter->flags & FTRACE_ITER_NOTRACE &&
3239-
ftrace_hash_empty(ops->func_hash->notrace_hash))) {
3231+
if ((iter->flags & (FTRACE_ITER_FILTER | FTRACE_ITER_NOTRACE)) &&
3232+
ftrace_hash_empty(iter->hash)) {
32403233
if (*pos > 0)
32413234
return t_hash_start(m, pos);
32423235
iter->flags |= FTRACE_ITER_PRINTALL;
@@ -3442,7 +3435,8 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag,
34423435
ret = -ENOMEM;
34433436
goto out_unlock;
34443437
}
3445-
}
3438+
} else
3439+
iter->hash = hash;
34463440

34473441
if (file->f_mode & FMODE_READ) {
34483442
iter->pg = ftrace_pages_start;
@@ -4526,6 +4520,9 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
45264520
free_ftrace_hash_rcu(old_hash);
45274521
}
45284522
mutex_unlock(&ftrace_lock);
4523+
} else {
4524+
/* For read only, the hash is the ops hash */
4525+
iter->hash = NULL;
45294526
}
45304527

45314528
mutex_unlock(&iter->ops->func_hash->regex_lock);

0 commit comments

Comments
 (0)