History

ftrace: Do not copy old hash when resetting

Do not waste time copying the old hash if the hash is going to be reset. Just allocate a new hash and free the old one, as that is the same result as copying te old one and then resetting it. Link: http://lkml.kernel.org/p/1405384820-48837-1-git-send-email-wangnan0@huawei.com

Wang Nan committed 12 years ago

Commit b972cc51 parent 6508fa71 file · +5 −10Browse files

Unified · Split

kernel/trace/ftrace.c+5−10
@@ -2949,13 +2949,6 @@ ftrace_enabled_open(struct inode *inode, struct file *file) · 2948 unmodified lines
29492949 return iter ? 0 : -ENOMEM;
29502950 }
29512951
2952−static void ftrace_filter_reset(struct ftrace_hash *hash)
2953−{
2954− mutex_lock(&ftrace_lock);
2955− ftrace_hash_clear(hash);
2956− mutex_unlock(&ftrace_lock);
2957−}
2958−
29592952 /**
29602953 * ftrace_regex_open - initialize function tracer filter files
29612954 * @ops: The ftrace_ops that hold the hash filters
@@ -3720,14 +3713,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len, · 758 unmodified lines
37203713 else
37213714 orig_hash = &ops->notrace_hash;
37223715
3723− hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
3716+ if (reset)
3717+ hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
3718+ else
3719+ hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
3720+
37243721 if (!hash) {
37253722 ret = -ENOMEM;
37263723 goto out_regex_unlock;
37273724 }
37283725
3729− if (reset)
3730− ftrace_filter_reset(hash);
37313726 if (buf && !ftrace_match_records(hash, buf, len)) {
37323727 ret = -EINVAL;
37333728 goto out_regex_unlock;