diff mbox series

[2/3] tracing/kprobe: Remove unneeded WARN_ON_ONCE() in selftests

Message ID 171805480405.52471.13982671291270977479.stgit@devnote2 (mailing list archive)
State Superseded
Headers show
Series tracing: Fix some selftest issues | expand

Commit Message

Masami Hiramatsu (Google) June 10, 2024, 9:26 p.m. UTC
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Since the kprobe-events selftest shows OK or NG with the reason, the
WARN_ON_ONCE()s for each place are redundant. Let's remove it.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/trace_kprobe.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Steven Rostedt June 10, 2024, 9:40 p.m. UTC | #1
On Tue, 11 Jun 2024 06:26:44 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Since the kprobe-events selftest shows OK or NG with the reason, the
> WARN_ON_ONCE()s for each place are redundant. Let's remove it.

Note, the ktests we run to validate commits, fail when it detects a WARN()
triggered.

If this fails in any configuration, ktest will not detect it failed.

-- Steve


> 
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
>  kernel/trace/trace_kprobe.c |   26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
Masami Hiramatsu (Google) June 11, 2024, 12:07 a.m. UTC | #2
On Mon, 10 Jun 2024 17:40:52 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Tue, 11 Jun 2024 06:26:44 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > 
> > Since the kprobe-events selftest shows OK or NG with the reason, the
> > WARN_ON_ONCE()s for each place are redundant. Let's remove it.
> 
> Note, the ktests we run to validate commits, fail when it detects a WARN()
> triggered.
> 
> If this fails in any configuration, ktest will not detect it failed.

Hmm, I think there are 2 options,
 - remove pr_warn() instead. (WARN_ON_ONCE + pr_warn is redundant)
 - Or, remove WARN_ON_ONCE() from each place, but add WARN_ON_ONCE() when
   `warn` is not zero.

Thank you,

