@@ -373,6 +373,8 @@ struct rcu_torture_ops {
373
373
bool (* poll_need_2gp )(bool poll , bool poll_full );
374
374
void (* cond_sync )(unsigned long oldstate );
375
375
void (* cond_sync_full )(struct rcu_gp_oldstate * rgosp );
376
+ int poll_active ;
377
+ int poll_active_full ;
376
378
call_rcu_func_t call ;
377
379
void (* cb_barrier )(void );
378
380
void (* fqs )(void );
@@ -558,6 +560,8 @@ static struct rcu_torture_ops rcu_ops = {
558
560
.poll_need_2gp = rcu_poll_need_2gp ,
559
561
.cond_sync = cond_synchronize_rcu ,
560
562
.cond_sync_full = cond_synchronize_rcu_full ,
563
+ .poll_active = NUM_ACTIVE_RCU_POLL_OLDSTATE ,
564
+ .poll_active_full = NUM_ACTIVE_RCU_POLL_FULL_OLDSTATE ,
561
565
.get_gp_state_exp = get_state_synchronize_rcu ,
562
566
.start_gp_poll_exp = start_poll_synchronize_rcu_expedited ,
563
567
.start_gp_poll_exp_full = start_poll_synchronize_rcu_expedited_full ,
@@ -741,6 +745,7 @@ static struct rcu_torture_ops srcu_ops = {
741
745
.get_gp_state = srcu_torture_get_gp_state ,
742
746
.start_gp_poll = srcu_torture_start_gp_poll ,
743
747
.poll_gp_state = srcu_torture_poll_gp_state ,
748
+ .poll_active = NUM_ACTIVE_SRCU_POLL_OLDSTATE ,
744
749
.call = srcu_torture_call ,
745
750
.cb_barrier = srcu_torture_barrier ,
746
751
.stats = srcu_torture_stats ,
@@ -783,6 +788,7 @@ static struct rcu_torture_ops srcud_ops = {
783
788
.get_gp_state = srcu_torture_get_gp_state ,
784
789
.start_gp_poll = srcu_torture_start_gp_poll ,
785
790
.poll_gp_state = srcu_torture_poll_gp_state ,
791
+ .poll_active = NUM_ACTIVE_SRCU_POLL_OLDSTATE ,
786
792
.call = srcu_torture_call ,
787
793
.cb_barrier = srcu_torture_barrier ,
788
794
.stats = srcu_torture_stats ,
@@ -1374,13 +1380,15 @@ rcu_torture_writer(void *arg)
1374
1380
int i ;
1375
1381
int idx ;
1376
1382
int oldnice = task_nice (current );
1377
- struct rcu_gp_oldstate rgo [NUM_ACTIVE_RCU_POLL_FULL_OLDSTATE ];
1383
+ struct rcu_gp_oldstate * rgo = NULL ;
1384
+ int rgo_size = 0 ;
1378
1385
struct rcu_torture * rp ;
1379
1386
struct rcu_torture * old_rp ;
1380
1387
static DEFINE_TORTURE_RANDOM (rand );
1381
1388
unsigned long stallsdone = jiffies ;
1382
1389
bool stutter_waited ;
1383
- unsigned long ulo [NUM_ACTIVE_RCU_POLL_OLDSTATE ];
1390
+ unsigned long * ulo = NULL ;
1391
+ int ulo_size = 0 ;
1384
1392
1385
1393
// If a new stall test is added, this must be adjusted.
1386
1394
if (stall_cpu_holdoff + stall_gp_kthread + stall_cpu )
@@ -1401,6 +1409,16 @@ rcu_torture_writer(void *arg)
1401
1409
torture_kthread_stopping ("rcu_torture_writer" );
1402
1410
return 0 ;
1403
1411
}
1412
+ if (cur_ops -> poll_active > 0 ) {
1413
+ ulo = kzalloc (cur_ops -> poll_active * sizeof (ulo [0 ]), GFP_KERNEL );
1414
+ if (!WARN_ON (!ulo ))
1415
+ ulo_size = cur_ops -> poll_active ;
1416
+ }
1417
+ if (cur_ops -> poll_active_full > 0 ) {
1418
+ rgo = kzalloc (cur_ops -> poll_active_full * sizeof (rgo [0 ]), GFP_KERNEL );
1419
+ if (!WARN_ON (!rgo ))
1420
+ rgo_size = cur_ops -> poll_active_full ;
1421
+ }
1404
1422
1405
1423
do {
1406
1424
rcu_torture_writer_state = RTWS_FIXED_DELAY ;
@@ -1502,40 +1520,40 @@ rcu_torture_writer(void *arg)
1502
1520
break ;
1503
1521
case RTWS_POLL_GET :
1504
1522
rcu_torture_writer_state = RTWS_POLL_GET ;
1505
- for (i = 0 ; i < ARRAY_SIZE ( ulo ) ; i ++ )
1523
+ for (i = 0 ; i < ulo_size ; i ++ )
1506
1524
ulo [i ] = cur_ops -> get_comp_state ();
1507
1525
gp_snap = cur_ops -> start_gp_poll ();
1508
1526
rcu_torture_writer_state = RTWS_POLL_WAIT ;
1509
1527
while (!cur_ops -> poll_gp_state (gp_snap )) {
1510
1528
gp_snap1 = cur_ops -> get_gp_state ();
1511
- for (i = 0 ; i < ARRAY_SIZE ( ulo ) ; i ++ )
1529
+ for (i = 0 ; i < ulo_size ; i ++ )
1512
1530
if (cur_ops -> poll_gp_state (ulo [i ]) ||
1513
1531
cur_ops -> same_gp_state (ulo [i ], gp_snap1 )) {
1514
1532
ulo [i ] = gp_snap1 ;
1515
1533
break ;
1516
1534
}
1517
- WARN_ON_ONCE (i >= ARRAY_SIZE ( ulo ) );
1535
+ WARN_ON_ONCE (ulo_size > 0 && i >= ulo_size );
1518
1536
torture_hrtimeout_jiffies (torture_random (& rand ) % 16 ,
1519
1537
& rand );
1520
1538
}
1521
1539
rcu_torture_pipe_update (old_rp );
1522
1540
break ;
1523
1541
case RTWS_POLL_GET_FULL :
1524
1542
rcu_torture_writer_state = RTWS_POLL_GET_FULL ;
1525
- for (i = 0 ; i < ARRAY_SIZE ( rgo ) ; i ++ )
1543
+ for (i = 0 ; i < rgo_size ; i ++ )
1526
1544
cur_ops -> get_comp_state_full (& rgo [i ]);
1527
1545
cur_ops -> start_gp_poll_full (& gp_snap_full );
1528
1546
rcu_torture_writer_state = RTWS_POLL_WAIT_FULL ;
1529
1547
while (!cur_ops -> poll_gp_state_full (& gp_snap_full )) {
1530
1548
cur_ops -> get_gp_state_full (& gp_snap1_full );
1531
- for (i = 0 ; i < ARRAY_SIZE ( rgo ) ; i ++ )
1549
+ for (i = 0 ; i < rgo_size ; i ++ )
1532
1550
if (cur_ops -> poll_gp_state_full (& rgo [i ]) ||
1533
1551
cur_ops -> same_gp_state_full (& rgo [i ],
1534
1552
& gp_snap1_full )) {
1535
1553
rgo [i ] = gp_snap1_full ;
1536
1554
break ;
1537
1555
}
1538
- WARN_ON_ONCE (i >= ARRAY_SIZE ( rgo ) );
1556
+ WARN_ON_ONCE (rgo_size > 0 && i >= rgo_size );
1539
1557
torture_hrtimeout_jiffies (torture_random (& rand ) % 16 ,
1540
1558
& rand );
1541
1559
}
@@ -1617,6 +1635,8 @@ rcu_torture_writer(void *arg)
1617
1635
pr_alert ("%s" TORTURE_FLAG
1618
1636
" Dynamic grace-period expediting was disabled.\n" ,
1619
1637
torture_type );
1638
+ kfree (ulo );
1639
+ kfree (rgo );
1620
1640
rcu_torture_writer_state = RTWS_STOPPING ;
1621
1641
torture_kthread_stopping ("rcu_torture_writer" );
1622
1642
return 0 ;
0 commit comments