aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2021-11-08 16:52:02 -0800
committerPaul E. McKenney <paulmck@kernel.org>2021-11-10 09:59:47 -0800
commita3ecbdd6d841a025ebe87b79c7538b4dc44edc94 (patch)
treeb893573abd8247f769cfe30d436f3c8ac4a11b54
parent889af1c1ccb6b00dd021bfcebe96808434c8bd78 (diff)
downloadlinux-rcu-a3ecbdd6d841a025ebe87b79c7538b4dc44edc94.tar.gz
rcu-tasks: Use spin_lock_rcu_node() and friends
This commit renames the rcu_tasks_percpu structure's ->cbs_pcpu_lock to ->lock and then uses spin_lock_rcu_node() and friends to acquire and release this lock, preparing for upcoming commits that will spread the grace-period process across multiple CPUs and kthreads. Reported-by: Martin Lau <kafai@fb.com> Cc: Neeraj Upadhyay <neeraj.iitr10@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
-rw-r--r--kernel/rcu/tasks.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index ab924a77c7eee..d3544a8f08304 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -23,11 +23,11 @@ typedef void (*postgp_func_t)(struct rcu_tasks *rtp);
/**
* struct rcu_tasks_percpu - Per-CPU component of definition for a Tasks-RCU-like mechanism.
* @cblist: Callback list.
- * @cbs_pcpu_lock: Lock protecting per-CPU callback list.
+ * @lock: Lock protecting per-CPU callback list.
*/
struct rcu_tasks_percpu {
struct rcu_segcblist cblist;
- raw_spinlock_t cbs_pcpu_lock;
+ raw_spinlock_t __private lock;
};
/**
@@ -82,7 +82,7 @@ struct rcu_tasks {
#define DEFINE_RCU_TASKS(rt_name, gp, call, n) \
static DEFINE_PER_CPU(struct rcu_tasks_percpu, rt_name ## __percpu) = { \
- .cbs_pcpu_lock = __RAW_SPIN_LOCK_UNLOCKED(rt_name ## __percpu.cbs_pcpu_lock), \
+ .lock = __RAW_SPIN_LOCK_UNLOCKED(rt_name ## __percpu.cbs_pcpu_lock), \
}; \
static struct rcu_tasks rt_name = \
{ \
@@ -178,11 +178,11 @@ static void cblist_init_generic(struct rcu_tasks *rtp)
pr_info("%s initializing CPU %d rcu_tasks_percpu structure for %s\n", __func__, cpu, rtp->name);
WARN_ON_ONCE(!rtpcp);
if (cpu)
- raw_spin_lock_init(&rtpcp->cbs_pcpu_lock);
- raw_spin_lock_irqsave(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_lock_init(&rtpcp->lock);
+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
if (rcu_segcblist_empty(&rtpcp->cblist))
rcu_segcblist_init(&rtpcp->cblist);
- raw_spin_unlock_irqrestore(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
}
raw_spin_unlock_irqrestore(&rtp->cbs_gbl_lock, flags);
@@ -201,15 +201,15 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
local_irq_save(flags);
rtpcp = per_cpu_ptr(rtp->rtpcpu,
smp_processor_id() >> READ_ONCE(rtp->percpu_enqueue_shift));
- raw_spin_lock(&rtpcp->cbs_pcpu_lock);
+ raw_spin_lock_rcu_node(rtpcp); // irqs already disabled.
if (!rcu_segcblist_is_enabled(&rtpcp->cblist)) {
- raw_spin_unlock(&rtpcp->cbs_pcpu_lock); // irqs remain disabled.
+ raw_spin_unlock_rcu_node(rtpcp); // irqs remain disabled.
cblist_init_generic(rtp);
- raw_spin_lock(&rtpcp->cbs_pcpu_lock); // irqs already disabled.
+ raw_spin_lock_rcu_node(rtpcp); // irqs already disabled.
}
needwake = rcu_segcblist_empty(&rtpcp->cblist);
rcu_segcblist_enqueue(&rtpcp->cblist, rhp);
- raw_spin_unlock_irqrestore(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
/* We can't create the thread unless interrupts are enabled. */
if (needwake && READ_ONCE(rtp->kthread_ptr))
wake_up(&rtp->cbs_wq);
@@ -251,11 +251,11 @@ static int __noreturn rcu_tasks_kthread(void *arg)
set_tasks_gp_state(rtp, RTGS_WAIT_CBS);
/* Pick up any new callbacks. */
- raw_spin_lock_irqsave(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
smp_mb__after_spinlock(); // Order updates vs. GP.
rcu_segcblist_advance(&rtpcp->cblist, rcu_seq_current(&rtp->tasks_gp_seq));
(void)rcu_segcblist_accelerate(&rtpcp->cblist, rcu_seq_snap(&rtp->tasks_gp_seq));
- raw_spin_unlock_irqrestore(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
/* If there were none, wait a bit and start over. */
if (!rcu_segcblist_pend_cbs(&rtpcp->cblist)) {
@@ -278,11 +278,11 @@ static int __noreturn rcu_tasks_kthread(void *arg)
/* Invoke the callbacks. */
set_tasks_gp_state(rtp, RTGS_INVOKE_CBS);
- raw_spin_lock_irqsave(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
smp_mb__after_spinlock(); // Order updates vs. GP.
rcu_segcblist_advance(&rtpcp->cblist, rcu_seq_current(&rtp->tasks_gp_seq));
rcu_segcblist_extract_done_cbs(&rtpcp->cblist, &rcl);
- raw_spin_unlock_irqrestore(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
len = rcl.len;
for (rhp = rcu_cblist_dequeue(&rcl); rhp; rhp = rcu_cblist_dequeue(&rcl)) {
local_bh_disable();
@@ -290,10 +290,10 @@ static int __noreturn rcu_tasks_kthread(void *arg)
local_bh_enable();
cond_resched();
}
- raw_spin_lock_irqsave(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
rcu_segcblist_add_len(&rtpcp->cblist, -len);
(void)rcu_segcblist_accelerate(&rtpcp->cblist, rcu_seq_snap(&rtp->tasks_gp_seq));
- raw_spin_unlock_irqrestore(&rtpcp->cbs_pcpu_lock, flags);
+ raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
/* Paranoid sleep to keep this from entering a tight loop */
schedule_timeout_idle(rtp->gp_sleep);
}