~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/cgroup_refcnt.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**
  2  * css_get - obtain a reference on the specified css
  3  * @css: target css
  4  *
  5  * The caller must already have a reference.
  6  */
  7 CGROUP_REF_FN_ATTRS
  8 void css_get(struct cgroup_subsys_state *css)
  9 {
 10         if (!(css->flags & CSS_NO_REF))
 11                 percpu_ref_get(&css->refcnt);
 12 }
 13 CGROUP_REF_EXPORT(css_get)
 14 
 15 /**
 16  * css_get_many - obtain references on the specified css
 17  * @css: target css
 18  * @n: number of references to get
 19  *
 20  * The caller must already have a reference.
 21  */
 22 CGROUP_REF_FN_ATTRS
 23 void css_get_many(struct cgroup_subsys_state *css, unsigned int n)
 24 {
 25         if (!(css->flags & CSS_NO_REF))
 26                 percpu_ref_get_many(&css->refcnt, n);
 27 }
 28 CGROUP_REF_EXPORT(css_get_many)
 29 
 30 /**
 31  * css_tryget - try to obtain a reference on the specified css
 32  * @css: target css
 33  *
 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.
 40  */
 41 CGROUP_REF_FN_ATTRS
 42 bool css_tryget(struct cgroup_subsys_state *css)
 43 {
 44         if (!(css->flags & CSS_NO_REF))
 45                 return percpu_ref_tryget(&css->refcnt);
 46         return true;
 47 }
 48 CGROUP_REF_EXPORT(css_tryget)
 49 
 50 /**
 51  * css_tryget_online - try to obtain a reference on the specified css if online
 52  * @css: target css
 53  *
 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;
 58  * %false otherwise.
 59  */
 60 CGROUP_REF_FN_ATTRS
 61 bool css_tryget_online(struct cgroup_subsys_state *css)
 62 {
 63         if (!(css->flags & CSS_NO_REF))
 64                 return percpu_ref_tryget_live(&css->refcnt);
 65         return true;
 66 }
 67 CGROUP_REF_EXPORT(css_tryget_online)
 68 
 69 /**
 70  * css_put - put a css reference
 71  * @css: target css
 72  *
 73  * Put a reference obtained via css_get() and css_tryget_online().
 74  */
 75 CGROUP_REF_FN_ATTRS
 76 void css_put(struct cgroup_subsys_state *css)
 77 {
 78         if (!(css->flags & CSS_NO_REF))
 79                 percpu_ref_put(&css->refcnt);
 80 }
 81 CGROUP_REF_EXPORT(css_put)
 82 
 83 /**
 84  * css_put_many - put css references
 85  * @css: target css
 86  * @n: number of references to put
 87  *
 88  * Put references obtained via css_get() and css_tryget_online().
 89  */
 90 CGROUP_REF_FN_ATTRS
 91 void css_put_many(struct cgroup_subsys_state *css, unsigned int n)
 92 {
 93         if (!(css->flags & CSS_NO_REF))
 94                 percpu_ref_put_many(&css->refcnt, n);
 95 }
 96 CGROUP_REF_EXPORT(css_put_many)
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php