Skip to contentSkip to conversation

Balance Freeing of Huge Pages across Nodes

PATCH In review Lee Schermerhorn 2 participants 4 messages Jun 26, 2009 – Jun 29, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Balance Freeing of Huge Pages across Nodes

[PATCH] 0/1 Free huge pages round robin to balance across nodes

I posted an earlier version of the patch following this message as part of a larger series. I think this patch might be ready for a ride in mmotm, so I'm sending it out separately. I'll base subsequent "huge pages controls" series atop this patch.

Mel Gorman agreed, in principle, that this patch was needed independent from the huge pages controls. However, he suggested some cleanup, which this version addresses [and then some], and he did not ACK the previous version.

David Rientjes did ACK the previous version, but because this version includes a fair amount of additional mods to adjust_pool_surplus(), I did not include his ACK.

Lee

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

PATCH 1/1 Balance Freeing of Huge Pages across Nodes

[PATCH] 1/1 Balance Freeing of Huge Pages across Nodes

Against: 12jun09 mmotm

[applies to 25jun09 mmotm as well]

Free huges pages from nodes in round robin fashion in an attempt to keep [persistent a.k.a static] hugepages balanced across nodes

New function free_pool_huge_page() is modeled on and performs roughly the inverse of alloc_fresh_huge_page(). Replaces dequeue_huge_page() which now has no callers, so this patch removes it.

Helper function hstate_next_node_to_free() uses new hstate member next_to_free_nid to distribute "frees" across all nodes with huge pages.

V2:

At Mel Gorman's suggestion: renamed hstate_next_node() to hstate_next_node_to_alloc() for symmetry. Also, renamed hstate member hugetlb_next_node to next_node_to_free. ["hugetlb" is implicit in the hstate struct, I think].

New in this version:

