Skip to content

Commit c1a8f1d

Browse files
joelagnelchantra
authored andcommitted
rcu: Refactor code a bit in rcu_nocb_do_flush_bypass()
This consolidates the code a bit and makes it cleaner. Functionally it is the same. Reported-by: Paul E. McKenney <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 62c6f42 commit c1a8f1d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

kernel/rcu/tree_nocb.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,11 @@ static void wake_nocb_gp_defer(struct rcu_data *rdp, int waketype,
327327
*
328328
* Note that this function always returns true if rhp is NULL.
329329
*/
330-
static bool rcu_nocb_do_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
330+
static bool rcu_nocb_do_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp_in,
331331
unsigned long j, bool lazy)
332332
{
333333
struct rcu_cblist rcl;
334+
struct rcu_head *rhp = rhp_in;
334335

335336
WARN_ON_ONCE(!rcu_rdp_is_offloaded(rdp));
336337
rcu_lockdep_assert_cblist_protected(rdp);
@@ -345,16 +346,16 @@ static bool rcu_nocb_do_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
345346

346347
/*
347348
* If the new CB requested was a lazy one, queue it onto the main
348-
* ->cblist so we can take advantage of a sooner grade period.
349+
* ->cblist so that we can take advantage of the grace-period that will
350+
* happen regardless. But queue it onto the bypass list first so that
351+
* the lazy CB is ordered with the existing CBs in the bypass list.
349352
*/
350353
if (lazy && rhp) {
351-
rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, NULL);
352-
rcu_cblist_enqueue(&rcl, rhp);
353-
WRITE_ONCE(rdp->lazy_len, 0);
354-
} else {
355-
rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, rhp);
356-
WRITE_ONCE(rdp->lazy_len, 0);
354+
rcu_cblist_enqueue(&rdp->nocb_bypass, rhp);
355+
rhp = NULL;
357356
}
357+
rcu_cblist_flush_enqueue(&rcl, &rdp->nocb_bypass, rhp);
358+
WRITE_ONCE(rdp->lazy_len, 0);
358359

359360
rcu_segcblist_insert_pend_cbs(&rdp->cblist, &rcl);
360361
WRITE_ONCE(rdp->nocb_bypass_first, j);

0 commit comments

Comments
 (0)