[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20120621010435.GA30634@dhcp-172-17-108-109.mtv.corp.google.com>
Date: Wed, 20 Jun 2012 18:04:35 -0700
From: Tejun Heo <tj@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, Salman Qazi <sqazi@...gle.com>
Subject: [GIT PULL] cgroup fixes for v3.5-rc3
Hello, Linus.
Please pull from the following branch to receive two patches fixing a
refcnt race bug during css_put(). Decing and checking the value
weren't atomic and two tasks could think that they both pushed the
counter to zero.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-3.5-fixes
Salman Qazi (2):
cgroup: make sure that decisions in __css_put are atomic
cgroups: Account for CSS_DEACT_BIAS in __css_put
Thanks.
---
kernel/cgroup.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 72fcd30..2097684 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -255,12 +255,17 @@ int cgroup_lock_is_held(void)
EXPORT_SYMBOL_GPL(cgroup_lock_is_held);
+static int css_unbias_refcnt(int refcnt)
+{
+ return refcnt >= 0 ? refcnt : refcnt - CSS_DEACT_BIAS;
+}
+
/* the current nr of refs, always >= 0 whether @css is deactivated or not */
static int css_refcnt(struct cgroup_subsys_state *css)
{
int v = atomic_read(&css->refcnt);
- return v >= 0 ? v : v - CSS_DEACT_BIAS;
+ return css_unbias_refcnt(v);
}
/* convenient tests for these bits */
@@ -4982,10 +4987,12 @@ EXPORT_SYMBOL_GPL(__css_tryget);
void __css_put(struct cgroup_subsys_state *css)
{
struct cgroup *cgrp = css->cgroup;
+ int v;
rcu_read_lock();
- atomic_dec(&css->refcnt);
- switch (css_refcnt(css)) {
+ v = css_unbias_refcnt(atomic_dec_return(&css->refcnt));
+
+ switch (v) {
case 1:
if (notify_on_release(cgrp)) {
set_bit(CGRP_RELEASABLE, &cgrp->flags);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists