Skip to content

Commit 6764100

Browse files
committed
rcutorture: Complete threading rcu_fwd pointers through functions
This commit threads pointers to rcu_fwd structures through the remaining functions using rcu_fwds directly, namely rcu_torture_fwd_prog_cbfree(), rcutorture_oom_notify() and rcu_torture_fwd_prog_init(). Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 7beba0c commit 6764100

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

kernel/rcu/rcutorture.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,23 +1754,23 @@ static void rcu_torture_fwd_prog_cond_resched(unsigned long iter)
17541754
* Free all callbacks on the rcu_fwd_cb_head list, either because the
17551755
* test is over or because we hit an OOM event.
17561756
*/
1757-
static unsigned long rcu_torture_fwd_prog_cbfree(void)
1757+
static unsigned long rcu_torture_fwd_prog_cbfree(struct rcu_fwd *rfp)
17581758
{
17591759
unsigned long flags;
17601760
unsigned long freed = 0;
17611761
struct rcu_fwd_cb *rfcp;
17621762

17631763
for (;;) {
1764-
spin_lock_irqsave(&rcu_fwds.rcu_fwd_lock, flags);
1765-
rfcp = rcu_fwds.rcu_fwd_cb_head;
1764+
spin_lock_irqsave(&rfp->rcu_fwd_lock, flags);
1765+
rfcp = rfp->rcu_fwd_cb_head;
17661766
if (!rfcp) {
1767-
spin_unlock_irqrestore(&rcu_fwds.rcu_fwd_lock, flags);
1767+
spin_unlock_irqrestore(&rfp->rcu_fwd_lock, flags);
17681768
break;
17691769
}
1770-
rcu_fwds.rcu_fwd_cb_head = rfcp->rfc_next;
1771-
if (!rcu_fwds.rcu_fwd_cb_head)
1772-
rcu_fwds.rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head;
1773-
spin_unlock_irqrestore(&rcu_fwds.rcu_fwd_lock, flags);
1770+
rfp->rcu_fwd_cb_head = rfcp->rfc_next;
1771+
if (!rfp->rcu_fwd_cb_head)
1772+
rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;
1773+
spin_unlock_irqrestore(&rfp->rcu_fwd_lock, flags);
17741774
kfree(rfcp);
17751775
freed++;
17761776
rcu_torture_fwd_prog_cond_resched(freed);
@@ -1926,7 +1926,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp)
19261926
cver = READ_ONCE(rcu_torture_current_version) - cver;
19271927
gps = rcutorture_seq_diff(cur_ops->get_gp_seq(), gps);
19281928
cur_ops->cb_barrier(); /* Wait for callbacks to be invoked. */
1929-
(void)rcu_torture_fwd_prog_cbfree();
1929+
(void)rcu_torture_fwd_prog_cbfree(rfp);
19301930

19311931
if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop) &&
19321932
!shutdown_time_arrived()) {
@@ -1952,20 +1952,22 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp)
19521952
static int rcutorture_oom_notify(struct notifier_block *self,
19531953
unsigned long notused, void *nfreed)
19541954
{
1955+
struct rcu_fwd *rfp = &rcu_fwds;
1956+
19551957
WARN(1, "%s invoked upon OOM during forward-progress testing.\n",
19561958
__func__);
1957-
rcu_torture_fwd_cb_hist(&rcu_fwds);
1958-
rcu_fwd_progress_check(1 + (jiffies - READ_ONCE(rcu_fwds.rcu_fwd_startat)) / 2);
1959+
rcu_torture_fwd_cb_hist(rfp);
1960+
rcu_fwd_progress_check(1 + (jiffies - READ_ONCE(rfp->rcu_fwd_startat)) / 2);
19591961
WRITE_ONCE(rcu_fwd_emergency_stop, true);
19601962
smp_mb(); /* Emergency stop before free and wait to avoid hangs. */
19611963
pr_info("%s: Freed %lu RCU callbacks.\n",
1962-
__func__, rcu_torture_fwd_prog_cbfree());
1964+
__func__, rcu_torture_fwd_prog_cbfree(rfp));
19631965
rcu_barrier();
19641966
pr_info("%s: Freed %lu RCU callbacks.\n",
1965-
__func__, rcu_torture_fwd_prog_cbfree());
1967+
__func__, rcu_torture_fwd_prog_cbfree(rfp));
19661968
rcu_barrier();
19671969
pr_info("%s: Freed %lu RCU callbacks.\n",
1968-
__func__, rcu_torture_fwd_prog_cbfree());
1970+
__func__, rcu_torture_fwd_prog_cbfree(rfp));
19691971
smp_mb(); /* Frees before return to avoid redoing OOM. */
19701972
(*(unsigned long *)nfreed)++; /* Forward progress CBs freed! */
19711973
pr_info("%s returning after OOM processing.\n", __func__);
@@ -2008,6 +2010,8 @@ static int rcu_torture_fwd_prog(void *args)
20082010
/* If forward-progress checking is requested and feasible, spawn the thread. */
20092011
static int __init rcu_torture_fwd_prog_init(void)
20102012
{
2013+
struct rcu_fwd *rfp = &rcu_fwds;
2014+
20112015
if (!fwd_progress)
20122016
return 0; /* Not requested, so don't do it. */
20132017
if (!cur_ops->stall_dur || cur_ops->stall_dur() <= 0 ||
@@ -2022,14 +2026,13 @@ static int __init rcu_torture_fwd_prog_init(void)
20222026
WARN_ON(1); /* Make sure rcutorture notices conflict. */
20232027
return 0;
20242028
}
2025-
spin_lock_init(&rcu_fwds.rcu_fwd_lock);
2026-
rcu_fwds.rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head;
2029+
spin_lock_init(&rfp->rcu_fwd_lock);
2030+
rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;
20272031
if (fwd_progress_holdoff <= 0)
20282032
fwd_progress_holdoff = 1;
20292033
if (fwd_progress_div <= 0)
20302034
fwd_progress_div = 4;
2031-
return torture_create_kthread(rcu_torture_fwd_prog,
2032-
&rcu_fwds, fwd_prog_task);
2035+
return torture_create_kthread(rcu_torture_fwd_prog, rfp, fwd_prog_task);
20332036
}
20342037

20352038
/* Callback function for RCU barrier testing. */

0 commit comments

Comments
 (0)