Skip to content

Commit 365187f

Browse files
committed
rcu: Update cpu_needs_another_gp() for futures from non-NOCB CPUs
In the old days, the only source of requests for future grace periods was NOCB CPUs. This has changed: CPUs routinely post requests for future grace periods in order to promote power efficiency and reduce OS jitter with minimal impact on grace-period latency. This commit therefore updates cpu_needs_another_gp() to invoke rcu_future_needs_gp() instead of rcu_nocb_needs_gp(). The latter is no longer used, so is now removed. This commit also adds tracing for the irq_work_queue() wakeup case. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent 83ebe63 commit 365187f

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

‎kernel/rcu/tree.c‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,28 @@ cpu_has_callbacks_ready_to_invoke(struct rcu_data *rdp)
323323
rdp->nxttail[RCU_DONE_TAIL] != NULL;
324324
}
325325

326+
/*
327+
* Return the root node of the specified rcu_state structure.
328+
*/
329+
static struct rcu_node *rcu_get_root(struct rcu_state *rsp)
330+
{
331+
return &rsp->node[0];
332+
}
333+
334+
/*
335+
* Is there any need for future grace periods?
336+
* Interrupts must be disabled. If the caller does not hold the root
337+
* rnp_node structure's ->lock, the results are advisory only.
338+
*/
339+
static int rcu_future_needs_gp(struct rcu_state *rsp)
340+
{
341+
struct rcu_node *rnp = rcu_get_root(rsp);
342+
int idx = (ACCESS_ONCE(rnp->completed) + 1) & 0x1;
343+
int *fp = &rnp->need_future_gp[idx];
344+
345+
return ACCESS_ONCE(*fp);
346+
}
347+
326348
/*
327349
* Does the current CPU require a not-yet-started grace period?
328350
* The caller must have disabled interrupts to prevent races with
@@ -335,7 +357,7 @@ cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
335357

336358
if (rcu_gp_in_progress(rsp))
337359
return 0; /* No, a grace period is already in progress. */
338-
if (rcu_nocb_needs_gp(rsp))
360+
if (rcu_future_needs_gp(rsp))
339361
return 1; /* Yes, a no-CBs CPU needs one. */
340362
if (!rdp->nxttail[RCU_NEXT_TAIL])
341363
return 0; /* No, this is a no-CBs (or offline) CPU. */
@@ -349,14 +371,6 @@ cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
349371
return 0; /* No grace period needed. */
350372
}
351373

352-
/*
353-
* Return the root node of the specified rcu_state structure.
354-
*/
355-
static struct rcu_node *rcu_get_root(struct rcu_state *rsp)
356-
{
357-
return &rsp->node[0];
358-
}
359-
360374
/*
361375
* rcu_eqs_enter_common - current CPU is moving towards extended quiescent state
362376
*
@@ -1672,6 +1686,8 @@ static void rsp_wakeup(struct irq_work *work)
16721686

16731687
/* Wake up rcu_gp_kthread() to start the grace period. */
16741688
wake_up(&rsp->gp_wq);
1689+
trace_rcu_grace_period(rsp->name, ACCESS_ONCE(rsp->gpnum),
1690+
"Workqueuewoken");
16751691
}
16761692

16771693
/*
@@ -1706,8 +1722,11 @@ rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp,
17061722
* the wakeup to interrupt context. And don't bother waking
17071723
* up the running kthread.
17081724
*/
1709-
if (current != rsp->gp_kthread)
1725+
if (current != rsp->gp_kthread) {
1726+
trace_rcu_grace_period(rsp->name, ACCESS_ONCE(rsp->gpnum),
1727+
"Workqueuewake");
17101728
irq_work_queue(&rsp->wakeup_work);
1729+
}
17111730
}
17121731

17131732
/*

‎kernel/rcu/tree.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu);
547547
static void print_cpu_stall_info_end(void);
548548
static void zero_cpu_stall_ticks(struct rcu_data *rdp);
549549
static void increment_cpu_stall_ticks(void);
550-
static int rcu_nocb_needs_gp(struct rcu_state *rsp);
551550
static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq);
552551
static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp);
553552
static void rcu_init_one_nocb(struct rcu_node *rnp);

‎kernel/rcu/tree_plugin.h‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,19 +2067,6 @@ static int __init parse_rcu_nocb_poll(char *arg)
20672067
}
20682068
early_param("rcu_nocb_poll", parse_rcu_nocb_poll);
20692069

2070-
/*
2071-
* Do any no-CBs CPUs need another grace period?
2072-
*
2073-
* Interrupts must be disabled. If the caller does not hold the root
2074-
* rnp_node structure's ->lock, the results are advisory only.
2075-
*/
2076-
static int rcu_nocb_needs_gp(struct rcu_state *rsp)
2077-
{
2078-
struct rcu_node *rnp = rcu_get_root(rsp);
2079-
2080-
return rnp->need_future_gp[(ACCESS_ONCE(rnp->completed) + 1) & 0x1];
2081-
}
2082-
20832070
/*
20842071
* Wake up any no-CBs CPUs' kthreads that were waiting on the just-ended
20852072
* grace period.
@@ -2402,11 +2389,6 @@ static bool init_nocb_callback_list(struct rcu_data *rdp)
24022389

24032390
#else /* #ifdef CONFIG_RCU_NOCB_CPU */
24042391

2405-
static int rcu_nocb_needs_gp(struct rcu_state *rsp)
2406-
{
2407-
return 0;
2408-
}
2409-
24102392
static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
24112393
{
24122394
}

0 commit comments

Comments
 (0)