From: Andrew Morton on
On Tue, 04 May 2010 18:54:02 +0800
Miao Xie <miaox(a)cn.fujitsu.com> wrote:

> Before applying this patch, cpuset updates task->mems_allowed and mempolicy by
> setting all new bits in the nodemask first, and clearing all old unallowed bits
> later. But in the way, the allocator may find that there is no node to alloc
> memory.
>
> The reason is that cpuset rebinds the task's mempolicy, it cleans the nodes which
> the allocater can alloc pages on, for example:
> (mpol: mempolicy)
> task1 task1's mpol task2
> alloc page 1
> alloc on node0? NO 1
> 1 change mems from 1 to 0
> 1 rebind task1's mpol
> 0-1 set new bits
> 0 clear disallowed bits
> alloc on node1? NO 0
> ...
> can't alloc page
> goto oom
>
> This patch fixes this problem by expanding the nodes range first(set newly
> allowed bits) and shrink it lazily(clear newly disallowed bits). So we use a
> variable to tell the write-side task that read-side task is reading nodemask,
> and the write-side task clears newly disallowed nodes after read-side task ends
> the current memory allocation.
>
>
> ...
>
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -16,6 +16,7 @@
> #include <linux/key.h>
> #include <linux/security.h>
> #include <linux/cpu.h>
> +#include <linux/cpuset.h>
> #include <linux/acct.h>
> #include <linux/tsacct_kern.h>
> #include <linux/file.h>
> @@ -1003,8 +1004,10 @@ NORET_TYPE void do_exit(long code)
>
> exit_notify(tsk, group_dead);
> #ifdef CONFIG_NUMA
> + task_lock(tsk);
> mpol_put(tsk->mempolicy);
> tsk->mempolicy = NULL;
> + task_unlock(tsk);
> #endif
> #ifdef CONFIG_FUTEX
> if (unlikely(current->pi_state_cache))

Given that this function is already holding task_lock(tsk), this
didn't work very well.

Also, why was the inclusion of cpuset.h added? Nothing which this
patch adds appears to need it?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andrew Morton on
On Wed, 12 May 2010 14:16:42 +0800 Miao Xie <miaox(a)cn.fujitsu.com> wrote:

> >> #include <linux/security.h>
> >> #include <linux/cpu.h>
> >> +#include <linux/cpuset.h>
> >> #include <linux/acct.h>
> >> #include <linux/tsacct_kern.h>
> >> #include <linux/file.h>
> >> @@ -1003,8 +1004,10 @@ NORET_TYPE void do_exit(long code)
> >>
> >> exit_notify(tsk, group_dead);
> >> #ifdef CONFIG_NUMA
> >> + task_lock(tsk);
> >> mpol_put(tsk->mempolicy);
> >> tsk->mempolicy = NULL;
> >> + task_unlock(tsk);
> >> #endif
> >> #ifdef CONFIG_FUTEX
> >> if (unlikely(current->pi_state_cache))
> >
> > Given that this function is already holding task_lock(tsk), this
> > didn't work very well.
>
> Sorry for replying late.
>
> Thanks for your patch that removes task_lock(tsk).
>
> I made this patch against the mainline tree, and do_exit() in the mainline tree
> doesn't hold task_lock(tsk), so I took task_lock(tsk). But I didn't take notice
> that do_exit() in the mmotm tree had been changed, and I made this mistake.

Ah, hang on. Yes, I had to manually fix that a lot of times. The code
you were patching has moved from do_exit() over to exit_mm(). AFACIT
my change is still OK though. Please carefully review latest -mm?


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