Commit 0d3e9465 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] hugetlb.c - fix try_to_free_low()

From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>

Turn on CONFIG_HIGHMEM and CONFIG_HUGETLBFS.  Try to config the hugetlb
pool:

[root@quokka]# echo 100 > /proc/sys/vm/nr_hugepages
[root@quokka]# grep HugePage /proc/meminfo
HugePages_Total:   100
HugePages_Free:    100

[root@quokka]# echo 20 > /proc/sys/vm/nr_hugepages
[root@quokka]# grep HugePage /proc/meminfo
HugePages_Total:     0
HugePages_Free:      0

[root@quokka]# echo 100 > /proc/sys/vm/nr_hugepages
[root@quokka]# grep HugePage /proc/meminfo
HugePages_Total:   100
HugePages_Free:    100

[root@quokka]# echo 0 > /proc/sys/vm/nr_hugepages
[root@quokka]# grep HugePage /proc/meminfo
HugePages_Total:    31
HugePages_Free:     31

The argument "count" passed to try_to_free_low() is the config parameter
for desired hugetlb page pool size.  But the implementation took that input
argument as number of pages to free.  It also decrement the config
parameter as well.  All give random behavior depend on how many hugetlb
pages are in normal/highmem zone.

A two line fix in try_to_free_low() would be:

-			if (!--count)
-				return 0;
+			if (count >= nr_huge_pages)
+				return count;

But more appropriately, that function shouldn't return anything.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent edadc05f
......@@ -130,7 +130,7 @@ static void update_and_free_page(struct page *page)
}
#ifdef CONFIG_HIGHMEM
static int try_to_free_low(unsigned long count)
static void try_to_free_low(unsigned long count)
{
int i;
for (i = 0; i < MAX_NUMNODES; ++i) {
......@@ -141,16 +141,14 @@ static int try_to_free_low(unsigned long count)
list_del(&page->lru);
update_and_free_page(page);
--free_huge_pages;
if (!--count)
return 0;
if (count >= nr_huge_pages)
return;
}
}
return count;
}
#else
static inline int try_to_free_low(unsigned long count)
static inline void try_to_free_low(unsigned long count)
{
return count;
}
#endif
......@@ -170,7 +168,8 @@ static unsigned long set_max_huge_pages(unsigned long count)
return nr_huge_pages;
spin_lock(&hugetlb_lock);
for (count = try_to_free_low(count); count < nr_huge_pages; --free_huge_pages) {
try_to_free_low(count);
for (; count < nr_huge_pages; --free_huge_pages) {
struct page *page = dequeue_huge_page();
if (!page)
break;
......
Markdown is supported
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