Skip to contentSkip to conversation

rcuscale: Do a proper cleanup if kfree_scale_init() fails

PATCH Superseded Uladzislau Rezki (Sony) 3 participants 5 messages Oct 24, 2024 – Oct 28, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Uladzislau Rezki (Sony)

author maintainer
#0 lore raw

PATCH 1/2 rcuscale: Do a proper cleanup if kfree_scale_init() fails

A static analyzer for C, Smatch, reports and triggers below warnings:

kernel/rcu/rcuscale.c:1215 rcu_scale_init()
warn: inconsistent returns 'global &fullstop_mutex'.

The checker complains about, we do not unlock the "fullstop_mutex" mutex, in case of hitting below error path:

<snip>
...

    if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
        pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
        WARN_ON_ONCE(1);
        return -1;
        ^^^^^^^^^^

...
<snip>

it happens because "-1" is returned right away instead of doing a proper unwinding.

Fix it by jumping to "unwind" label instead of returning -1.

Fixes 084e04fff160 ("rcuscale: Add laziness and kfree tests")
---
 kernel/rcu/rcuscale.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcuscale.c +2 -2
index 6d37596deb1f..de7d511e6be4 100644
@@ -890,13 +890,13 @@ kfree_scale_init(void)
 		if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
 			pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
 			WARN_ON_ONCE(1);
-			return -1;
+			goto unwind;
 		}
 
 		if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
 			pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
 			WARN_ON_ONCE(1);
-			return -1;
+			goto unwind;
 		}
 	}
 
Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 2/2 rcuscale: Remove redundant WARN_ON_ONCE() splat

There are two places where WARN_ON_ONCE() is called two times in the error paths. One which is encapsulated into if() condition and another one, which is unnecessary, is placed in the brackets.

Remove an extra WARN_ON_ONCE() splat which is in brackets.

---
 kernel/rcu/rcuscale.c | 2 --
 1 file changed, 2 deletions(-)
kernel/rcu/rcuscale.c +0 -2
index de7d511e6be4..1d8bb603c289 100644
@@ -889,13 +889,11 @@ kfree_scale_init(void)
 
 		if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
 			pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
-			WARN_ON_ONCE(1);
 			goto unwind;
 		}
 
 		if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
 			pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
-			WARN_ON_ONCE(1);
 			goto unwind;
 		}
 	}
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat

Quoted 7 lines · Uladzislau Rezki (Sony)

There are two places where WARN_ON_ONCE() is called two times in the error paths. One which is encapsulated into if() condition and another one, which is unnecessary, is placed in the brackets.

Remove an extra WARN_ON_ONCE() splat which is in brackets.

For both:

Quoted 25 lines
---
 kernel/rcu/rcuscale.c | 2 --
 1 file changed, 2 deletions(-)
kernel/rcu/rcuscale.c +0 -2
index de7d511e6be4..1d8bb603c289 100644
@@ -889,13 +889,11 @@ kfree_scale_init(void)
 
 		if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
 			pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
-			WARN_ON_ONCE(1);
 			goto unwind;
 		}
 
 		if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
 			pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
-			WARN_ON_ONCE(1);
 			goto unwind;
 		}
 	}
Signature · 1 line
2.39.5
author maintainer
#3 lore raw

Re: [PATCH 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat

Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · Uladzislau Rezki (Sony)

There are two places where WARN_ON_ONCE() is called two times in the error paths. One which is encapsulated into if() condition and another one, which is unnecessary, is placed in the brackets.

Quoted 8 lines
Quoted 3 lines

Remove an extra WARN_ON_ONCE() splat which is in brackets.

For both:

Thank you :)

--
Uladzislau Rezki

#4 lore raw

Re: [PATCH 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · Uladzislau Rezki (Sony)

There are two places where WARN_ON_ONCE() is called two times in the error paths. One which is encapsulated into if() condition and another one, which is unnecessary, is placed in the brackets.

Quoted 7 lines
Quoted 3 lines

Remove an extra WARN_ON_ONCE() splat which is in brackets.

For both:

Both applied!

Thanks.