From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: <linux-kernel@vger.kernel.org>
Subject: More bug fix in mm/hugetlb.c - fix try_to_free_low()
Date: Wed, 23 Jun 2004 12:33:00 -0700 [thread overview]
Message-ID: <200406231931.i5NJVeY10040@unix-os.sc.intel.com> (raw)
Is it just me having bad luck with hugetlb for x86 lately? Take base
2.6.7, 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.
diff -Nurp linux-2.6.7.orig/mm/hugetlb.c linux-2.6.7/mm/hugetlb.c
--- linux-2.6.7.orig/mm/hugetlb.c 2004-06-15 22:19:37.000000000 -0700
+++ linux-2.6.7/mm/hugetlb.c 2004-06-23 12:11:31.000000000 -0700
@@ -130,7 +130,7 @@ static void update_and_free_page(struct
}
#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
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(
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;
next reply other threads:[~2004-06-23 19:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-23 19:33 Chen, Kenneth W [this message]
2004-06-23 19:42 ` William Lee Irwin III
2004-06-23 21:50 ` Chen, Kenneth W
2004-06-23 22:17 ` Keith Owens
2004-06-23 22:24 ` Chen, Kenneth W
2004-06-23 22:35 ` William Lee Irwin III
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200406231931.i5NJVeY10040@unix-os.sc.intel.com \
--to=kenneth.w.chen@intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®