diff options
author | Lee Schermerhorn <lee.schermerhorn@hp.com> | 2009-12-14 20:58:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:12 -0500 |
commit | 9a30523066cde73c1442b76224bb540de9f9b0b0 (patch) | |
tree | 57165f74e16def0b74bb6e6e05ec9a6b7bd42403 /drivers/base | |
parent | 4e25b2576efda24c02e2d6b9bcb5965a3f865f33 (diff) |
hugetlb: add per node hstate attributes
Add 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.
Calling set_max_huge_pages() with no node 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 valid node id indicates an
update to that node's hstate parameters, and the count argument specifies
the target count for the specified 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.
Setting the node specific nr_hugepages via the per node attribute
effectively ignores any task mempolicy or cpuset constraints.
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
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: Andi Kleen <andi@firstfloor.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Adam Litke <agl@us.ibm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Eric Whitney <eric.whitney@hp.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/node.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index 1fe5536d404f..f502711d28db 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -173,6 +173,43 @@ static ssize_t node_read_distance(struct sys_device * dev, | |||
173 | } | 173 | } |
174 | static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL); | 174 | static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL); |
175 | 175 | ||
176 | #ifdef CONFIG_HUGETLBFS | ||
177 | /* | ||
178 | * hugetlbfs per node attributes registration interface: | ||
179 | * When/if hugetlb[fs] subsystem initializes [sometime after this module], | ||
180 | * it will register its per node attributes for all nodes online at that | ||
181 | * time. It will also call register_hugetlbfs_with_node(), below, to | ||
182 | * register its attribute registration functions with this node driver. | ||
183 | * Once these hooks have been initialized, the node driver will call into | ||
184 | * the hugetlb module to [un]register attributes for hot-plugged nodes. | ||
185 | */ | ||
186 | static node_registration_func_t __hugetlb_register_node; | ||
187 | static node_registration_func_t __hugetlb_unregister_node; | ||
188 | |||
189 | static inline void hugetlb_register_node(struct node *node) | ||
190 | { | ||
191 | if (__hugetlb_register_node) | ||
192 | __hugetlb_register_node(node); | ||
193 | } | ||
194 | |||
195 | static inline void hugetlb_unregister_node(struct node *node) | ||
196 | { | ||
197 | if (__hugetlb_unregister_node) | ||
198 | __hugetlb_unregister_node(node); | ||
199 | } | ||
200 | |||
201 | void register_hugetlbfs_with_node(node_registration_func_t doregister, | ||
202 | node_registration_func_t unregister) | ||
203 | { | ||
204 | __hugetlb_register_node = doregister; | ||
205 | __hugetlb_unregister_node = unregister; | ||
206 | } | ||
207 | #else | ||
208 | static inline void hugetlb_register_node(struct node *node) {} | ||
209 | |||
210 | static inline void hugetlb_unregister_node(struct node *node) {} | ||
211 | #endif | ||
212 | |||
176 | 213 | ||
177 | /* | 214 | /* |
178 | * register_node - Setup a sysfs device for a node. | 215 | * register_node - Setup a sysfs device for a node. |
@@ -196,6 +233,7 @@ int register_node(struct node *node, int num, struct node *parent) | |||
196 | sysdev_create_file(&node->sysdev, &attr_distance); | 233 | sysdev_create_file(&node->sysdev, &attr_distance); |
197 | 234 | ||
198 | scan_unevictable_register_node(node); | 235 | scan_unevictable_register_node(node); |
236 | hugetlb_register_node(node); | ||
199 | } | 237 | } |
200 | return error; | 238 | return error; |
201 | } | 239 | } |
@@ -216,6 +254,7 @@ void unregister_node(struct node *node) | |||
216 | sysdev_remove_file(&node->sysdev, &attr_distance); | 254 | sysdev_remove_file(&node->sysdev, &attr_distance); |
217 | 255 | ||
218 | scan_unevictable_unregister_node(node); | 256 | scan_unevictable_unregister_node(node); |
257 | hugetlb_unregister_node(node); | ||
219 | 258 | ||
220 | sysdev_unregister(&node->sysdev); | 259 | sysdev_unregister(&node->sysdev); |
221 | } | 260 | } |