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
Unified · Split
| @@ -2949,13 +2949,6 @@ ftrace_enabled_open(struct inode *inode, struct file *file) · 2948 unmodified lines | ||
| 2949 | 2949 | return iter ? 0 : -ENOMEM; |
| 2950 | 2950 | } |
| 2951 | 2951 | |
| 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 | − | |
| 2959 | 2952 | /** |
| 2960 | 2953 | * ftrace_regex_open - initialize function tracer filter files |
| 2961 | 2954 | * @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 | 3713 | else |
| 3721 | 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 | 3721 | if (!hash) { |
| 3725 | 3722 | ret = -ENOMEM; |
| 3726 | 3723 | goto out_regex_unlock; |
| 3727 | 3724 | } |
| 3728 | 3725 | |
| 3729 | − if (reset) | |
| 3730 | − ftrace_filter_reset(hash); | |
| 3731 | 3726 | if (buf && !ftrace_match_records(hash, buf, len)) { |
| 3732 | 3727 | ret = -EINVAL; |
| 3733 | 3728 | goto out_regex_unlock; |