Skip to contentSkip to conversation

rcutorture: Perform more frequent testing of ->gpwrap

bug report Dan Carpenter 3 participants 7 messages Apr 23, 2025 – Apr 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

set an error code?

    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
    4592         rcu_torture_cleanup();
    4593         if (shutdown_secs) {
    4594                 WARN_ON(!IS_MODULE(CONFIG_RCU_TORTURE_TEST));
    4595                 kernel_power_off();
    4596         }
    4597         return firsterr;
    4598 }

regards,
dan carpenter

#1 lore raw
Quoted 9 lines · Dan Carpenter

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'
Quoted 7 lines

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
                   ^^^^^^^^^^^^^^^^^^^

Also:

kernel/rcu/rcutorture.c:4591 rcu_torture_init() warn: double unlock 'global &fullstop_mutex' (orig line 4581)

Quoted 6 lines
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

Quoted 7 lines

set an error code?

    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
                   ^^^^^^^^^^^^^^^^^^^

regards,
dan carpenter

Quoted 10 lines
    4592         rcu_torture_cleanup();
    4593         if (shutdown_secs) {
    4594                 WARN_ON(!IS_MODULE(CONFIG_RCU_TORTURE_TEST));
    4595                 kernel_power_off();
    4596         }
    4597         return firsterr;
    4598 }

regards,
dan carpenter

maintainer
#2 lore raw
Quoted 17 lines · Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'
Quoted 7 lines

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
Quoted 4 lines
                   ^^^^^^^^^^^^^^^^^^^

Also:

kernel/rcu/rcutorture.c:4591 rcu_torture_init() warn: double unlock 'global &fullstop_mutex' (orig line 4581)

You lost me on this one. This mutex is acquired by the earlier call to torture_init_begin(), but only if that function returns true. If that function returns false, yes, it releases fullstop_mutex, but in that case rcu_torture_init() returns immediately, thus avoiding this invocation of torture_init_end().

Or am I missing something subtle here? Or missing something obvious, for that matter! ;-)

Thanx, Paul

Quoted 29 lines
Quoted 6 lines
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

Quoted 7 lines

set an error code?

    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
                   ^^^^^^^^^^^^^^^^^^^

regards,
dan carpenter

Quoted 10 lines
    4592         rcu_torture_cleanup();
    4593         if (shutdown_secs) {
    4594                 WARN_ON(!IS_MODULE(CONFIG_RCU_TORTURE_TEST));
    4595                 kernel_power_off();
    4596         }
    4597         return firsterr;
    4598 }

regards,
dan carpenter

#3 lore raw
Quoted 23 lines · Paul E. McKenney
Quoted 17 lines · Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'
Quoted 7 lines

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
Quoted 4 lines
                   ^^^^^^^^^^^^^^^^^^^

Also:

kernel/rcu/rcutorture.c:4591 rcu_torture_init() warn: double unlock 'global &fullstop_mutex' (orig line 4581)

Quoted 9 lines

You lost me on this one. This mutex is acquired by the earlier call to torture_init_begin(), but only if that function returns true. If that function returns false, yes, it releases fullstop_mutex, but in that case rcu_torture_init() returns immediately, thus avoiding this invocation of torture_init_end().

Or am I missing something subtle here? Or missing something obvious, for that matter! ;-)

I explained it badly. Joel's patch added a goto so now we call torture_init_end() twice in a row.

Quoted 9 lines

Thanx, Paul

Quoted 7 lines
Quoted 7 lines
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

set an error code?

Here is the goto.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
                   ^^^^^^^^^^^^^^^^^^^

Here is the second torture_init_end().

regards,
dan carpenter

maintainer
#4 lore raw
Quoted 50 lines · Dan Carpenter
Quoted 23 lines · Paul E. McKenney
Quoted 17 lines · Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'
Quoted 7 lines

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
Quoted 4 lines
                   ^^^^^^^^^^^^^^^^^^^

Also:

kernel/rcu/rcutorture.c:4591 rcu_torture_init() warn: double unlock 'global &fullstop_mutex' (orig line 4581)

Quoted 9 lines

You lost me on this one. This mutex is acquired by the earlier call to torture_init_begin(), but only if that function returns true. If that function returns false, yes, it releases fullstop_mutex, but in that case rcu_torture_init() returns immediately, thus avoiding this invocation of torture_init_end().

Or am I missing something subtle here? Or missing something obvious, for that matter! ;-)

I explained it badly. Joel's patch added a goto so now we call torture_init_end() twice in a row.

Quoted 9 lines

Thanx, Paul

Quoted 7 lines
Quoted 7 lines
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

set an error code?

Here is the goto.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
                   ^^^^^^^^^^^^^^^^^^^

Here is the second torture_init_end().

Ah! Thank you for persisting. Over to you, Joel!

Thanx, Paul

maintainer
#5 lore raw
Quoted 56 lines · Paul E. McKenney
Quoted 55 lines · Dan Carpenter
Quoted 23 lines · Paul E. McKenney
Quoted 17 lines · Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'
Quoted 7 lines

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
Quoted 4 lines
                   ^^^^^^^^^^^^^^^^^^^

