[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 6 Jun 2017 11:22:08 -0700
From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, mingo@...nel.org,
jiangshanlai@...il.com, dipankar@...ibm.com,
akpm@...ux-foundation.org, mathieu.desnoyers@...icios.com,
josh@...htriplett.org, tglx@...utronix.de, rostedt@...dmis.org,
dhowells@...hat.com, edumazet@...gle.com, fweisbec@...il.com,
oleg@...hat.com, Paolo Bonzini <pbonzini@...hat.com>,
kvm@...r.kernel.org, Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH RFC tip/core/rcu 1/2] srcu: Allow use of Tiny/Tree SRCU
from both process and interrupt context
On Tue, Jun 06, 2017 at 08:00:09PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 06, 2017 at 10:50:48AM -0700, Paul E. McKenney wrote:
> > On Tue, Jun 06, 2017 at 07:23:42PM +0200, Peter Zijlstra wrote:
> > > On Mon, Jun 05, 2017 at 03:09:50PM -0700, Paul E. McKenney wrote:
> > > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > > > index 3ae8474557df..157654fa436a 100644
> > > > --- a/kernel/rcu/srcutree.c
> > > > +++ b/kernel/rcu/srcutree.c
> > > > @@ -357,7 +357,7 @@ EXPORT_SYMBOL_GPL(cleanup_srcu_struct);
> > > >
> > > > /*
> > > > * Counts the new reader in the appropriate per-CPU element of the
> > > > - * srcu_struct. Must be called from process context.
> > > > + * srcu_struct.
> > > > * Returns an index that must be passed to the matching srcu_read_unlock().
> > > > */
> > > > int __srcu_read_lock(struct srcu_struct *sp)
> > > > @@ -365,7 +365,7 @@ int __srcu_read_lock(struct srcu_struct *sp)
> > > > int idx;
> > > >
> > > > idx = READ_ONCE(sp->srcu_idx) & 0x1;
> > > > - __this_cpu_inc(sp->sda->srcu_lock_count[idx]);
> > > > + this_cpu_inc(sp->sda->srcu_lock_count[idx]);
> > > > smp_mb(); /* B */ /* Avoid leaking the critical section. */
> > > > return idx;
> > > > }
> > >
> > > So again, the change is to make this an IRQ safe operation, however if
> > > we have this balance requirement, the IRQ will not visibly change the
> > > value and load-store should be good again, no?
> > >
> > > Or am I missing some other detail with this implementation?
> >
> > Unlike Tiny SRCU, Classic and Tree SRCU increment one counter
> > (->srcu_lock_count[]) and decrement another (->srcu_unlock_count[]).
> > So balanced srcu_read_lock() and srcu_read_unlock() within an irq
> > handler would increment both counters, with no decrements. Therefore,
> > __srcu_read_lock()'s counter manipulation needs to be irq-safe.
>
> Oh, duh, so much for being able to read...
I know that feeling! Including the s/decrement/increment/ needed in my
erroneous paragraph above. Classic and Tree SRCU increment both counters,
and they decrement nothing. :-/
Thanx, Paul
Powered by blists - more mailing lists