mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
cpuset,mm: fix no node to alloc memory when changing cpuset's mems
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. [[email protected]: fix spello] Signed-off-by: Miao Xie <[email protected]> Cc: David Rientjes <[email protected]> Cc: Nick Piggin <[email protected]> Cc: Paul Menage <[email protected]> Cc: Lee Schermerhorn <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Ravikiran Thirumalai <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Andi Kleen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
708c1bbc9d
commit
c0ff7453bb
11 changed files with 148 additions and 20 deletions
10
mm/filemap.c
10
mm/filemap.c
|
|
@ -461,9 +461,15 @@ EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
|
|||
#ifdef CONFIG_NUMA
|
||||
struct page *__page_cache_alloc(gfp_t gfp)
|
||||
{
|
||||
int n;
|
||||
struct page *page;
|
||||
|
||||
if (cpuset_do_page_mem_spread()) {
|
||||
int n = cpuset_mem_spread_node();
|
||||
return alloc_pages_exact_node(n, gfp, 0);
|
||||
get_mems_allowed();
|
||||
n = cpuset_mem_spread_node();
|
||||
page = alloc_pages_exact_node(n, gfp, 0);
|
||||
put_mems_allowed();
|
||||
return page;
|
||||
}
|
||||
return alloc_pages(gfp, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue