rcuscale: Do a proper cleanup if kfree_scale_init() fails
Subsystems (2)
Uladzislau Rezki (Sony)
maintainerPATCH v2 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.
--- kernel/rcu/rcuscale.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/rcu/rcuscale.c +4 -2
@@ -890,13 +890,15 @@ 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 ; + firsterr =-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 ; + firsterr =-1 ; + goto unwind; } }
Signature · 1 line
2.39.5
Uladzislau Rezki (Sony)
maintainerPATCH v2 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
@@ -889,14 +889,12 @@ 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 ); firsterr =-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 ); firsterr =-1 ; goto unwind; }
Signature · 1 line
2.39.5
Re: [PATCH v2 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat
Quoted 9 lines · Uladzislau Rezki (Sony)
There are two places where
WARN_ON_ONCE()is called two times in the error paths. One which is encapsulated intoif()condition and another one, which is unnecessary, is placed in the brackets.Remove an extra
WARN_ON_ONCE()splat which is in brackets.Reviewed-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>---
- Neeraj
Quoted 22 lines · Uladzislau Rezki (Sony)
A static analyzer for C, Smatch, reports and triggers below warnings:
kernel/rcu/rcuscale.c:1215rcu_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.
Quoted 8 lines
Fix it by jumping to "unwind" label instead of returning -1.
Reviewed-by Paul E. McKenney <[email protected]>Reported-by Dan Carpenter <[email protected]>Fixes 084e04fff160 ("rcuscale: Add laziness and kfree tests")Signed-off-by Uladzislau Rezki (Sony) <[email protected]>---
- Neeraj