Modified adjust_pool_surplus() to use hstate_next_node_to_alloc() and hstate_next_node_to_free() to advance node id for adjusting surplus huge page count, as this is equivalent to allocating and freeing persistent huge pages. [Can't blame Mel for this part.]

 include/linux/hugetlb.h |    3 -
 mm/hugetlb.c            |  132 +++++++++++++++++++++++++++++++-----------------
 2 files changed, 88 insertions(+), 47 deletions(-)
include/linux/hugetlb.h +2 -1
Index: linux-2.6.30-mmotm-090612-1220/include/linux/hugetlb.h
===================================================================
@@ -183,7 +183,8 @@ unsigned long hugetlb_get_unmapped_area(
 #define HSTATE_NAME_LEN 32
 /* Defines one hugetlb page size */
 struct hstate {
-	int hugetlb_next_nid;
+	int next_nid_to_alloc;
+	int next_nid_to_free;
 	unsigned int order;
 	unsigned long mask;
 	unsigned long max_huge_pages;
mm/hugetlb.c +86 -46

212 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#2 lore raw
Quoted 26 lines · Lee Schermerhorn

[PATCH] 1/1 Balance Freeing of Huge Pages across Nodes

Against: 12jun09 mmotm

[applies to 25jun09 mmotm as well]

Free huges pages from nodes in round robin fashion in an attempt to keep [persistent a.k.a static] hugepages balanced across nodes

New function free_pool_huge_page() is modeled on and performs roughly the inverse of alloc_fresh_huge_page(). Replaces dequeue_huge_page() which now has no callers, so this patch removes it.

Helper function hstate_next_node_to_free() uses new hstate member next_to_free_nid to distribute "frees" across all nodes with huge pages.

V2:

At Mel Gorman's suggestion: renamed hstate_next_node() to hstate_next_node_to_alloc() for symmetry. Also, renamed hstate member hugetlb_next_node to next_node_to_free. ["hugetlb" is implicit in the hstate struct, I think].

Quoted 8 lines

New in this version:

Modified adjust_pool_surplus() to use hstate_next_node_to_alloc() and hstate_next_node_to_free() to advance node id for adjusting surplus huge page count, as this is equivalent to allocating and freeing persistent huge pages. [Can't blame Mel for this part.]

Very useful change!

Quoted 10 lines
mm/hugetlb.c +2 -2
@@ -666,14 +648,15 @@ static int alloc_fresh_huge_page(struct 
 	int next_nid;
 	int ret = 0;
 
-	start_nid = h->hugetlb_next_nid;
+	start_nid = h->next_nid_to_alloc;
+	next_nid = start_nid;
 
 	do {
-		page = alloc_fresh_huge_page_node(h, h->hugetlb_next_nid);

mm/hugetlb.c static int alloc_fresh_huge_page(struct · line 662

Quoted 10 lines
mm/hugetlb.c +3 -2
+		page = alloc_fresh_huge_page_node(h, next_nid);
 		if (page)
 			ret = 1;
-		next_nid = hstate_next_node(h);
-	} while (!page && h->hugetlb_next_nid != start_nid);
+		next_nid = hstate_next_node_to_alloc(h);
+	} while (!page && next_nid != start_nid);
 
 	if (ret)
 		count_vm_event(HTLB_BUDDY_PGALLOC);

This actually puts the currently unused next_nid to use, nice.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
Quoted 35 lines · David Rientjes
Quoted 33 lines · Lee Schermerhorn

[PATCH] 1/1 Balance Freeing of Huge Pages across Nodes

Against: 12jun09 mmotm

[applies to 25jun09 mmotm as well]

Free huges pages from nodes in round robin fashion in an attempt to keep [persistent a.k.a static] hugepages balanced across nodes

New function free_pool_huge_page() is modeled on and performs roughly the inverse of alloc_fresh_huge_page(). Replaces dequeue_huge_page() which now has no callers, so this patch removes it.

Helper function hstate_next_node_to_free() uses new hstate member next_to_free_nid to distribute "frees" across all nodes with huge pages.

V2:

At Mel Gorman's suggestion: renamed hstate_next_node() to hstate_next_node_to_alloc() for symmetry. Also, renamed hstate member hugetlb_next_node to next_node_to_free. ["hugetlb" is implicit in the hstate struct, I think].

New in this version:

Modified adjust_pool_surplus() to use hstate_next_node_to_alloc() and hstate_next_node_to_free() to advance node id for adjusting surplus huge page count, as this is equivalent to allocating and freeing persistent huge pages. [Can't blame Mel for this part.]

Quoted 5 lines
Quoted 1 line

Very useful change!

Thanks, David.

Unfortunately, as I've been working on the next set of changes [mempolicy-based and per node controls], I noticed that I should probably fix up return_unused_surplus_pages(), as well. So, I'll send out v3 of this patch, maybe with a Documentation update, real soon, I hope.

Lee

Quoted 24 lines
Quoted 11 lines
mm/hugetlb.c +2 -2
@@ -666,14 +648,15 @@ static int alloc_fresh_huge_page(struct 
 	int next_nid;
 	int ret = 0;
 
-	start_nid = h->hugetlb_next_nid;
+	start_nid = h->next_nid_to_alloc;
+	next_nid = start_nid;
 
 	do {
-		page = alloc_fresh_huge_page_node(h, h->hugetlb_next_nid);

mm/hugetlb.c static int alloc_fresh_huge_page(struct · line 662

Quoted 10 lines
mm/hugetlb.c +3 -2
+		page = alloc_fresh_huge_page_node(h, next_nid);
 		if (page)
 			ret = 1;
-		next_nid = hstate_next_node(h);
-	} while (!page && h->hugetlb_next_nid != start_nid);
+		next_nid = hstate_next_node_to_alloc(h);
+	} while (!page && next_nid != start_nid);
 
 	if (ret)
 		count_vm_event(HTLB_BUDDY_PGALLOC);

This actually puts the currently unused next_nid to use, nice.

Quoted 5 lines

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>