lkml.org 
[lkml]   [2008]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 1/6] memcg: fix pre_destory handler
> +static bool memcg_is_obsolete(struct mem_cgroup *mem)
> +{

Will this function be called with mem->css.refcnt == 0? If yes, then
this function is racy.

cg = mem->css.cgroup
cgroup_diput()
mem_cgroup_destroy()
mem->css.cgroup = NULL;
kfree(cg);
if (!cg || cgroup_is_removed(cg)...)
(accessing invalid cg)

> + struct cgroup *cg = mem->css.cgroup;
> + /*
> + * "Being Removed" means pre_destroy() handler is called.
> + * After "pre_destroy" handler is called, memcg should not
> + * have any additional charges.
> + * This means there are small races for mis-accounting. But this
> + * mis-accounting should happen only under swap-in opration.
> + * (Attachin new task will fail if cgroup is under rmdir()).
> + */
> +
> + if (!cg || cgroup_is_removed(cg) || cgroup_is_being_removed(cg))
> + return true;
> + return false;
> +}
> +

...

> static void mem_cgroup_destroy(struct cgroup_subsys *ss,
> struct cgroup *cont)
> {
> - mem_cgroup_free(mem_cgroup_from_cont(cont));
> + struct mem_cgroup *mem = mem_cgroup_from_cont(cont):
> + mem_cgroup_free(mem);
> + /* forget */
> + mem->css.cgroup = NULL;

mem might already be destroyed by mem_cgroup_free(mem).

> }


\
 
 \ /
  Last update: 2008-12-10 03:23    [from the cache]
©2003-2011 Jasper Spaans