[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6599ad830809091728m426a7219h1977001f86cb5f31@mail.gmail.com>
Date: Tue, 9 Sep 2008 17:28:03 -0700
From: "Paul Menage" <menage@...gle.com>
To: "Lai Jiangshan" <laijs@...fujitsu.com>
Cc: "Andrew Morton" <akpm@...ux-foundation.org>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cgroups: fix probable race with put_css_set[_taskexit] and find_css_set
On Mon, Aug 18, 2008 at 11:29 PM, Lai Jiangshan <laijs@...fujitsu.com> wrote:
> put_css_set_taskexit may be called when find_css_set is called on
> other cpu. And the race will occur:
>
Sorry I didn't respond to this when it originally came out - I was on vacation.
I agree that it's a race that needs to be fixed, but I'm not sure that
I like the fix that can generate kref warnings.
I can see two possible fixes:
1) avoid the race entirely by introducing some new primitives:
atomic_dec_and_write_lock() (like atomic_dec_and_lock(), but for an rwlock)
and kref_put_and_write_lock() which would be something like:
int kref_put_and_write_lock(struct kref *kref, void (*release)(struct
kref *kref), rwlock*lock)
{
if(atomic_dec_and_write_lock(&kref->refcount, lock)) {
release(kref);
return 1;
}
return 0;
}
We'd then use kref_put_and_write_lock(), and enter __release_css_set()
with the lock already held
2) Use atomic_inc_not_zero() in find_existing_css_set(), to ensure
that we only return a referenced css, and remove the get_css_set()
call from find_css_set(). (Possibly wrapping this in a new
kref_get_not_zero() function)
Paul
--
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