hugetlb: V1 Per Node Hugepages attributes
Subsystems (3)
cover hugetlb: V1 Per Node Hugepages attributes
PATCH/RFC 0/4 V1 Add Per Node Hugepages Attributes
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously posted alloc_bootmem_hugepages fix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]
This is V1 of a third alternative for controlling allocation of persistent huge pages on a NUMA system. [Prior alternatives were separate "hugepages_nodes_allowed" mask and mempolicy-based mask.] This series implements a per node, per huge pages size, read/write attribute--nr_hugepages--to query and modify the persistent huge pages on a specific node. The series also implements read only attributes to query free_huge_pages and surplus_free_pages.
This implementation continues to pass the libhugetlbfs functional test suite.
Some issues/limitations with this series:
1) The series includes a rework/cleanup patch from the "mempolicy- based" huge pages series. I think this rework is worth doing which ever method we chose for controlling per node huge pages.
2) The series extends the struct kobject with a private bit field to aid the correlation of kobjects with the global or per node hstate attributes. This is not absolutely required, but did simplify the back mapping of kobjects to subsystem objects.
3) The reserved and overcommit counts remain global. This seems to be the most straightforward usage, even in the context of per node persistent huge page attributes. Global reserve and overcommit values allow mempolicy to be applied to the huge page allocation to satisfy a page fault. [Some work appears to be needed in the per cpuset overcommit limit and reserve accounting, but outside of the scope of this series.]
4) This series does not implement a boot command line parameter to control per node allocations. This could be added if needed.
5) Using this method--per node attributes--to control persistent huge page allocation will require enhancments to hugeadm, including a new command line syntax for specifying specific nodes if we wish to avoid direct accessing of the attributes.
6) I have yet to update the hugetlbfs doc for this alternative.
--
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>
PATCH 1/4 hugetlb: rework hstate_next_node_* functions
PATCH/RFC 1/4 hugetlb: rework hstate_next_node* functions
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously posted alloc_bootmem_hugepages fix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]
[From V3 of the mempolicy-based huge pages allocation series]
Modify the hstate_next_node* functions to allow them to be called to obtain the "start_nid". Then, whereas prior to this patch we unconditionally called hstate_next_node_to_{alloc|free}(), whether or not we successfully allocated/freed a huge page on the node, now we only call these functions on failure to alloc/free.
Factor out the next_node_allowed() function to handle wrap at end of node_online_map. In this version, the allowed nodes are all of the online nodes.
mm/hugetlb.c | 70 +++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 25 deletions(-)
mm/hugetlb.c +45 -25
@@ -622,6 +622,20 @@ static struct page *alloc_fresh_huge_pag }/* +* common helper function for hstate_next_node_to_{alloc|free}. +* return next node in node_online_map, wrapping at end. +*/ +static int next_node_allowed (int nid) +{ + nid =next_node (nid, node_online_map); +if (nid ==MAX_NUMNODES ) + nid =first_node (node_online_map); +VM_BUG_ON (nid >=MAX_NUMNODES ); + +return nid; +} + +/* * Use a helper variable to find the next node and then * copy it back to next_nid_to_alloc afterwards: * otherwise there's a window in which a racer might
@@ -634,12 +648,12 @@ static struct page *alloc_fresh_huge_pag*/ static int hstate_next_node_to_alloc (struct hstate *h) { -int next_nid; - next_nid =next_node (h->next_nid_to_alloc, node_online_map); -if (next_nid ==MAX_NUMNODES ) - next_nid =first_node (node_online_map); +int nid, next_nid; + + nid = h->next_nid_to_alloc; + next_nid =next_node_allowed (nid); h->next_nid_to_alloc = next_nid; -return next_nid; +return nid; }static int alloc_fresh_huge_page (struct hstate *h)
@@ -649,15 +663,17 @@ static int alloc_fresh_huge_page(structint next_nid;int ret =0 ; - start_nid = h->next_nid_to_alloc; + start_nid =hstate_next_node_to_alloc (h); next_nid = start_nid;do { page =alloc_fresh_huge_page_node (h, next_nid); -if (page) +if (page) { ret =1 ; +break ; + } next_nid =hstate_next_node_to_alloc (h); - }while (!page && next_nid != start_nid); + }while (next_nid != start_nid);if (ret)count_vm_event (HTLB_BUDDY_PGALLOC );
@@ -668,17 +684,19 @@ static int alloc_fresh_huge_page(struct }/* -* helper for free_pool_huge_page() - find next node -* from which to free a huge page +* helper for free_pool_huge_page() - return the next node +* from which to free a huge page. Advance the next node id +* whether or not we find a free huge page to free so that the +* next attempt to free addresses the next node. */ static int hstate_next_node_to_free (struct hstate *h) { -int next_nid; - next_nid =next_node (h->next_nid_to_free, node_online_map); -if (next_nid ==MAX_NUMNODES ) - next_nid =first_node (node_online_map); +int nid, next_nid; + + nid = h->next_nid_to_free; + next_nid =next_node_allowed (nid); h->next_nid_to_free = next_nid; -return next_nid; +return nid; }/*
@@ -693,7 +711,7 @@ static int free_pool_huge_page(struct hsint next_nid;int ret =0 ; - start_nid = h->next_nid_to_free; + start_nid =hstate_next_node_to_free (h); next_nid = start_nid; do {
@@ -715,9 +733,10 @@ static int free_pool_huge_page(struct hs }update_and_free_page (h, page); ret =1 ; +break ; } next_nid =hstate_next_node_to_free (h); - }while (!ret && next_nid != start_nid); + }while (next_nid != start_nid);return ret; }
@@ -1028,10 +1047,9 @@ int __weak alloc_bootmem_huge_page(strucvoid *addr; addr =__alloc_bootmem_node_nopanic ( -NODE_DATA (h->next_nid_to_alloc), +NODE_DATA (hstate_next_node_to_alloc (h)),huge_page_size (h),huge_page_size (h),0 ); -hstate_next_node_to_alloc (h);if (addr) {/* * Use the beginning of the huge page to store the
@@ -1167,29 +1185,31 @@ static int adjust_pool_surplus(struct hsVM_BUG_ON (delta !=-1 && delta !=1 );if (delta <0 ) - start_nid = h->next_nid_to_alloc; + start_nid =hstate_next_node_to_alloc (h);else - start_nid = h->next_nid_to_free; + start_nid =hstate_next_node_to_free (h); next_nid = start_nid; do { int nid = next_nid; if (delta < 0) { - next_nid = hstate_next_node_to_alloc(h); /* * To shrink on this node, there must be a surplus page */ - if (!h->surplus_huge_pages_node[nid]) + if (!h->surplus_huge_pages_node[nid]) { + next_nid = hstate_next_node_to_alloc(h); continue; + } } if (delta > 0) { - next_nid = hstate_next_node_to_free(h); /* * Surplus cannot exceed the total number of pages */ if (h->surplus_huge_pages_node[nid] >= - h->nr_huge_pages_node[nid]) + h->nr_huge_pages_node[nid]) { + next_nid = hstate_next_node_to_free(h); continue; + } } h->surplus_huge_pages += delta;
--
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>
PATCH 2/4 hugetlb: numafy several functions
In reply to Lee SchermerhornPATCH/RFC 2/4 hugetlb: numafy several functions
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously posted alloc_bootmem_hugepages fix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]
Based on a patch by Nishanth Aravamudan <[email protected]>, circa april2008.
Factor out functions to dequeue and free huge pages and/or adjust surplus huge page count for a specific node in support of subsequent patch to alloc or free huge pages on a specified node.
--- mm/hugetlb.c | 126 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 54 deletions(-)
mm/hugetlb.c +72 -54
@@ -456,6 +456,17 @@ static void enqueue_huge_page(struct hst h->free_huge_pages_node[nid]++; } +static struct page *hstate_dequeue_huge_page_node (struct hstate *h,int nid) +{ +struct page *page; + + page = list_entry(h->hugepage_freelists[nid].next, struct page, lru); +list_del (&page->lru); + h->free_huge_pages--; + h->free_huge_pages_node[nid]--; +return page; +} +static struct page *dequeue_huge_page_vma (struct hstate *h,struct vm_area_struct *vma,unsigned long address,int avoid_reserve)
@@ -487,11 +498,7 @@ static struct page *dequeue_huge_page_vm nid =zone_to_nid (zone);if (cpuset_zone_allowed_softwall (zone, htlb_alloc_mask) && !list_empty (&h->hugepage_freelists[nid])) { - page =list_entry (h->hugepage_freelists[nid].next, - struct page, lru); -list_del (&page->lru); - h->free_huge_pages--; - h->free_huge_pages_node[nid]--; + page =hstate_dequeue_huge_page_node (h, nid);if (!avoid_reserve)decrement_hugepage_resv_vma (h, vma);
@@ -599,12 +606,12 @@ int PageHuge(struct page *page)return dtor == free_huge_page; } -static struct page *alloc_fresh_huge_page_node (struct hstate *h,int nid) +static int alloc_fresh_huge_page_node (struct hstate *h,int nid) {struct page *page;if (h->order >=MAX_ORDER ) -return NULL ; +return 0 ; page = alloc_pages_exact_node(nid, htlb_alloc_mask|__GFP_COMP|__GFP_THISNODE|
@@ -613,12 +620,12 @@ static struct page *alloc_fresh_huge_pagif (page) {if (arch_prepare_hugepage (page)) {__free_pages (page,huge_page_order (h)); -return NULL ; +return 0 ; }prep_new_huge_page (h, page, nid); } -return page; +return 1 ; }/*
@@ -658,7 +665,6 @@ static int hstate_next_node_to_alloc(strstatic int alloc_fresh_huge_page (struct hstate *h) { -struct page *page;int start_nid;int next_nid;int ret =0 ;
@@ -667,11 +673,9 @@ static int alloc_fresh_huge_page(struct next_nid = start_nid;do { - page =alloc_fresh_huge_page_node (h, next_nid); -if (page) { - ret =1 ; + ret =alloc_fresh_huge_page_node (h, next_nid); +if (ret)break ; - } next_nid =hstate_next_node_to_alloc (h); }while (next_nid != start_nid);
@@ -699,6 +703,23 @@ static int hstate_next_node_to_free(strureturn nid; } +static int hstate_free_huge_page_node (struct hstate *h,bool acct_surplus, +int nid) +{ +struct page *page; + +if (list_empty (&h->hugepage_freelists[nid])) +return 0 ; + + page =hstate_dequeue_huge_page_node (h, nid); +if (acct_surplus) { + h->surplus_huge_pages--; + h->surplus_huge_pages_node[nid]--; + } +update_and_free_page (h, page); +return 1 ; +} +/* * Free huge page from pool from next node to free. * Attempt to keep persistent huge pages more or less
@@ -719,21 +740,11 @@ static int free_pool_huge_page(struct hs* If we're returning unused surplus pages, only examine * nodes with surplus pages. */ -if ((!acct_surplus || h->surplus_huge_pages_node[next_nid]) && - !list_empty (&h->hugepage_freelists[next_nid])) { -struct page *page = -list_entry (h->hugepage_freelists[next_nid].next, - struct page, lru); -list_del (&page->lru); - h->free_huge_pages--; - h->free_huge_pages_node[next_nid]--; -if (acct_surplus) { - h->surplus_huge_pages--; - h->surplus_huge_pages_node[next_nid]--; - } -update_and_free_page (h, page); - ret =1 ; -break ; +if ((!acct_surplus || h->surplus_huge_pages_node[next_nid])) { + ret =hstate_free_huge_page_node (h, acct_surplus, + next_nid); +if (ret) +break ; } next_nid =hstate_next_node_to_free (h); }while (next_nid != start_nid);
@@ -1173,6 +1184,31 @@ static inline void try_to_free_low(struc#endif /* +* Increment or decrement surplus_huge_pages for a specified node, +* if conditions permit. Note that decrementing the surplus huge +* page count effective promotes a page to persistent, while +* incrementing the surplus count demotes a page to surplus. +*/ +static int adjust_pool_surplus_node (struct hstate *h,int delta,int nid) +{ +int ret =0 ; + +/* +* To shrink on this node, there must be a surplus page. +* Surplus cannot exceed the total number of pages. +*/ +if ((delta <0 && h->surplus_huge_pages_node[nid]) || + (delta >0 && h->surplus_huge_pages_node[nid] < + h->nr_huge_pages_node[nid])) { + + h->surplus_huge_pages += delta; + h->surplus_huge_pages_node[nid] += delta; + ret =1 ; + } +return ret; +} + +/* * Increment or decrement surplus_huge_pages. Keep node-specific counters * balanced by operating on them in a round-robin fashion. * Returns 1 if an adjustment was made.
@@ -1191,31 +1227,13 @@ static int adjust_pool_surplus(struct hs next_nid = start_nid;do { -int nid = next_nid; -if (delta <0 ) { -/* -* To shrink on this node, there must be a surplus page -*/ -if (!h->surplus_huge_pages_node[nid]) { - next_nid =hstate_next_node_to_alloc (h); -continue ; - } - } -if (delta >0 ) { -/* -* Surplus cannot exceed the total number of pages -*/ -if (h->surplus_huge_pages_node[nid] >= - h->nr_huge_pages_node[nid]) { - next_nid =hstate_next_node_to_free (h); -continue ; - } - } - - h->surplus_huge_pages += delta; - h->surplus_huge_pages_node[nid] += delta; - ret =1 ; -break ; + ret =adjust_pool_surplus_node (h, delta, next_nid); +if (ret) +break ; +if (delta <0 ) + next_nid =hstate_next_node_to_alloc (h); +else + next_nid =hstate_next_node_to_free (h); }while (next_nid != start_nid);return ret;
--
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>
PATCH 3/4 hugetlb: add private bit-field to kobject structure
In reply to Lee SchermerhornPATCH/RFC 3/4 hugetlb: add private bitfield to struct kobject
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously posted alloc_bootmem_hugepages fix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]
For the per node huge page attributes, we want to share as much code as possible with the global huge page attributes, including the show/store functions. To do this, we'll need a way to back translate from the kobj argument to the show/store function to the node id, when entered via that path. This patch adds a subsystem/sysdev private bitfield to the kobject structure. The bitfield uses unused bits in the same unsigned int as the various kobject flags so as not to increase the size of the structure.
Currently, the bit field is the minimum required for the huge pages per node attributes [plus one extra bit]. The field could be expanded for other usage, should such arise.
Note that this is not absolutely required. However, using this private field eliminates an inner loop to scan the per node hstate kobjects and eliminates scanning entirely for the global hstate kobjects.
--- include/linux/kobject.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/kobject.h +3 -0
@@ -56,6 +56,8 @@ enum kobject_action {KOBJ_MAX }; +#define KOBJ_PRIVATE_BITS 3/* subsystem/sysdev private */ +struct kobject {const char *name;struct list_head entry;
@@ -69,6 +71,7 @@ struct kobject { unsigned int state_add_uevent_sent:1; unsigned int state_remove_uevent_sent:1; unsigned int uevent_suppress:1; + unsigned int private:KOBJ_PRIVATE_BITS; };extern int kobject_set_name (struct kobject *kobj,const char *name, ...)
--
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>
Re: [PATCH 3/4] hugetlb: add private bit-field to kobject structure
Quoted 16 lines · Lee Schermerhorn
PATCH/RFC 3/4 hugetlb: add private bitfield to struct kobject
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously postedalloc_bootmem_hugepagesfix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]For the per node huge page attributes, we want to share as much code as possible with the global huge page attributes, including the show/store functions. To do this, we'll need a way to back translate from the kobj argument to the show/store function to the node id, when entered via that path. This patch adds a subsystem/sysdev private bitfield to the kobject structure. The bitfield uses unused bits in the same unsigned int as the various kobject flags so as not to increase the size of the structure.
Quoted 8 lines
Currently, the bit field is the minimum required for the huge pages per node attributes [plus one extra bit]. The field could be expanded for other usage, should such arise.
Note that this is not absolutely required. However, using this private field eliminates an inner loop to scan the per node hstate kobjects and eliminates scanning entirely for the global hstate kobjects.
Ick, no, please don't do that. That's what the structure you use to contain your kobject should be for, right?
Or are you for some reason using "raw" kobjects?
thanks,
greg k-h
--
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>
Re: [PATCH 3/4] hugetlb: add private bit-field to kobject structure
Quoted 26 lines · Greg KH
Quoted 16 lines · Lee Schermerhorn
PATCH/RFC 3/4 hugetlb: add private bitfield to struct kobject
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously postedalloc_bootmem_hugepagesfix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]For the per node huge page attributes, we want to share as much code as possible with the global huge page attributes, including the show/store functions. To do this, we'll need a way to back translate from the kobj argument to the show/store function to the node id, when entered via that path. This patch adds a subsystem/sysdev private bitfield to the kobject structure. The bitfield uses unused bits in the same unsigned int as the various kobject flags so as not to increase the size of the structure.
Quoted 8 lines
Currently, the bit field is the minimum required for the huge pages per node attributes [plus one extra bit]. The field could be expanded for other usage, should such arise.
Note that this is not absolutely required. However, using this private field eliminates an inner loop to scan the per node hstate kobjects and eliminates scanning entirely for the global hstate kobjects.
Quoted 4 lines
Ick, no, please don't do that. That's what the structure you use to contain your kobject should be for, right?
Or are you for some reason using "raw" kobjects?
OK, reworked to remove the private bit field from kobject. This replaces patches 3 and 4 of 4 in case anyone wants to test the series w/o the change to the kobject structure. I'll be sending out another version of this patch in response to a thread with David and Mel shortly.
Lee
---
PATCH/RFC 3/3 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously posted alloc_bootmem_hugepages fix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]
V2: remove dependency on kobject private bitfield. Search
global hstates then all per node hstates for kobject match in attribute show/store functions.
This patch adds the per huge page size control/query attributes to the per node sysdevs:
/sys/devices/system/node/node<ID>/hugepages/hugepages-<size>/
nr_hugepages - r/w
free_huge_pages - r/o
surplus_huge_pages - r/o
The patch attempts to re-use/share as much of the existing global hstate attribute initialization and handling as possible. Throughout, a node id < 0 indicates global hstate parameters.
Note: computation of "min_count" in set_max_huge_pages() for a specified node needs careful review.
Issue: dependency of base driver [node] dependency on hugetlbfs module. We want to keep all of the hstate attribute registration and handling in the hugetlb module. However, we need to call into this code to register the per node hstate attributes on node hot plug.
With this patch:
(me):ls /sys/devices/system/node/node0/hugepages/hugepages-2048kB ./ ../ free_hugepages nr_hugepages surplus_hugepages
Starting from:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 0 Node 2 HugePages_Free: 0 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
vm.nr_hugepages = 0
Allocate 16 persistent huge pages on node 2:
(me):echo 16 >/sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages
Yields:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 16 Node 2 HugePages_Free: 16 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
vm.nr_hugepages = 16
Global controls work as expected--reduce pool to 8 persistent huge pages:
(me):echo 8 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 8 Node 2 HugePages_Free: 8 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
drivers/base/node.c | 2 include/linux/hugetlb.h | 6 + include/linux/node.h | 3 mm/hugetlb.c | 274 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 243 insertions(+), 42 deletions(-)
drivers/base/node.c +2 -0
@@ -200,6 +200,7 @@ int register_node(struct node *node, intsysdev_create_file (&node->sysdev, &attr_distance);scan_unevictable_register_node (node); +hugetlb_register_node (node); }return error; }
@@ -220,6 +221,7 @@ void unregister_node(struct node *node)sysdev_remove_file (&node->sysdev, &attr_distance);scan_unevictable_unregister_node (node); +hugetlb_unregister_node (node);sysdev_unregister (&node->sysdev); }
include/linux/hugetlb.h +6 -0
@@ -278,6 +278,10 @@ static inline struct hstate *page_hstate return size_to_hstate(PAGE_SIZE << compound_order(page)); } +struct node ; +extern void hugetlb_register_node (struct node *); +extern void hugetlb_unregister_node (struct node *); +#else struct hstate {};#define alloc_bootmem_huge_page (h) NULL
@@ -294,6 +298,8 @@ static inline unsigned int pages_per_hug {return 1 ; } +#define hugetlb_register_node (NP ) +#define hugetlb_unregister_node (NP )#endif #endif /* _LINUX_HUGETLB_H */
mm/hugetlb.c +232 -42
426 lines not on this page · raw message
include/linux/node.h +3 -0
@@ -21,9 +21,12 @@#include <linux/sysdev.h> #include <linux/cpumask.h> +#include <linux/hugetlb.h> struct node {struct sys_device sysdev; +struct kobject *hugepages_kobj; +struct kobject *hstate_kobjs[HUGE_MAX_HSTATE ]; };struct memory_block ;
PATCH 4/4 hugetlb: add per node hstate attributes
In reply to Lee SchermerhornPATCH/RFC 4/4 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously posted alloc_bootmem_hugepages fix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]
This patch adds the per huge page size control/query attributes to the per node sysdevs:
/sys/devices/system/node/node<ID>/hugepages/hugepages-<size>/
nr_hugepages - r/w
free_huge_pages - r/o
surplus_huge_pages - r/o
The patch attempts to re-use/share as much of the existing global hstate attribute initialization and handling as possible. Throughout, a node id < 0 indicates global hstate parameters.
Note: computation of "min_count" in set_max_huge_pages() for a specified node needs careful review.
Issue: dependency of base driver [node] dependency on hugetlbfs module. We want to keep all of the hstate attribute registration and handling in the hugetlb module. However, we need to call into this code to register the per node hstate attributes on node hot plug.
With this patch:
(me):ls /sys/devices/system/node/node0/hugepages/hugepages-2048kB ./ ../ free_hugepages nr_hugepages surplus_hugepages
Starting from:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 0 Node 2 HugePages_Free: 0 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
vm.nr_hugepages = 0
Allocate 16 persistent huge pages on node 2:
(me):echo 16 >/sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages
Yields:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 16 Node 2 HugePages_Free: 16 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
vm.nr_hugepages = 16
Global controls work as expected--reduce pool to 8 persistent huge pages:
(me):echo 8 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 8 Node 2 HugePages_Free: 8 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
--- drivers/base/node.c | 2 include/linux/hugetlb.h | 6 + include/linux/node.h | 2 mm/hugetlb.c | 266 +++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 239 insertions(+), 37 deletions(-)
drivers/base/node.c +2 -0
@@ -200,6 +200,7 @@ int register_node(struct node *node, intsysdev_create_file (&node->sysdev, &attr_distance);scan_unevictable_register_node (node); +hugetlb_register_node (node); }return error; }
@@ -220,6 +221,7 @@ void unregister_node(struct node *node)sysdev_remove_file (&node->sysdev, &attr_distance);scan_unevictable_unregister_node (node); +hugetlb_unregister_node (node);sysdev_unregister (&node->sysdev); }
include/linux/hugetlb.h +6 -0
@@ -278,6 +278,10 @@ static inline struct hstate *page_hstate return size_to_hstate(PAGE_SIZE << compound_order(page)); } +struct node ; +extern void hugetlb_register_node (struct node *); +extern void hugetlb_unregister_node (struct node *); +#else struct hstate {};#define alloc_bootmem_huge_page (h) NULL
@@ -294,6 +298,8 @@ static inline unsigned int pages_per_hug {return 1 ; } +#define hugetlb_register_node (NP ) +#define hugetlb_unregister_node (NP )#endif #endif /* _LINUX_HUGETLB_H */
mm/hugetlb.c +229 -37
411 lines not on this page · raw message
include/linux/node.h +2 -0
@@ -24,6 +24,8 @@struct node {struct sys_device sysdev; +struct kobject *hugepages_kobj; +struct kobject *hstate_kobjs[HUGE_MAX_HSTATE ]; };struct memory_block ;
--
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>
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 84 lines · Lee Schermerhorn
PATCH/RFC 4/4 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously postedalloc_bootmem_hugepagesfix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]This patch adds the per huge page size control/query attributes to the per node sysdevs:
/sys/devices/system/node/node<ID>/hugepages/hugepages-<size>/
nr_hugepages- r/w
free_huge_pages - r/o
surplus_huge_pages - r/oThe patch attempts to re-use/share as much of the existing global hstate attribute initialization and handling as possible. Throughout, a node id < 0 indicates global hstate parameters.
Note: computation of "
min_count" inset_max_huge_pages()for a specified node needs careful review.Issue: dependency of base driver [node] dependency on hugetlbfs module. We want to keep all of the hstate attribute registration and handling in the hugetlb module. However, we need to call into this code to register the per node hstate attributes on node hot plug.
With this patch:
(me):ls
/sys/devices/system/node/node0/hugepages/hugepages-2048kB./ ../ free_hugepages nr_hugepages surplus_hugepagesStarting from:
Node 0HugePages_Total: 0
Node 0HugePages_Free: 0
Node 0HugePages_Surp: 0
Node 1HugePages_Total: 0
Node 1HugePages_Free: 0
Node 1HugePages_Surp: 0
Node 2HugePages_Total: 0
Node 2HugePages_Free: 0
Node 2HugePages_Surp: 0
Node 3HugePages_Total: 0
Node 3HugePages_Free: 0
Node 3HugePages_Surp: 0
vm.nr_hugepages = 0Allocate 16 persistent huge pages on node 2:
(me):echo 16 >/sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepagesYields:
Node 0HugePages_Total: 0
Node 0HugePages_Free: 0
Node 0HugePages_Surp: 0
Node 1HugePages_Total: 0
Node 1HugePages_Free: 0
Node 1HugePages_Surp: 0
Node 2HugePages_Total: 16
Node 2HugePages_Free: 16
Node 2HugePages_Surp: 0
Node 3HugePages_Total: 0
Node 3HugePages_Free: 0
Node 3HugePages_Surp: 0
vm.nr_hugepages = 16Global controls work as expected--reduce pool to 8 persistent huge pages:
(me):echo 8 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepagesNode 0
HugePages_Total: 0
Node 0HugePages_Free: 0
Node 0HugePages_Surp: 0
Node 1HugePages_Total: 0
Node 1HugePages_Free: 0
Node 1HugePages_Surp: 0
Node 2HugePages_Total: 8
Node 2HugePages_Free: 8
Node 2HugePages_Surp: 0
Node 3HugePages_Total: 0
Node 3HugePages_Free: 0
Node 3HugePages_Surp: 0
Quoted 2 lines
Signed-off-by Lee Schermerhorn <[email protected]>
Thank you very much for doing this.
Google is going to need this support regardless of what finally gets merged into mainline, so I'm thrilled you've implemented this version.
I hugely (get it? hugely :) favor this approach because it's much simpler to reserve hugepages from this interface than a mempolicy based approach once hugepages have already been allocated before. For cpusets users in particular, jobs typically get allocated on a subset of nodes that are required for that application and they don't last for the duration of the machine's uptime. When a job exits and the nodes need to be reallocated to a new cpuset, it may be a very different set of mems based on the memory requirements or interleave optimizations for the new job. Allocating resources such as hugepages are possible in this scenario via mempolicies, but it would require a temporary mempolicy to then allocate additional hugepages from which seems like an unnecessary requirement, especially if the job scheduler that is governing hugepage allocations already has a mempolicy of its own.
So it's my opinion that the mempolicy based approach is very appropriate for tasks that allocate hugepages itself. Other users, particularly cpusets users, however, would require preallocation of hugepages prior to a job being scheduled in which case a temporary mempolicy would be required for that job scheduler. That seems like an inconvenience when the entire state of the system's hugepages could easily be governed with the per-node hstate attributes and a slightly modified user library.
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 86 lines · David Rientjes
Quoted 84 lines · Lee Schermerhorn
PATCH/RFC 4/4 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously postedalloc_bootmem_hugepagesfix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]This patch adds the per huge page size control/query attributes to the per node sysdevs:
/sys/devices/system/node/node<ID>/hugepages/hugepages-<size>/
nr_hugepages- r/w
free_huge_pages - r/o
surplus_huge_pages - r/oThe patch attempts to re-use/share as much of the existing global hstate attribute initialization and handling as possible. Throughout, a node id < 0 indicates global hstate parameters.
Note: computation of "
min_count" inset_max_huge_pages()for a specified node needs careful review.Issue: dependency of base driver [node] dependency on hugetlbfs module. We want to keep all of the hstate attribute registration and handling in the hugetlb module. However, we need to call into this code to register the per node hstate attributes on node hot plug.
With this patch:
(me):ls
/sys/devices/system/node/node0/hugepages/hugepages-2048kB./ ../ free_hugepages nr_hugepages surplus_hugepagesStarting from:
Node 0HugePages_Total: 0
Node 0HugePages_Free: 0
Node 0HugePages_Surp: 0
Node 1HugePages_Total: 0
Node 1HugePages_Free: 0
Node 1HugePages_Surp: 0
Node 2HugePages_Total: 0
Node 2HugePages_Free: 0
Node 2HugePages_Surp: 0
Node 3HugePages_Total: 0
Node 3HugePages_Free: 0
Node 3HugePages_Surp: 0
vm.nr_hugepages = 0Allocate 16 persistent huge pages on node 2:
(me):echo 16 >/sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepagesYields:
Node 0HugePages_Total: 0
Node 0HugePages_Free: 0
Node 0HugePages_Surp: 0
Node 1HugePages_Total: 0
Node 1HugePages_Free: 0
Node 1HugePages_Surp: 0
Node 2HugePages_Total: 16
Node 2HugePages_Free: 16
Node 2HugePages_Surp: 0
Node 3HugePages_Total: 0
Node 3HugePages_Free: 0
Node 3HugePages_Surp: 0
vm.nr_hugepages = 16Global controls work as expected--reduce pool to 8 persistent huge pages:
(me):echo 8 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepagesNode 0
HugePages_Total: 0
Node 0HugePages_Free: 0
Node 0HugePages_Surp: 0
Node 1HugePages_Total: 0
Node 1HugePages_Free: 0
Node 1HugePages_Surp: 0
Node 2HugePages_Total: 8
Node 2HugePages_Free: 8
Node 2HugePages_Surp: 0
Node 3HugePages_Total: 0
Node 3HugePages_Free: 0
Node 3HugePages_Surp: 0
Quoted 8 lines
Quoted 2 lines
Signed-off-by Lee Schermerhorn <[email protected]>Thank you very much for doing this.
Google is going to need this support regardless of what finally gets merged into mainline, so I'm thrilled you've implemented this version.
The fact that there is a definite use case in mind lends weight to this approach but I want to be 100% sure that a hugetlbfs-specific interface is required in this case.
Quoted 6 lines
I hugely (get it? hugely :) favor this approach because it's much simpler to reserve hugepages from this interface than a mempolicy based approach once hugepages have already been allocated before. For cpusets users in particular, jobs typically get allocated on a subset of nodes that are required for that application and they don't last for the duration of the machine's uptime. When a job exits and the
Quoted 9 lines
nodes need to be reallocated to a new cpuset, it may be a very different set of mems based on the memory requirements or interleave optimizations for the new job. Allocating resources such as hugepages are possible in this scenario via mempolicies, but it would require a temporary mempolicy to then allocate additional hugepages from which seems like an unnecessary requirement, especially if the job scheduler that is governing hugepage allocations already has a mempolicy of its own.
I don't know the setup, but lets say something like the following is happening
1. job scheduler creates cpuset of subset of nodes
2. job scheduler creates memory policy for subset of nodes
3. initialisation job starts, reserves huge pages. If a memory policy is already in place, it will reserve them in the correct places
4. Job completes
5. job scheduler frees the pages reserved for the job freeing up pages on the subset of nodes
i.e. if the job scheduler already has a memory policy of it's own, or even some child process of that job scheduler, it should just be able to set nr_hugepages and have them reserved on the correct nodes.
With the per-node-attribute approach, little stops a process going outside of it's subset of allowed nodes.
Quoted 5 lines
So it's my opinion that the mempolicy based approach is very appropriate for tasks that allocate hugepages itself. Other users, particularly cpusets users, however, would require preallocation of hugepages prior to a job being scheduled in which case a temporary mempolicy would be required for that job scheduler.
And why is it such a big difficulty for the job scheduler just to create a child that does
numactl -m $NODES_SUBSET hugeadm --pool-pages-min 2M:+$PAGES_NEEDED
?
Quoted 5 lines
That seems like
an inconvenience when the entire state of the system's hugepages could easily be governed with the per-node hstate attributes and a slightly modified user library.
Signature · 7 lines
Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- To unsubscribe from this list: send the line "unsubscribe linux-numa" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 140 lines · Mel Gorman
Quoted 86 lines · David Rientjes
Quoted 84 lines · Lee Schermerhorn
PATCH/RFC 4/4 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc3-mmotm-090716-1432
atop the previously postedalloc_bootmem_hugepagesfix.
[http://marc.info/?l=linux-mm&m=124775468226290&w=4]This patch adds the per huge page size control/query attributes to the per node sysdevs:
/sys/devices/system/node/node<ID>/hugepages/hugepages-<size>/
nr_hugepages- r/w
free_huge_pages- r/o
surplus_huge_pages- r/oThe patch attempts to re-use/share as much of the existing global hstate attribute initialization and handling as possible. Throughout, a node id < 0 indicates global hstate parameters.
Note: computation of "
min_count" inset_max_huge_pages()for a specified node needs careful review.Issue: dependency of base driver [node] dependency on hugetlbfs module. We want to keep all of the hstate attribute registration and handling in the hugetlb module. However, we need to call into this code to register the per node hstate attributes on node hot plug.
With this patch:
(me):ls
/sys/devices/system/node/node0/hugepages/hugepages-2048kB./ ../free_hugepagesnr_hugepagessurplus_hugepagesStarting from:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 0 Node 2 HugePages_Free: 0 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0vm.nr_hugepages = 0
Allocate 16 persistent huge pages on node 2:
(me):echo 16 >/sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepagesYields:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 16 Node 2 HugePages_Free: 16 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0vm.nr_hugepages = 16
Global controls work as expected--reduce pool to 8 persistent huge pages:
(me):echo 8 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepagesNode 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 8 Node 2 HugePages_Free: 8 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0Quoted 8 lines
Quoted 2 lines
Signed-off-by Lee Schermerhorn <[email protected]>Thank you very much for doing this.
Google is going to need this support regardless of what finally gets merged into mainline, so I'm thrilled you've implemented this version.
The fact that there is a definite use case in mind lends weight to this approach but I want to be 100% sure that a hugetlbfs-specific interface is required in this case.
Quoted 6 lines
I hugely (get it? hugely :) favor this approach because it's much simpler to reserve hugepages from this interface than a mempolicy based approach once hugepages have already been allocated before. For cpusets users in particular, jobs typically get allocated on a subset of nodes that are required for that application and they don't last for the duration of the machine's uptime. When a job exits and the
Quoted 9 lines
nodes need to be reallocated to a new cpuset, it may be a very different set of mems based on the memory requirements or interleave optimizations for the new job. Allocating resources such as hugepages are possible in this scenario via mempolicies, but it would require a temporary mempolicy to then allocate additional hugepages from which seems like an unnecessary requirement, especially if the job scheduler that is governing hugepage allocations already has a mempolicy of its own.
I don't know the setup, but lets say something like the following is happening
1. job scheduler creates cpuset of subset of nodes
2. job scheduler creates memory policy for subset of nodes
3. initialisation job starts, reserves huge pages. If a memory policy is already in place, it will reserve them in the correct places
4. Job completes
5. job scheduler frees the pages reserved for the job freeing up pages on the subset of nodesi.e. if the job scheduler already has a memory policy of it's own, or even some child process of that job scheduler, it should just be able to set
nr_hugepagesand have them reserved on the correct nodes.With the per-node-attribute approach, little stops a process going outside of it's subset of allowed nodes.
Quoted 5 lines
So it's my opinion that the mempolicy based approach is very appropriate for tasks that allocate hugepages itself. Other users, particularly cpusets users, however, would require preallocation of hugepages prior to a job being scheduled in which case a temporary mempolicy would be required for that job scheduler.
Quoted 13 lines
And why is it such a big difficulty for the job scheduler just to create a child that does
numactl -m $NODES_SUBSET hugeadm --pool-pages-min 2M:+$PAGES_NEEDED
?
Quoted 5 lines
That seems like
an inconvenience when the entire state of the system's hugepages could easily be governed with the per-node hstate attributes and a slightly modified user library.
It occurred to me that I could easily rebase the per node attributes atop the mempolicy based nodes_allowed series and support both methods of control. I'm not saying that I should, just that I could. So, I did. This applies atop the V3 mempolicy based nodes_allowed series. [You'll want the patch to restore the kfree of nodes_allowed that I just sent out.]
I'll be offline for most/all of next week, so perhaps David and Mel could have a look at this and sort out how they want to proceed. Andrew is holding off on these series until we can decide on one.
Lee
---
PATCH/RFC 5/4 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc4-mmotm-090730-0510
and the hugetlb rework and mempolicy-based nodes_allowed series
V2: remove dependency on kobject private bitfield. Search
global hstates then all per node hstates for kobject match in attribute show/store functions.
V3: rebase atop the mempolicy-based hugepage alloc/free;
use custom "nodes_allowed" to restrict alloc/free to a specific node via per node attributes. Per node attribute overrides mempolicy. I.e., mempolicy only applies to global attributes.
To demonstrate feasibility--if not advisability--of supporting both mempolicy-based persistent huge page management with per node "override" attributes.
This patch adds the per huge page size control/query attributes to the per node sysdevs:
/sys/devices/system/node/node<ID>/hugepages/hugepages-<size>/
nr_hugepages - r/w
free_huge_pages - r/o
surplus_huge_pages - r/o
The patch attempts to re-use/share as much of the existing global hstate attribute initialization and handling, and the "nodes_allowed" constraint processing as possible. In set_max_huge_pages(), a node id < 0 indicates a change to global hstate parameters. In this case, any non-default task mempolicy will be used to generate the nodes_allowed mask. A node id > 0 indicates a node specific update and the count argument specifies the target count for the node. From this info, we compute the target global count for the hstate and construct a nodes_allowed node mask contain only the specified node. Thus, setting the node specific nr_hugepages via the per node attribute effectively overrides any task mempolicy.
Issue: dependency of base driver [node] dependency on hugetlbfs module. We want to keep all of the hstate attribute registration and handling in the hugetlb module. However, we need to call into this code to register the per node hstate attributes on node hot plug.
With this patch:
(me):ls /sys/devices/system/node/node0/hugepages/hugepages-2048kB ./ ../ free_hugepages nr_hugepages surplus_hugepages
Starting from:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 0 Node 2 HugePages_Free: 0 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
vm.nr_hugepages = 0
Allocate 16 persistent huge pages on node 2:
(me):echo 16 >/sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages
[Note that this is equivalent to:
numactl -m 2 hugeadmin --pool-pages-min 2M:+16
]
Yields:
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 16 Node 2 HugePages_Free: 16 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
vm.nr_hugepages = 16
Global controls work as expected--reduce pool to 8 persistent huge pages:
(me):echo 8 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 Node 1 HugePages_Total: 0 Node 1 HugePages_Free: 0 Node 1 HugePages_Surp: 0 Node 2 HugePages_Total: 8 Node 2 HugePages_Free: 8 Node 2 HugePages_Surp: 0 Node 3 HugePages_Total: 0 Node 3 HugePages_Free: 0 Node 3 HugePages_Surp: 0
drivers/base/node.c | 2 include/linux/hugetlb.h | 6 + include/linux/node.h | 3 mm/hugetlb.c | 213 +++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 197 insertions(+), 27 deletions(-)
drivers/base/node.c +2 -0
@@ -200,6 +200,7 @@ int register_node(struct node *node, intsysdev_create_file (&node->sysdev, &attr_distance);scan_unevictable_register_node (node); +hugetlb_register_node (node); }return error; }
@@ -220,6 +221,7 @@ void unregister_node(struct node *node)sysdev_remove_file (&node->sysdev, &attr_distance);scan_unevictable_unregister_node (node); +hugetlb_unregister_node (node);sysdev_unregister (&node->sysdev); }
include/linux/hugetlb.h +6 -0
@@ -278,6 +278,10 @@ static inline struct hstate *page_hstate return size_to_hstate(PAGE_SIZE << compound_order(page)); } +struct node ; +extern void hugetlb_register_node (struct node *); +extern void hugetlb_unregister_node (struct node *); +#else struct hstate {};#define alloc_bootmem_huge_page (h) NULL
@@ -294,6 +298,8 @@ static inline unsigned int pages_per_hug {return 1 ; } +#define hugetlb_register_node (NP ) +#define hugetlb_unregister_node (NP )#endif #endif /* _LINUX_HUGETLB_H */
mm/hugetlb.c +186 -27
328 lines not on this page · raw message
include/linux/node.h +3 -0
@@ -21,9 +21,12 @@#include <linux/sysdev.h> #include <linux/cpumask.h> +#include <linux/hugetlb.h> struct node {struct sys_device sysdev; +struct kobject *hugepages_kobj; +struct kobject *hstate_kobjs[HUGE_MAX_HSTATE ]; };struct memory_block ;
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 6 lines · Lee Schermerhorn
PATCH/RFC 5/4 hugetlb: register per node hugepages attributes
Against: 2.6.31-rc4-mmotm-090730-0510
and the hugetlb rework and mempolicy-basednodes_allowedseries
Andrew, Lee, what's the status of this patchset? I don't see it, or the mempolicy support version, in mmotm-2009-08-12-13-55.
I think there are use cases for both the per-node hstate attributes and the mempolicy restricted hugepage allocation support and both features can co-exist in the kernel.
My particular interest is in the per-node hstate attributes because it allows job schedulers to preallocate hugepages in nodes attached to a cpuset with ease and allows node-targeted hugepage freeing for balanced allocations, which is a prerequisite for effective interleave optimizations.
I'd encourage the addition of the per-node hstate attributes to mmotm. Thanks Lee for implementing this feature.
--
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>
Andrew Morton
maintainerRe: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 1 line · On Fri, 14 Aug 2009 15:38:43 -0700 (PDT) David Rientjes <[email protected]>…
Andrew, Lee, what's the status of this patchset?
All forgotten about as far as I'm concerned. It was v1, it had "rfc" in there and had an "Ick, no, please don't do that" from Greg. I assume Greg's OK with the fixed-up version.
--
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>
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 8 lines · Andrew Morton
Quoted 1 line · On Fri, 14 Aug 2009 15:38:43 -0700 (PDT) David Rientjes <[email protected]>…
Andrew, Lee, what's the status of this patchset?
All forgotten about as far as I'm concerned. It was v1, it had "rfc" in there and had an "Ick, no, please don't do that" from Greg. I assume Greg's OK with the fixed-up version.
If the fixed up version does not touch the kobject core in any manner, then yes, I have no objection.
thanks,
greg k-h
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
In reply to Andrew MortonQuoted 10 lines · Andrew Morton
Quoted 1 line · On Fri, 14 Aug 2009 15:38:43 -0700 (PDT) David Rientjes <[email protected]>…
Andrew, Lee, what's the status of this patchset?
All forgotten about as far as I'm concerned. It was v1, it had "rfc" in there and had an "Ick, no, please don't do that" from Greg. I assume Greg's OK with the fixed-up version.
I think Greg's concerns were addressed in the latest revision of the patchset, specifically http://marc.info/?l=linux-mm&m=124906676520398.
Maybe the more appropriate question to ask is if Mel has any concerns about adding the per-node hstate attributes either as a substitution or as a complement to the mempolicy-based allocation approach. Mel?
Lee, do you have plans to resend the patchset including the modified kobj handling?
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 16 lines · David Rientjes
Quoted 10 lines · Andrew Morton
Quoted 1 line · On Fri, 14 Aug 2009 15:38:43 -0700 (PDT) David Rientjes <[email protected]>…
Andrew, Lee, what's the status of this patchset?
All forgotten about as far as I'm concerned. It was v1, it had "rfc" in there and had an "Ick, no, please don't do that" from Greg. I assume Greg's OK with the fixed-up version.
I think Greg's concerns were addressed in the latest revision of the patchset, specifically http://marc.info/?l=linux-mm&m=124906676520398.
Quoted 6 lines
Maybe the more appropriate question to ask is if Mel has any concerns about adding the per-node hstate attributes either as a substitution or as a complement to the mempolicy-based allocation approach. Mel?
Lee, do you have plans to resend the patchset including the modified kobj handling?
Yes. I had planned to ping you and Mel, as I hadn't heard back from you about the combined interfaces. I think they mesh fairly well, and the per node attributes have the, perhaps desirable, property of ignoring any current task mempolicy. But, I know that some folks don't like a proliferation of ways to do something. I'll package up the series [I need to update the Documentation for the per node attributes] and send it out as soon as I can get to it. This week, I'm pretty sure.
Lee
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
Quoted 5 lines · Lee Schermerhorn
Yes. I had planned to ping you and Mel, as I hadn't heard back from you about the combined interfaces. I think they mesh fairly well, and the per node attributes have the, perhaps desirable, property of ignoring any current task mempolicy. But, I know that some folks don't like a proliferation of ways to do something.
I agree as a matter of general principle, but I don't think this would be a good example of it.
I'm struggling to understand exactly how clean the mempolicy-based approach would be if an application such as a job scheduler wanted to free hugepages only on specific nodes. Presumably this would require the application to create a MPOL_BIND mempolicy to those nodes and write to /proc/sys/vm/nr_hugepages, but that may break existing implementations if there are no hugepages allocated on the mempolicy's nodes.
Quoted 4 lines
I'll package up the series [I
need to update the Documentation for the per node attributes] and send it out as soon as I can get to it. This week, I'm pretty sure.
That's good news, thanks!
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
In reply to David RientjesQuoted 4 lines · David Rientjes
Quoted 2 lines · Lee Schermerhorn
PATCH/RFC 5/4 hugetlb: register per node hugepages attributes
Quoted 8 lines
Quoted 4 lines
Against: 2.6.31-rc4-mmotm-090730-0510
and the hugetlb rework and mempolicy-basednodes_allowedseriesAndrew, Lee, what's the status of this patchset? I don't see it, or the mempolicy support version, in mmotm-2009-08-12-13-55.
Lee went on holidays and I dropped the ball somewhat in that I didn't review the combined set he posted just before he left. As the two approaches are not mutually exclusive, my expectation was that at at least one more patchset would be posted combining both approaches before merging to -mm.
Quoted 4 lines
I think there are use cases for both the per-node hstate attributes and the mempolicy restricted hugepage allocation support and both features can co-exist in the kernel.
Agreed.
Quoted 9 lines
My particular interest is in the per-node hstate attributes because it allows job schedulers to preallocate hugepages in nodes attached to a cpuset with ease and allows node-targeted hugepage freeing for balanced allocations, which is a prerequisite for effective interleave optimizations.
I'd encourage the addition of the per-node hstate attributes to mmotm. Thanks Lee for implementing this feature.
I'd like to see at least one patchset without the RFCs attached and have one more read-through before it's merged.
Signature · 9 lines
Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- 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>
Re: [PATCH 4/4] hugetlb: add per node hstate attributes
In reply to Mel GormanQuoted 8 lines · Mel Gorman
Quoted 3 lines
Google is going to need this support regardless of what finally gets merged into mainline, so I'm thrilled you've implemented this version.
The fact that there is a definite use case in mind lends weight to this approach but I want to be 100% sure that a hugetlbfs-specific interface is required in this case.
It's not necessarily required over the mempolicy approach for allocation since it's quite simple to just do
numactl --membind nodemask echo 10 > \ /sys/kernel/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
on the nodemask for which you want to allocate 10 additional hugepages (or, if node-targeted allocations are really necessary, to use numactl --preferred node in succession to get a balanced interleave, for example.)
Quoted 7 lines
I don't know the setup, but lets say something like the following is happening
1. job scheduler creates cpuset of subset of nodes
2. job scheduler creates memory policy for subset of nodes
3. initialisation job starts, reserves huge pages. If a memory policy is already in place, it will reserve them in the correct places
This is where per-node nr_hugepages attributes would be helpful. It may not be possible for the desired number of hugepages to be evenly allocated on each node in the subset for MPOL_INTERLEAVE.
If the subset is {1, 2, 3}, for instance, it's possible to get hugepage quantities on those nodes as {10, 5, 10}. The preferred userspace solution may be to either change its subset of the cpuset nodes to allocate 10 hugepages on another node and not use node 2, or to deallocate hugepages on nodes 1 and 3 so it matches node 2.
With the per-node nr_hugepages attributes, that's trivial. With the mempolicy based approach, you'd need to do this (I guess):
- to change the subset of cpuset nodes: construct a mempolicy of MPOL_PREFERRED on node 2, deallocate via the global nr_hugepages file, select (or allocate) another cpuset node, construct another mempolicy of MPOL_PREFERRED on that new node, allocate, check, reiterate, and
- to deallocate on nodes 1 and 3: construct a mempolicy of MPOL_BIND on nodes 1 and 3, deallocate via the global nr_hugepages.
I'm not sure at the moment that mempolicies work in freeing hugepages via /sys/kernel/mm/hugepages/*/nr_hugepags and it isn't simply a round-robin, so the second solution may not even work.
Quoted 8 lines
4. Job completes
5. job scheduler frees the pages reserved for the job freeing up pages on the subset of nodesi.e. if the job scheduler already has a memory policy of it's own, or even some child process of that job scheduler, it should just be able to set
nr_hugepagesand have them reserved on the correct nodes.
Right, allocation is simple with the mempolicy based approach, but given the fact that hugepages are not always successfully allocated to what userspace wants and freeing is more difficult, it's easier to use per-node controls.
Quoted 3 lines
With the per-node-attribute approach, little stops a process going outside of it's subset of allowed nodes.
If you are allowed the capability to allocate system-wide resources for hugepages (and you can change your own mempolicy to MPOL_DEFAULT whenever you want, of course), that doesn't seem like an issue.