@@ -390,6 +390,7 @@ struct rcu_torture_ops {
390
390
int extendables ;
391
391
int slow_gps ;
392
392
int no_pi_lock ;
393
+ int debug_objects ;
393
394
const char * name ;
394
395
};
395
396
@@ -577,6 +578,7 @@ static struct rcu_torture_ops rcu_ops = {
577
578
.irq_capable = 1 ,
578
579
.can_boost = IS_ENABLED (CONFIG_RCU_BOOST ),
579
580
.extendables = RCUTORTURE_MAX_EXTEND ,
581
+ .debug_objects = 1 ,
580
582
.name = "rcu"
581
583
};
582
584
@@ -747,6 +749,7 @@ static struct rcu_torture_ops srcu_ops = {
747
749
.cbflood_max = 50000 ,
748
750
.irq_capable = 1 ,
749
751
.no_pi_lock = IS_ENABLED (CONFIG_TINY_SRCU ),
752
+ .debug_objects = 1 ,
750
753
.name = "srcu"
751
754
};
752
755
@@ -786,6 +789,7 @@ static struct rcu_torture_ops srcud_ops = {
786
789
.cbflood_max = 50000 ,
787
790
.irq_capable = 1 ,
788
791
.no_pi_lock = IS_ENABLED (CONFIG_TINY_SRCU ),
792
+ .debug_objects = 1 ,
789
793
.name = "srcud"
790
794
};
791
795
@@ -3455,7 +3459,6 @@ rcu_torture_cleanup(void)
3455
3459
cur_ops -> gp_slow_unregister (NULL );
3456
3460
}
3457
3461
3458
- #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
3459
3462
static void rcu_torture_leak_cb (struct rcu_head * rhp )
3460
3463
{
3461
3464
}
@@ -3473,7 +3476,6 @@ static void rcu_torture_err_cb(struct rcu_head *rhp)
3473
3476
*/
3474
3477
pr_alert ("%s: duplicated callback was invoked.\n" , KBUILD_MODNAME );
3475
3478
}
3476
- #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
3477
3479
3478
3480
/*
3479
3481
* Verify that double-free causes debug-objects to complain, but only
@@ -3482,39 +3484,43 @@ static void rcu_torture_err_cb(struct rcu_head *rhp)
3482
3484
*/
3483
3485
static void rcu_test_debug_objects (void )
3484
3486
{
3485
- #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
3486
3487
struct rcu_head rh1 ;
3487
3488
struct rcu_head rh2 ;
3489
+ int idx ;
3490
+
3491
+ if (!IS_ENABLED (CONFIG_DEBUG_OBJECTS_RCU_HEAD )) {
3492
+ pr_alert ("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_%s()\n" ,
3493
+ KBUILD_MODNAME , cur_ops -> name );
3494
+ return ;
3495
+ }
3496
+
3497
+ if (WARN_ON_ONCE (cur_ops -> debug_objects &&
3498
+ (!cur_ops -> call || !cur_ops -> cb_barrier )))
3499
+ return ;
3500
+
3488
3501
struct rcu_head * rhp = kmalloc (sizeof (* rhp ), GFP_KERNEL );
3489
3502
3490
3503
init_rcu_head_on_stack (& rh1 );
3491
3504
init_rcu_head_on_stack (& rh2 );
3492
- pr_alert ("%s: WARN: Duplicate call_rcu () test starting.\n" , KBUILD_MODNAME );
3505
+ pr_alert ("%s: WARN: Duplicate call_%s () test starting.\n" , KBUILD_MODNAME , cur_ops -> name );
3493
3506
3494
3507
/* Try to queue the rh2 pair of callbacks for the same grace period. */
3495
- preempt_disable (); /* Prevent preemption from interrupting test. */
3496
- rcu_read_lock (); /* Make it impossible to finish a grace period. */
3497
- call_rcu_hurry (& rh1 , rcu_torture_leak_cb ); /* Start grace period. */
3498
- local_irq_disable (); /* Make it harder to start a new grace period. */
3499
- call_rcu_hurry (& rh2 , rcu_torture_leak_cb );
3500
- call_rcu_hurry (& rh2 , rcu_torture_err_cb ); /* Duplicate callback. */
3508
+ idx = cur_ops -> readlock (); /* Make it impossible to finish a grace period. */
3509
+ cur_ops -> call (& rh1 , rcu_torture_leak_cb ); /* Start grace period. */
3510
+ cur_ops -> call (& rh2 , rcu_torture_leak_cb );
3511
+ cur_ops -> call (& rh2 , rcu_torture_err_cb ); /* Duplicate callback. */
3501
3512
if (rhp ) {
3502
- call_rcu_hurry (rhp , rcu_torture_leak_cb );
3503
- call_rcu_hurry (rhp , rcu_torture_err_cb ); /* Another duplicate callback. */
3513
+ cur_ops -> call (rhp , rcu_torture_leak_cb );
3514
+ cur_ops -> call (rhp , rcu_torture_err_cb ); /* Another duplicate callback. */
3504
3515
}
3505
- local_irq_enable ();
3506
- rcu_read_unlock ();
3507
- preempt_enable ();
3516
+ cur_ops -> readunlock (idx );
3508
3517
3509
3518
/* Wait for them all to get done so we can safely return. */
3510
- rcu_barrier ();
3511
- pr_alert ("%s: WARN: Duplicate call_rcu () test complete.\n" , KBUILD_MODNAME );
3519
+ cur_ops -> cb_barrier ();
3520
+ pr_alert ("%s: WARN: Duplicate call_%s () test complete.\n" , KBUILD_MODNAME , cur_ops -> name );
3512
3521
destroy_rcu_head_on_stack (& rh1 );
3513
3522
destroy_rcu_head_on_stack (& rh2 );
3514
3523
kfree (rhp );
3515
- #else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
3516
- pr_alert ("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n" , KBUILD_MODNAME );
3517
- #endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
3518
3524
}
3519
3525
3520
3526
static void rcutorture_sync (void )
0 commit comments