Skip to contentSkip to conversation

ftrace: Do not copy old hash when resetting.

PATCH Superseded Wang Nan 2 participants 4 messages Jul 14, 2014 – Jul 18, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wang Nan

author
#0 lore raw

PATCH 1/1 ftrace: Do not copy old hash when resetting.

If we are going to reset hash, we don't need to duplicate old hash and remove every entries right after allocation.

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/ftrace.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +5 -3
index 5b372e3..52d6931 100644
@@ -3471,14 +3471,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 	else
 		orig_hash = &ops->notrace_hash;
 
-	hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	if (!reset)
+		hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	else
+		hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
+
 	if (!hash) {
 		ret = -ENOMEM;
 		goto out_regex_unlock;
 	}
 
-	if (reset)
-		ftrace_filter_reset(hash);
 	if (buf && !ftrace_match_records(hash, buf, len)) {
 		ret = -EINVAL;
 		goto out_regex_unlock;
Signature · 1 line
1.8.4
maintainer
#1 lore raw
Quoted 15 lines · On Mon, 14 Jul 2014 12:10:00 +0800 Wang Nan <[email protected]> wrote:

If we are going to reset hash, we don't need to duplicate old hash and remove every entries right after allocation.

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/ftrace.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +0 -0
index 5b372e3..52d6931 100644

kernel/trace/ftrace.c ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len, · line 3477

Quoted 8 lines
kernel/trace/ftrace.c +4 -1
@@ -3471,14 +3471,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 	else
 		orig_hash = &ops->notrace_hash;
 
-	hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	if (!reset)
+		hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	else
+		hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);

I'm fine with this patch, but please swap the if statement above. I prefer the if condition being positive if there's also an else statement above. That is:

	if (reset)
		hash = alloc_ftrace_hash();
	else
		hash = alloc_and_copy_ftrace_hash();

-- Steve

Quoted 11 lines
kernel/trace/ftrace.c +1 -2
+
 	if (!hash) {
 		ret = -ENOMEM;
 		goto out_regex_unlock;
 	}
 
-	if (reset)
-		ftrace_filter_reset(hash);
 	if (buf && !ftrace_match_records(hash, buf, len)) {
 		ret = -EINVAL;
 		goto out_regex_unlock;
author
#2 lore raw
In reply to Wang Nan

Hi Steve,

What's your opinion on my v2 patch ( https://lkml.org/lkml/2014/7/14/839 )?

I have swapped if consitions following your suggestion.

Quoted 35 lines · Wang Nan

If we are going to reset hash, we don't need to duplicate old hash and remove every entries right after allocation.

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/ftrace.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +5 -3
index 5b372e3..52d6931 100644
@@ -3471,14 +3471,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 	else
 		orig_hash = &ops->notrace_hash;
 
-	hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	if (!reset)
+		hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	else
+		hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
+
 	if (!hash) {
 		ret = -ENOMEM;
 		goto out_regex_unlock;
 	}
 
-	if (reset)
-		ftrace_filter_reset(hash);
 	if (buf && !ftrace_match_records(hash, buf, len)) {
 		ret = -EINVAL;
 		goto out_regex_unlock;
maintainer
#3 lore raw
Quoted 6 lines · On Fri, 18 Jul 2014 12:44:18 +0800 Wang Nan <[email protected]> wrote:

Hi Steve,

What's your opinion on my v2 patch ( https://lkml.org/lkml/2014/7/14/839 )?

I have swapped if consitions following your suggestion.

Bah I didn't see it.

Damn Claws mail, I need to figure out why the f*ck it randomly marks all my email as read. This has caused me to miss a few important emails recently :-(

It looks fine, I've now marked it as todo that way I'll see it to pull it in for 3.17. Thanks,

-- Steve

Quoted 37 lines · Wang Nan
Quoted 35 lines

If we are going to reset hash, we don't need to duplicate old hash and remove every entries right after allocation.

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/ftrace.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +5 -3
index 5b372e3..52d6931 100644
@@ -3471,14 +3471,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 	else
 		orig_hash = &ops->notrace_hash;
 
-	hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	if (!reset)
+		hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
+	else
+		hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
+
 	if (!hash) {
 		ret = -ENOMEM;
 		goto out_regex_unlock;
 	}
 
-	if (reset)
-		ftrace_filter_reset(hash);
 	if (buf && !ftrace_match_records(hash, buf, len)) {
 		ret = -EINVAL;
 		goto out_regex_unlock;