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

From: Paul Menage
Date: Tue Sep 09 2008 - 23:12:03 EST


On Tue, Sep 9, 2008 at 7:18 PM, Lai Jiangshan <laijs@xxxxxxxxxxxxxx> wrote:
> hlist_for_each_entry(cg, node, hhead, hlist) {
> if (!memcmp(template, cg->subsys, sizeof(cg->subsys))) {
> /* All subsystems matched */
> + if (!kref_get_not_zero(&cg->ref))
> + return NULL;

Maybe it would be better to do:

if (!memcmp(...) && kref_get_not_zero(&cg->ref))
return cg;

so that in the event of a race, we carry on looking in the array.
> + * Return 0 if this refcount is 0, otherwise return 1.
> + */
> +int kref_get_not_zero(struct kref *kref)

Probably clearer to have a bool return type.

Paul
--
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/