Messages in this thread | | | Date | Mon, 17 Feb 2020 17:21:31 -0500 | From | Steven Rostedt <> | Subject | Re: [PATCH tip/core/rcu 22/30] rcu: Don't flag non-starting GPs before GP kthread is running |
| |
On Mon, 17 Feb 2020 14:03:56 -0800 "Paul E. McKenney" <paulmck@kernel.org> wrote:
> And what is a day without micro-optimization of a slowpath? :-)
A day you have off, but still find yourself working ;-)
> > OK, let's see... > > Grace-period kthread wakeups are normally mediated by rcu_start_this_gp(), > which uses a funnel lock to consolidate concurrent requests to start > a grace period. If a grace period is already in progress, it refrains > from doing a wakeup because that means that the grace-period kthread > will check for another grace period being needed at the end of the > current grace period. > > Exceptions include: > > o The wakeup reporting the last quiescent state of the current > grace period. > > o Emergency situations such as callback overloads and RCU CPU stalls. > > So on a busy system that is not overloaded, the common case is that > rcu_gp_kthread_wake() is invoked only once per grace period because there > is no emergency and there is a grace period in progress. If this system > has short idle periods and a fair number of quiescent states, a reasonable > amount of idle time, then the last quiescent state will not normally be > detected by the grace-period kthread. But workloads can of course vary. > > The "!t" holds only during early boot. So we could put a likely() around > the "t". But more to the point, at runtime, "!t" would always be false, > so it really should be last in the list of "||" clauses. This isn't > enough of a fastpath for a static branch to make sense.
Hey! Does that mean we can add a static branch for that check?
struct static_key rcu_booting = STATIC_KEY_INIT_TRUE;
[...]
if (READ_ONCE(rcu_state.gp_flags) || (current == t && !in_irq() && !in_serving_softirq()) return;
if (static_branch_unlikely(&rcu_booting) && !t) return;
At end of boot:
static_key_disable(&rcu_booting);
That way we can really micro-optimize the slow path, and it basically becomes a nop!
-- Steve
> > The "!READ_ONCE(rcu_state.gp_flags)" will normally hold, though it is > false often enough to pay for itself. Or has been in the past, anyway. > I suspect that access to the global variable rcu_state.gp_flags is not > always fast either. > > So I am having difficulty talking myself into modifying this one given > the frequency of operations. > > Thanx, Paul
| |