diff options
-rw-r--r-- | include/linux/cgroup.h | 1 | ||||
-rw-r--r-- | kernel/cgroup.c | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index e267e62827bb..e4e8e117d27d 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -99,6 +99,7 @@ static inline bool css_tryget(struct cgroup_subsys_state *css) | |||
99 | while (!atomic_inc_not_zero(&css->refcnt)) { | 99 | while (!atomic_inc_not_zero(&css->refcnt)) { |
100 | if (test_bit(CSS_REMOVED, &css->flags)) | 100 | if (test_bit(CSS_REMOVED, &css->flags)) |
101 | return false; | 101 | return false; |
102 | cpu_relax(); | ||
102 | } | 103 | } |
103 | return true; | 104 | return true; |
104 | } | 105 | } |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 0066092de19a..492215d67fa5 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2509,7 +2509,7 @@ static int cgroup_clear_css_refs(struct cgroup *cgrp) | |||
2509 | for_each_subsys(cgrp->root, ss) { | 2509 | for_each_subsys(cgrp->root, ss) { |
2510 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; | 2510 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; |
2511 | int refcnt; | 2511 | int refcnt; |
2512 | do { | 2512 | while (1) { |
2513 | /* We can only remove a CSS with a refcnt==1 */ | 2513 | /* We can only remove a CSS with a refcnt==1 */ |
2514 | refcnt = atomic_read(&css->refcnt); | 2514 | refcnt = atomic_read(&css->refcnt); |
2515 | if (refcnt > 1) { | 2515 | if (refcnt > 1) { |
@@ -2523,7 +2523,10 @@ static int cgroup_clear_css_refs(struct cgroup *cgrp) | |||
2523 | * css_tryget() to spin until we set the | 2523 | * css_tryget() to spin until we set the |
2524 | * CSS_REMOVED bits or abort | 2524 | * CSS_REMOVED bits or abort |
2525 | */ | 2525 | */ |
2526 | } while (atomic_cmpxchg(&css->refcnt, refcnt, 0) != refcnt); | 2526 | if (atomic_cmpxchg(&css->refcnt, refcnt, 0) == refcnt) |
2527 | break; | ||
2528 | cpu_relax(); | ||
2529 | } | ||
2527 | } | 2530 | } |
2528 | done: | 2531 | done: |
2529 | for_each_subsys(cgrp->root, ss) { | 2532 | for_each_subsys(cgrp->root, ss) { |