]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - include/linux/cgroup.h
cgroup: Use css_tryget() instead of css_tryget_online() in task_get_css()
[thirdparty/kernel/stable.git] / include / linux / cgroup.h
index 81f58b4a5418da9bf57d1c6f78a2782aeba61377..b6a8df3b7e9693e6f61a2d09064833e15eb7892a 100644 (file)
@@ -487,7 +487,7 @@ static inline struct cgroup_subsys_state *task_css(struct task_struct *task,
  *
  * Find the css for the (@task, @subsys_id) combination, increment a
  * reference on and return it.  This function is guaranteed to return a
- * valid css.
+ * valid css.  The returned css may already have been offlined.
  */
 static inline struct cgroup_subsys_state *
 task_get_css(struct task_struct *task, int subsys_id)
@@ -497,7 +497,13 @@ task_get_css(struct task_struct *task, int subsys_id)
        rcu_read_lock();
        while (true) {
                css = task_css(task, subsys_id);
-               if (likely(css_tryget_online(css)))
+               /*
+                * Can't use css_tryget_online() here.  A task which has
+                * PF_EXITING set may stay associated with an offline css.
+                * If such task calls this function, css_tryget_online()
+                * will keep failing.
+                */
+               if (likely(css_tryget(css)))
                        break;
                cpu_relax();
        }