lkml.org 
[lkml]   [2014]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 14/14] cgroup: implement css_tryget()
On Sun, May 11, 2014 at 12:54:59AM -0400, Johannes Weiner wrote:
> > /**
> > + * css_tryget - try to obtain a reference on the specified css
> > + * @css: target css
> > + *
> > + * Obtain a reference on @css unless it already has reached zero and is
> > + * being released. This function doesn't care whether @css is on or
> > + * offline. The caller naturally needs to ensure that @css is accessible
> > + * but doesn't have to be holding a reference on it - IOW, RCU protected
> > + * access is good enough for this function. Returns %true if a reference
> > + * count was successfully obtained; %false otherwise.
> > + */
> > +static inline bool css_tryget(struct cgroup_subsys_state *css)
> > +{
> > + return percpu_ref_tryget(&css->refcnt);
> > +}
>
> percpu_ref_tryget() fails once killed (transitioned from per-cpu to
> atomic mode), but exactly this happens during offlining and so this
> would actually be equivalent to css_tryget_online(), no?

Not any more. percpu/for-3.16 already contains the updates to
percpu_ref_tryget[_live](). percpu_ref_tryget() succeeds as long as
the refcnt is above zero.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2014-05-11 15:21    [W:0.215 / U:0.872 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site