> 
> -- Steve
> 
> 
> > 
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> >  kernel/trace/trace_kprobe.c |   26 +++++++++++++-------------
> >  1 file changed, 13 insertions(+), 13 deletions(-)
>
Steven Rostedt June 11, 2024, 12:18 a.m. UTC | #3
On Tue, 11 Jun 2024 06:26:44 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Since the kprobe-events selftest shows OK or NG with the reason, the
> WARN_ON_ONCE()s for each place are redundant. Let's remove it.
> 
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
>  kernel/trace/trace_kprobe.c |   26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 16383247bdbf..4abed36544d0 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -2023,18 +2023,18 @@ static __init int kprobe_trace_self_tests_init(void)
>  	pr_info("Testing kprobe tracing: ");
>  
>  	ret = create_or_delete_trace_kprobe("p:testprobe kprobe_trace_selftest_target $stack $stack0 +0($stack)");
> -	if (WARN_ON_ONCE(ret)) {
> +	if (ret) {
>  		pr_warn("error on probing function entry.\n");

Actually, you can consolidate this to:

	if (WARN_ONCE(ret, "error on probing function entry."))

>  		warn++;
>  	} else {
>  		/* Enable trace point */
>  		tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM);
> -		if (WARN_ON_ONCE(tk == NULL)) {
> +		if (tk == NULL) {
>  			pr_warn("error on getting new probe.\n");

And this to:

		if (WARN_ONCE(tk == NULL, "error on getting new probe."))

end so on.

-- Steve

>  			warn++;
>  		} else {
>  			file = find_trace_probe_file(tk, top_trace_array());
> -			if (WARN_ON_ONCE(file == NULL)) {
> +			if (file == NULL) {
>  				pr_warn("error on getting probe file.\n");
>  				warn++;
>  			} else
> @@ -2044,18 +2044,18 @@ static __init int kprobe_trace_self_tests_init(void)
>  	}
>  
>  	ret = create_or_delete_trace_kprobe("r:testprobe2 kprobe_trace_selftest_target $retval");
> -	if (WARN_ON_ONCE(ret)) {
> +	if (ret) {
>  		pr_warn("error on probing function return.\n");
>  		warn++;
>  	} else {
>  		/* Enable trace point */
>  		tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM);
> -		if (WARN_ON_ONCE(tk == NULL)) {
> +		if (tk == NULL) {
>  			pr_warn("error on getting 2nd new probe.\n");
>  			warn++;
>  		} else {
>  			file = find_trace_probe_file(tk, top_trace_array());
> -			if (WARN_ON_ONCE(file == NULL)) {
> +			if (file == NULL) {
>  				pr_warn("error on getting probe file.\n");
>  				warn++;
>  			} else
> @@ -2079,7 +2079,7 @@ static __init int kprobe_trace_self_tests_init(void)
>  
>  	/* Disable trace points before removing it */
>  	tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM);
> -	if (WARN_ON_ONCE(tk == NULL)) {
> +	if (tk == NULL) {
>  		pr_warn("error on getting test probe.\n");
>  		warn++;
>  	} else {
> @@ -2089,7 +2089,7 @@ static __init int kprobe_trace_self_tests_init(void)
>  		}
>  
>  		file = find_trace_probe_file(tk, top_trace_array());
> -		if (WARN_ON_ONCE(file == NULL)) {
> +		if (file == NULL) {
>  			pr_warn("error on getting probe file.\n");
>  			warn++;
>  		} else
> @@ -2098,7 +2098,7 @@ static __init int kprobe_trace_self_tests_init(void)
>  	}
>  
>  	tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM);
> -	if (WARN_ON_ONCE(tk == NULL)) {
> +	if (tk == NULL) {
>  		pr_warn("error on getting 2nd test probe.\n");
>  		warn++;
>  	} else {
> @@ -2108,7 +2108,7 @@ static __init int kprobe_trace_self_tests_init(void)
>  		}
>  
>  		file = find_trace_probe_file(tk, top_trace_array());
> -		if (WARN_ON_ONCE(file == NULL)) {
> +		if (file == NULL) {
>  			pr_warn("error on getting probe file.\n");
>  			warn++;
>  		} else
> @@ -2117,20 +2117,20 @@ static __init int kprobe_trace_self_tests_init(void)
>  	}
>  
>  	ret = create_or_delete_trace_kprobe("-:testprobe");
> -	if (WARN_ON_ONCE(ret)) {
> +	if (ret) {
>  		pr_warn("error on deleting a probe.\n");
>  		warn++;
>  	}
>  
>  	ret = create_or_delete_trace_kprobe("-:testprobe2");
> -	if (WARN_ON_ONCE(ret)) {
> +	if (ret) {
>  		pr_warn("error on deleting a probe.\n");
>  		warn++;
>  	}
>  
>  end:
>  	ret = dyn_events_release_all(&trace_kprobe_ops);
> -	if (WARN_ON_ONCE(ret)) {
> +	if (ret) {
>  		pr_warn("error on cleaning up probes.\n");
>  		warn++;
>  	}
Masami Hiramatsu (Google) June 11, 2024, 6:11 a.m. UTC | #4
On Mon, 10 Jun 2024 20:18:13 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Tue, 11 Jun 2024 06:26:44 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > 
> > Since the kprobe-events selftest shows OK or NG with the reason, the
> > WARN_ON_ONCE()s for each place are redundant. Let's remove it.
> > 
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> >  kernel/trace/trace_kprobe.c |   26 +++++++++++++-------------
> >  1 file changed, 13 insertions(+), 13 deletions(-)
> > 
> > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> > index 16383247bdbf..4abed36544d0 100644
> > --- a/kernel/trace/trace_kprobe.c
> > +++ b/kernel/trace/trace_kprobe.c
> > @@ -2023,18 +2023,18 @@ static __init int kprobe_trace_self_tests_init(void)
> >  	pr_info("Testing kprobe tracing: ");
> >  
> >  	ret = create_or_delete_trace_kprobe("p:testprobe kprobe_trace_selftest_target $stack $stack0 +0($stack)");
> > -	if (WARN_ON_ONCE(ret)) {
> > +	if (ret) {
> >  		pr_warn("error on probing function entry.\n");
> 
> Actually, you can consolidate this to:
> 
> 	if (WARN_ONCE(ret, "error on probing function entry."))

Ahh, OK, let me update it.

> 
> >  		warn++;
> >  	} else {
> >  		/* Enable trace point */
> >  		tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM);
> > -		if (WARN_ON_ONCE(tk == NULL)) {
> > +		if (tk == NULL) {
> >  			pr_warn("error on getting new probe.\n");
> 
> And this to:
> 
> 		if (WARN_ONCE(tk == NULL, "error on getting new probe."))

Thank you!

> 
> end so on.
> 
> -- Steve
> 
> >  			warn++;
> >  		} else {
> >  			file = find_trace_probe_file(tk, top_trace_array());
> > -			if (WARN_ON_ONCE(file == NULL)) {
> > +			if (file == NULL) {
> >  				pr_warn("error on getting probe file.\n");
> >  				warn++;
> >  			} else
> > @@ -2044,18 +2044,18 @@ static __init int kprobe_trace_self_tests_init(void)
> >  	}
> >  
> >  	ret = create_or_delete_trace_kprobe("r:testprobe2 kprobe_trace_selftest_target $retval");
> > -	if (WARN_ON_ONCE(ret)) {
> > +	if (ret) {
> >  		pr_warn("error on probing function return.\n");
> >  		warn++;
> >  	} else {
> >  		/* Enable trace point */
> >  		tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM);
> > -		if (WARN_ON_ONCE(tk == NULL)) {
> > +		if (tk == NULL) {
> >  			pr_warn("error on getting 2nd new probe.\n");
> >  			warn++;
> >  		} else {
> >  			file = find_trace_probe_file(tk, top_trace_array());
> > -			if (WARN_ON_ONCE(file == NULL)) {
> > +			if (file == NULL) {
> >  				pr_warn("error on getting probe file.\n");
> >  				warn++;
> >  			} else
> > @@ -2079,7 +2079,7 @@ static __init int kprobe_trace_self_tests_init(void)
> >  
> >  	/* Disable trace points before removing it */
> >  	tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM);
> > -	if (WARN_ON_ONCE(tk == NULL)) {
> > +	if (tk == NULL) {
> >  		pr_warn("error on getting test probe.\n");
> >  		warn++;
> >  	} else {
> > @@ -2089,7 +2089,7 @@ static __init int kprobe_trace_self_tests_init(void)
> >  		}
> >  
> >  		file = find_trace_probe_file(tk, top_trace_array());
> > -		if (WARN_ON_ONCE(file == NULL)) {
> > +		if (file == NULL) {
> >  			pr_warn("error on getting probe file.\n");
> >  			warn++;
> >  		} else
> > @@ -2098,7 +2098,7 @@ static __init int kprobe_trace_self_tests_init(void)
> >  	}
> >  
> >  	tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM);
> > -	if (WARN_ON_ONCE(tk == NULL)) {
> > +	if (tk == NULL) {
> >  		pr_warn("error on getting 2nd test probe.\n");
> >  		warn++;
> >  	} else {
> > @@ -2108,7 +2108,7 @@ static __init int kprobe_trace_self_tests_init(void)
> >  		}
> >  
> >  		file = find_trace_probe_file(tk, top_trace_array());
> > -		if (WARN_ON_ONCE(file == NULL)) {
> > +		if (file == NULL) {
> >  			pr_warn("error on getting probe file.\n");
> >  			warn++;
> >  		} else
> > @@ -2117,20 +2117,20 @@ static __init int kprobe_trace_self_tests_init(void)
> >  	}
> >  
> >  	ret = create_or_delete_trace_kprobe("-:testprobe");
> > -	if (WARN_ON_ONCE(ret)) {
> > +	if (ret) {
> >  		pr_warn("error on deleting a probe.\n");
> >  		warn++;
> >  	}
> >  
> >  	ret = create_or_delete_trace_kprobe("-:testprobe2");
> > -	if (WARN_ON_ONCE(ret)) {
> > +	if (ret) {
> >  		pr_warn("error on deleting a probe.\n");
> >  		warn++;
> >  	}
> >  
> >  end:
> >  	ret = dyn_events_release_all(&trace_kprobe_ops);
> > -	if (WARN_ON_ONCE(ret)) {
> > +	if (ret) {
> >  		pr_warn("error on cleaning up probes.\n");
> >  		warn++;
> >  	}
>
diff mbox series

Patch

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 16383247bdbf..4abed36544d0 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -2023,18 +2023,18 @@  static __init int kprobe_trace_self_tests_init(void)
 	pr_info("Testing kprobe tracing: ");
 
 	ret = create_or_delete_trace_kprobe("p:testprobe kprobe_trace_selftest_target $stack $stack0 +0($stack)");
-	if (WARN_ON_ONCE(ret)) {
+	if (ret) {
 		pr_warn("error on probing function entry.\n");
 		warn++;
 	} else {
 		/* Enable trace point */
 		tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM);
-		if (WARN_ON_ONCE(tk == NULL)) {
+		if (tk == NULL) {
 			pr_warn("error on getting new probe.\n");
 			warn++;
 		} else {
 			file = find_trace_probe_file(tk, top_trace_array());
-			if (WARN_ON_ONCE(file == NULL)) {
+			if (file == NULL) {
 				pr_warn("error on getting probe file.\n");
 				warn++;
 			} else
@@ -2044,18 +2044,18 @@  static __init int kprobe_trace_self_tests_init(void)
 	}
 
 	ret = create_or_delete_trace_kprobe("r:testprobe2 kprobe_trace_selftest_target $retval");
-	if (WARN_ON_ONCE(ret)) {
+	if (ret) {
 		pr_warn("error on probing function return.\n");
 		warn++;
 	} else {
 		/* Enable trace point */
 		tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM);
-		if (WARN_ON_ONCE(tk == NULL)) {
+		if (tk == NULL) {
 			pr_warn("error on getting 2nd new probe.\n");
 			warn++;
 		} else {
 			file = find_trace_probe_file(tk, top_trace_array());
-			if (WARN_ON_ONCE(file == NULL)) {
+			if (file == NULL) {
 				pr_warn("error on getting probe file.\n");
 				warn++;
 			} else
@@ -2079,7 +2079,7 @@  static __init int kprobe_trace_self_tests_init(void)
 
 	/* Disable trace points before removing it */
 	tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM);
-	if (WARN_ON_ONCE(tk == NULL)) {
+	if (tk == NULL) {
 		pr_warn("error on getting test probe.\n");
 		warn++;
 	} else {
@@ -2089,7 +2089,7 @@  static __init int kprobe_trace_self_tests_init(void)
 		}
 
 		file = find_trace_probe_file(tk, top_trace_array());
-		if (WARN_ON_ONCE(file == NULL)) {
+		if (file == NULL) {
 			pr_warn("error on getting probe file.\n");
 			warn++;
 		} else
@@ -2098,7 +2098,7 @@  static __init int kprobe_trace_self_tests_init(void)
 	}
 
 	tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM);
-	if (WARN_ON_ONCE(tk == NULL)) {
+	if (tk == NULL) {
 		pr_warn("error on getting 2nd test probe.\n");
 		warn++;
 	} else {
@@ -2108,7 +2108,7 @@  static __init int kprobe_trace_self_tests_init(void)
 		}
 
 		file = find_trace_probe_file(tk, top_trace_array());
-		if (WARN_ON_ONCE(file == NULL)) {
+		if (file == NULL) {
 			pr_warn("error on getting probe file.\n");
 			warn++;
 		} else
@@ -2117,20 +2117,20 @@  static __init int kprobe_trace_self_tests_init(void)
 	}
 
 	ret = create_or_delete_trace_kprobe("-:testprobe");
-	if (WARN_ON_ONCE(ret)) {
+	if (ret) {
 		pr_warn("error on deleting a probe.\n");
 		warn++;
 	}
 
 	ret = create_or_delete_trace_kprobe("-:testprobe2");
-	if (WARN_ON_ONCE(ret)) {
+	if (ret) {
 		pr_warn("error on deleting a probe.\n");
 		warn++;
 	}
 
 end:
 	ret = dyn_events_release_all(&trace_kprobe_ops);
-	if (WARN_ON_ONCE(ret)) {
+	if (ret) {
 		pr_warn("error on cleaning up probes.\n");
 		warn++;
 	}