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

Showing the changes to kernel/trace (1 of 1 file). Show all

Unified · Split

kernel/trace/ftrace.c+5−10
@@ -2949,13 +2949,6 @@ ftrace_enabled_open(struct inode *inode, struct file *file) · 2948 unmodified lines
2949 return iter ? 0 : -ENOMEM;2949 return iter ? 0 : -ENOMEM;
2950}2950}
2951 2951
2952static 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
2959/**2952/**
2960 * ftrace_regex_open - initialize function tracer filter files2953 * ftrace_regex_open - initialize function tracer filter files
2961 * @ops: The ftrace_ops that hold the hash filters2954 * @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
3720 else3713 else
3721 orig_hash = &ops->notrace_hash;3714 orig_hash = &ops->notrace_hash;
3722 3715
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
3724 if (!hash) {3721 if (!hash) {
3725 ret = -ENOMEM;3722 ret = -ENOMEM;
3726 goto out_regex_unlock;3723 goto out_regex_unlock;
3727 }3724 }
3728 3725
3729 if (reset)
3730 ftrace_filter_reset(hash);
3731 if (buf && !ftrace_match_records(hash, buf, len)) {3726 if (buf && !ftrace_match_records(hash, buf, len)) {
3732 ret = -EINVAL;3727 ret = -EINVAL;
3733 goto out_regex_unlock;3728 goto out_regex_unlock;