Also:

kernel/rcu/rcutorture.c:4591 rcu_torture_init() warn: double unlock 'global &fullstop_mutex' (orig line 4581)

Quoted 9 lines

You lost me on this one. This mutex is acquired by the earlier call to torture_init_begin(), but only if that function returns true. If that function returns false, yes, it releases fullstop_mutex, but in that case rcu_torture_init() returns immediately, thus avoiding this invocation of torture_init_end().

Or am I missing something subtle here? Or missing something obvious, for that matter! ;-)

I explained it badly. Joel's patch added a goto so now we call torture_init_end() twice in a row.

Quoted 9 lines

Thanx, Paul

Quoted 7 lines
Quoted 7 lines
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

set an error code?

Here is the goto.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
                   ^^^^^^^^^^^^^^^^^^^

Here is the second torture_init_end().

Ah! Thank you for persisting. Over to you, Joel!

Oops, thanks for finding both the issues. I will move the torture_init_end() further down and run some tests. At first look, that seems like the right thing to do:

kernel/rcu/rcutorture.c +1 -1
index 92e2686a4795..bb9a8e718533 100644
@@ -4582,13 +4582,17 @@ rcu_torture_init(void)
        }
        if (object_debug)
                rcu_test_debug_objects();
-       torture_init_end();
+
        if (cur_ops->gp_slow_register &&

!WARN_ON_ONCE(!cur_ops->gp_slow_unregister))

                cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);

- if (gpwrap_lag && cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())
- goto unwind;
+ if (gpwrap_lag && cur_ops->set_gpwrap_lag) {
+ firsterr = rcu_gpwrap_lag_init();
+ if (torture_init_error(firsterr))
+ goto unwind;
+ }

+       torture_init_end();
        return 0;

unwind:

maintainer
#6 lore raw
Quoted 83 lines · Joel Fernandes
Quoted 56 lines · Paul E. McKenney
Quoted 55 lines · Dan Carpenter
Quoted 23 lines · Paul E. McKenney
Quoted 17 lines · Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Joel Fernandes,

Commit bd57ec707441 ("rcutorture: Perform more frequent testing of ->gpwrap") from Feb 16, 2025 (linux-next), leads to the following Smatch static checker warning:

	kernel/rcu/rcutorture.c:4586 rcu_torture_init()
	warn: missing error code 'firsterr'
Quoted 7 lines

kernel/rcu/rcutorture.c

    4576                 if (torture_init_error(firsterr))
    4577                         goto unwind;
    4578         }
    4579         if (object_debug)
    4580                 rcu_test_debug_objects();
    4581         torture_init_end();
Quoted 4 lines
                   ^^^^^^^^^^^^^^^^^^^

Also:

kernel/rcu/rcutorture.c:4591 rcu_torture_init() warn: double unlock 'global &fullstop_mutex' (orig line 4581)

Quoted 9 lines

You lost me on this one. This mutex is acquired by the earlier call to torture_init_begin(), but only if that function returns true. If that function returns false, yes, it releases fullstop_mutex, but in that case rcu_torture_init() returns immediately, thus avoiding this invocation of torture_init_end().

Or am I missing something subtle here? Or missing something obvious, for that matter! ;-)

I explained it badly. Joel's patch added a goto so now we call torture_init_end() twice in a row.

Quoted 9 lines

Thanx, Paul

Quoted 7 lines
Quoted 7 lines
    4582         if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
    4583                 cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
    4584 
    4585         if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())

--> 4586 goto unwind;

set an error code?

Here is the goto.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
    4587 
    4588         return 0;
    4589 
    4590 unwind:
    4591         torture_init_end();
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
                   ^^^^^^^^^^^^^^^^^^^

Here is the second torture_init_end().

Ah! Thank you for persisting. Over to you, Joel!

Oops, thanks for finding both the issues. I will move the torture_init_end() further down and run some tests. At first look, that seems like the right thing to do:

kernel/rcu/rcutorture.c +1 -1
index 92e2686a4795..bb9a8e718533 100644
@@ -4582,13 +4582,17 @@ rcu_torture_init(void)
        }
        if (object_debug)
                rcu_test_debug_objects();
-       torture_init_end();
+
        if (cur_ops->gp_slow_register &&
 !WARN_ON_ONCE(!cur_ops->gp_slow_unregister))
                cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay);
 

kernel/rcu/rcutorture.c rcu_torture_init(void) · line 4597

Quoted 10 lines
kernel/rcu/rcutorture.c +6 -2
-       if (gpwrap_lag && cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init())
-               goto unwind;
+       if (gpwrap_lag && cur_ops->set_gpwrap_lag) {
+               firsterr = rcu_gpwrap_lag_init();
+               if (torture_init_error(firsterr))
+                       goto unwind;
+       }
 
+       torture_init_end();
        return 0;

Passes basic testing, fixed and pushed for more testing with attribution:

git://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git (next.2025.04.24b)

Thanks!

- Joel