mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
rcu/nocb: Extract nocb_defer_wakeup_cancel() helper
The pattern of checking nocb_defer_wakeup and deleting the timer is duplicated in __wake_nocb_gp() and nocb_gp_wait(). Extract this into a common helper function nocb_defer_wakeup_cancel(). This removes code duplication and makes it easier to maintain. Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
This commit is contained in:
parent
b11c1efa7f
commit
cc74050f13
1 changed files with 11 additions and 8 deletions
|
|
@ -190,6 +190,15 @@ static void rcu_init_one_nocb(struct rcu_node *rnp)
|
|||
init_swait_queue_head(&rnp->nocb_gp_wq[1]);
|
||||
}
|
||||
|
||||
/* Clear any pending deferred wakeup timer (nocb_gp_lock must be held). */
|
||||
static void nocb_defer_wakeup_cancel(struct rcu_data *rdp_gp)
|
||||
{
|
||||
if (rdp_gp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
|
||||
WRITE_ONCE(rdp_gp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
|
||||
timer_delete(&rdp_gp->nocb_timer);
|
||||
}
|
||||
}
|
||||
|
||||
static bool __wake_nocb_gp(struct rcu_data *rdp_gp,
|
||||
struct rcu_data *rdp,
|
||||
unsigned long flags)
|
||||
|
|
@ -204,10 +213,7 @@ static bool __wake_nocb_gp(struct rcu_data *rdp_gp,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (rdp_gp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
|
||||
WRITE_ONCE(rdp_gp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
|
||||
timer_delete(&rdp_gp->nocb_timer);
|
||||
}
|
||||
nocb_defer_wakeup_cancel(rdp_gp);
|
||||
|
||||
if (READ_ONCE(rdp_gp->nocb_gp_sleep)) {
|
||||
WRITE_ONCE(rdp_gp->nocb_gp_sleep, false);
|
||||
|
|
@ -788,10 +794,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
|
|||
if (rdp_toggling)
|
||||
my_rdp->nocb_toggling_rdp = NULL;
|
||||
|
||||
if (my_rdp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
|
||||
WRITE_ONCE(my_rdp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
|
||||
timer_delete(&my_rdp->nocb_timer);
|
||||
}
|
||||
nocb_defer_wakeup_cancel(my_rdp);
|
||||
WRITE_ONCE(my_rdp->nocb_gp_sleep, true);
|
||||
raw_spin_unlock_irqrestore(&my_rdp->nocb_gp_lock, flags);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue