Re: [PATCH -mm] memrlimit: fix task_lock() recursive locking

From: Balbir Singh
Date: Thu Sep 18 2008 - 14:48:41 EST


Andrea Righi wrote:
> cgroup_mm_owner_callbacks() can be called with task_lock() held in
> mm_update_next_owner(), and all the .mm_owner_changed callbacks seem to
> be *always* called with task_lock() held.
>
> Actually, memrlimit is using task_lock() via get_task_mm() in
> memrlimit_cgroup_mm_owner_changed(), raising the following recursive locking
> trace:

[snip]

Thanks for the BUG report()

[snip]

> static void memrlimit_cgroup_mm_owner_changed(struct cgroup_subsys *ss,
> struct cgroup *old_cgrp,
> @@ -246,7 +246,7 @@ static void memrlimit_cgroup_mm_owner_changed(struct cgroup_subsys *ss,
> struct task_struct *p)
> {
> struct memrlimit_cgroup *memrcg, *old_memrcg;
> - struct mm_struct *mm = get_task_mm(p);
> + struct mm_struct *mm = get_task_mm_task_locked(p);
>

Since we hold task_lock(), we know that p->mm cannot change and we don't have to
worry about incrementing mm_users. I think using just p->mm will work, we do
have checks to make sure we don't pick a kernel thread. I vote for going down
that road.


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