Commit 348e1e04 authored by Nishanth Aravamudan's avatar Nishanth Aravamudan Committed by Linus Torvalds
Browse files

hugetlb: fix pool shrinking while in restricted cpuset

Adam Litke noticed that currently we grow the hugepage pool independent of any
cpuset the running process may be in, but when shrinking the pool, the cpuset
is checked.  This leads to inconsistency when shrinking the pool in a
restricted cpuset -- an administrator may have been able to grow the pool on a
node restricted by a containing cpuset, but they cannot shrink it there.

There are two options: either prevent growing of the pool outside of the
cpuset or allow shrinking outside of the cpuset.  >From previous discussions
on linux-mm, /proc/sys/vm/nr_hugepages is an administrative interface that
should not be restricted by cpusets.  So allow shrinking the pool by removing
pages from nodes outside of current's cpuset.
Signed-off-by: default avatarNishanth Aravamudan <>
Acked-by: default avatarAdam Litke <>
Cc: William Irwin <>
Cc: Lee Schermerhorn <>
Cc: Christoph Lameter <>
Cc: Paul Jackson <>
Cc: David Gibson <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent ac09b3a1
......@@ -71,7 +71,25 @@ static void enqueue_huge_page(struct page *page)
static struct page *dequeue_huge_page(struct vm_area_struct *vma,
static struct page *dequeue_huge_page(void)
int nid;
struct page *page = NULL;
for (nid = 0; nid < MAX_NUMNODES; ++nid) {
if (!list_empty(&hugepage_freelists[nid])) {
page = list_entry(hugepage_freelists[nid].next,
struct page, lru);
return page;
static struct page *dequeue_huge_page_vma(struct vm_area_struct *vma,
unsigned long address)
int nid;
......@@ -410,7 +428,7 @@ static struct page *alloc_huge_page_shared(struct vm_area_struct *vma,
struct page *page;
page = dequeue_huge_page(vma, addr);
page = dequeue_huge_page_vma(vma, addr);
return page ? page : ERR_PTR(-VM_FAULT_OOM);
......@@ -425,7 +443,7 @@ static struct page *alloc_huge_page_private(struct vm_area_struct *vma,
if (free_huge_pages > resv_huge_pages)
page = dequeue_huge_page(vma, addr);
page = dequeue_huge_page_vma(vma, addr);
if (!page) {
page = alloc_buddy_huge_page(vma, addr);
......@@ -578,7 +596,7 @@ static unsigned long set_max_huge_pages(unsigned long count)
min_count = max(count, min_count);
while (min_count < persistent_huge_pages) {
struct page *page = dequeue_huge_page(NULL, 0);
struct page *page = dequeue_huge_page();
if (!page)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment