[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130128212407.GF26407@google.com>
Date: Mon, 28 Jan 2013 13:24:07 -0800
From: Kent Overstreet <koverstreet@...gle.com>
To: Tejun Heo <tj@...nel.org>
Cc: Oleg Nesterov <oleg@...hat.com>, srivatsa.bhat@...ux.vnet.ibm.com,
rusty@...tcorp.com.au, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] generic dynamic per cpu refcounting
On Mon, Jan 28, 2013 at 01:18:32PM -0800, Tejun Heo wrote:
> Hello, Kent.
>
> On Mon, Jan 28, 2013 at 12:55:40PM -0800, Kent Overstreet wrote:
> > > I don't understand why we need two stages. What prevents the killing
> > > thread from fetching percpu counters after dying passes one
> > > synchronize_sched()?
> >
> > It does. The second synchronize_sched() is needed after we set state :=
> > dead, and before we drop the initial ref. Otherwise the ref could hit 0
> > before percpu_ref_put knows to check for it.
>
> Still a bit confused. Why do we need to make the two steps separate?
> What prevents us from doing the following?
>
> set dying;
> synchronize_sched();
> collect percpu refs into global atomic_t;
> put the base ref;
After you set state := dying, percpu_ref_put() decrements the atomic_t,
but it can't check if it's 0 yet because the thread that's collecting
the percpu refs might not be done yet.
So percpu_ref_put can't check for ref == 0 until after state == dead.
But the put in your example might have made ref 0. When did you set
state to dead?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists