Skip to content

Commit 5155be9

Browse files
committed
rcutorture: Dynamically allocate rcu_fwds structure
This commit switches from static structure to dynamic allocation for rcu_fwds as another step towards providing multiple call_rcu() forward-progress kthreads. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 6764100 commit 5155be9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kernel/rcu/rcutorture.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ struct rcu_fwd {
16861686
unsigned long rcu_launder_gp_seq_start;
16871687
};
16881688

1689-
struct rcu_fwd rcu_fwds;
1689+
struct rcu_fwd *rcu_fwds;
16901690
bool rcu_fwd_emergency_stop;
16911691

16921692
static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp)
@@ -1952,7 +1952,7 @@ 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;
1955+
struct rcu_fwd *rfp = rcu_fwds;
19561956

19571957
WARN(1, "%s invoked upon OOM during forward-progress testing.\n",
19581958
__func__);
@@ -2010,7 +2010,7 @@ static int rcu_torture_fwd_prog(void *args)
20102010
/* If forward-progress checking is requested and feasible, spawn the thread. */
20112011
static int __init rcu_torture_fwd_prog_init(void)
20122012
{
2013-
struct rcu_fwd *rfp = &rcu_fwds;
2013+
struct rcu_fwd *rfp;
20142014

20152015
if (!fwd_progress)
20162016
return 0; /* Not requested, so don't do it. */
@@ -2026,12 +2026,15 @@ static int __init rcu_torture_fwd_prog_init(void)
20262026
WARN_ON(1); /* Make sure rcutorture notices conflict. */
20272027
return 0;
20282028
}
2029-
spin_lock_init(&rfp->rcu_fwd_lock);
2030-
rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;
20312029
if (fwd_progress_holdoff <= 0)
20322030
fwd_progress_holdoff = 1;
20332031
if (fwd_progress_div <= 0)
20342032
fwd_progress_div = 4;
2033+
rfp = kzalloc(sizeof(*rfp), GFP_KERNEL);
2034+
if (!rfp)
2035+
return -ENOMEM;
2036+
spin_lock_init(&rfp->rcu_fwd_lock);
2037+
rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;
20352038
return torture_create_kthread(rcu_torture_fwd_prog, rfp, fwd_prog_task);
20362039
}
20372040

0 commit comments

Comments
 (0)