[PATCH] memory hotremoval for linux-2.6.7 [10/16]
From: Hirokazu Takahashi
Date: Wed Jul 14 2004 - 09:19:05 EST
--- linux-2.6.7.ORG/mm/hugetlb.c Thu Jun 17 15:17:51 2032
+++ linux-2.6.7/mm/hugetlb.c Thu Jun 17 15:21:18 2032
@@ -15,8 +15,20 @@ const unsigned long hugetlb_zero = 0, hu
static unsigned long nr_huge_pages, free_huge_pages;
unsigned long max_huge_pages;
static struct list_head hugepage_freelists[MAX_NUMNODES];
+static struct list_head hugepage_alllists[MAX_NUMNODES];
static spinlock_t hugetlb_lock = SPIN_LOCK_UNLOCKED;
+static void register_huge_page(struct page *page)
+{
+ list_add(&page[1].lru,
+ &hugepage_alllists[page_zone(page)->zone_pgdat->node_id]);
+}
+
+static void unregister_huge_page(struct page *page)
+{
+ list_del(&page[1].lru);
+}
+
static void enqueue_huge_page(struct page *page)
{
list_add(&page->lru,
@@ -90,14 +102,17 @@ static int __init hugetlb_init(void)
unsigned long i;
struct page *page;
- for (i = 0; i < MAX_NUMNODES; ++i)
+ for (i = 0; i < MAX_NUMNODES; ++i) {
INIT_LIST_HEAD(&hugepage_freelists[i]);
+ INIT_LIST_HEAD(&hugepage_alllists[i]);
+ }
for (i = 0; i < max_huge_pages; ++i) {
page = alloc_fresh_huge_page();
if (!page)
break;
spin_lock(&hugetlb_lock);
+ register_huge_page(page);
enqueue_huge_page(page);
spin_unlock(&hugetlb_lock);
}
@@ -139,6 +154,7 @@ static int try_to_free_low(unsigned long
if (PageHighMem(page))
continue;
list_del(&page->lru);
+ unregister_huge_page(page);
update_and_free_page(page);
--free_huge_pages;
if (!--count)
@@ -161,6 +177,7 @@ static unsigned long set_max_huge_pages(
if (!page)
return nr_huge_pages;
spin_lock(&hugetlb_lock);
+ register_huge_page(page);
enqueue_huge_page(page);
free_huge_pages++;
nr_huge_pages++;
@@ -174,6 +191,7 @@ static unsigned long set_max_huge_pages(
struct page *page = dequeue_huge_page();
if (!page)
break;
+ unregister_huge_page(page);
update_and_free_page(page);
}
spin_unlock(&hugetlb_lock);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/