Re: [PATCH] memcontrol: rcu_read_lock() to protectmm_match_cgroup()

From: KAMEZAWA Hiroyuki
Date: Fri Nov 21 2008 - 05:33:17 EST


On Fri, 21 Nov 2008 16:49:43 +0800
Lai Jiangshan <laijs@xxxxxxxxxxxxxx> wrote:

>
> mm_match_cgroup() calls cgroup_subsys_state().
>
> we must use rcu_read_lock() to protect cgroup_subsys_state().
>
Thanks,
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>

> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> ---
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 1fbe14d..ce89ff0 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -47,8 +47,15 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
>
> extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
>
> -#define mm_match_cgroup(mm, cgroup) \
> - ((cgroup) == mem_cgroup_from_task((mm)->owner))
> +static inline
> +int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
> +{
> + struct mem_cgroup *mem;
> + rcu_read_lock();
> + mem = mem_cgroup_from_task((mm)->owner);
> + rcu_read_unlock();
> + return cgroup == mem;
> +}
>
> extern int
> mem_cgroup_prepare_migration(struct page *page, struct page *newpage);
>
>

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