2 * css_get - obtain a reference on the specified css
5 * The caller must already have a reference.
8 void css_get(struct cgroup_subsys_state *css)
10 if (!(css->flags & CSS_NO_REF))
11 percpu_ref_get(&css->refcnt);
13 CGROUP_REF_EXPORT(css_get)
16 * css_get_many - obtain references on the specified css
18 * @n: number of references to get
20 * The caller must already have a reference.
23 void css_get_many(struct cgroup_subsys_state *css, unsigned int n)
25 if (!(css->flags & CSS_NO_REF))
26 percpu_ref_get_many(&css->refcnt, n);
28 CGROUP_REF_EXPORT(css_get_many)
31 * css_tryget - try to obtain a reference on the specified css
34 * Obtain a reference on @css unless it already has reached zero and is
35 * being released. This function doesn't care whether @css is on or
36 * offline. The caller naturally needs to ensure that @css is accessible
37 * but doesn't have to be holding a reference on it - IOW, RCU protected
38 * access is good enough for this function. Returns %true if a reference
39 * count was successfully obtained; %false otherwise.
42 bool css_tryget(struct cgroup_subsys_state *css)
44 if (!(css->flags & CSS_NO_REF))
45 return percpu_ref_tryget(&css->refcnt);
48 CGROUP_REF_EXPORT(css_tryget)
51 * css_tryget_online - try to obtain a reference on the specified css if online
54 * Obtain a reference on @css if it's online. The caller naturally needs
55 * to ensure that @css is accessible but doesn't have to be holding a
56 * reference on it - IOW, RCU protected access is good enough for this
57 * function. Returns %true if a reference count was successfully obtained;
61 bool css_tryget_online(struct cgroup_subsys_state *css)
63 if (!(css->flags & CSS_NO_REF))
64 return percpu_ref_tryget_live(&css->refcnt);
67 CGROUP_REF_EXPORT(css_tryget_online)
70 * css_put - put a css reference
73 * Put a reference obtained via css_get() and css_tryget_online().
76 void css_put(struct cgroup_subsys_state *css)
78 if (!(css->flags & CSS_NO_REF))
79 percpu_ref_put(&css->refcnt);
81 CGROUP_REF_EXPORT(css_put)
84 * css_put_many - put css references
86 * @n: number of references to put
88 * Put references obtained via css_get() and css_tryget_online().
91 void css_put_many(struct cgroup_subsys_state *css, unsigned int n)
93 if (!(css->flags & CSS_NO_REF))
94 percpu_ref_put_many(&css->refcnt, n);
96 CGROUP_REF_EXPORT(css_put_many)