LCOV - code coverage report
Current view: top level - include/linux - cgroup_refcnt.h (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc3-djwa @ Mon Jul 31 20:08:17 PDT 2023 Lines: 7 11 63.6 %
Date: 2023-07-31 20:08:17 Functions: 2 3 66.7 %

          Line data    Source code
       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           0 : void css_get(struct cgroup_subsys_state *css)
       9             : {
      10           0 :         if (!(css->flags & CSS_NO_REF))
      11           0 :                 percpu_ref_get(&css->refcnt);
      12           0 : }
      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      979100 : bool css_tryget(struct cgroup_subsys_state *css)
      43             : {
      44      979100 :         if (!(css->flags & CSS_NO_REF))
      45      979096 :                 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      979080 : void css_put(struct cgroup_subsys_state *css)
      77             : {
      78      979080 :         if (!(css->flags & CSS_NO_REF))
      79      979083 :                 percpu_ref_put(&css->refcnt);
      80      979096 : }
      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)

Generated by: LCOV version 1.14