Re: [PATCH] cgroups: fix probable race with put_css_set[_taskexit]and find_css_set

From: Greg KH
Date: Wed Sep 10 2008 - 01:03:37 EST


On Wed, Sep 10, 2008 at 10:18:36AM +0800, Lai Jiangshan wrote:
> Paul Menage wrote:
> > On Mon, Aug 18, 2008 at 11:29 PM, Lai Jiangshan <laijs@xxxxxxxxxxxxxx> wrote:
> >
> > 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)
> >
>
> [CC: Greg Kroah-Hartman <greg@xxxxxxxxx>]
>
> There are indeed several ways fix this race by Using the
> atomic-functions directly. I prefer the second one, i makes all
> code clearly. And put_css_set[_taskexit] do not need to be changed.
>
> I don't think adding kref_get_not_zero() API is a good idea.
> It will bring kref APIs to a little chaos, kref_get_not_zero() is
> hard to be used, for this function needs a special lock held.
>
> But I tried:

What are you trying to solve here with this change? I agree, it does
seem a bit "chaotic" :)

I thought we used to have something like this for kref in the past, but
I must be mistaken as it's no longer there...

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/