From: Lee Schermerhorn <lee.schermerhorn@hp.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, Mel Gorman <mel@csn.ul.ie>,
Nishanth Aravamudan <nacc@us.ibm.com>,
Adam Litke <agl@us.ibm.com>, Andy Whitcroft <apw@canonical.com>,
eric.whitney@hp.com
Subject: [PATCH 4/5] Add sysctl for default hstate nodes_allowed.
Date: Tue, 16 Jun 2009 09:53:08 -0400 [thread overview]
Message-ID: <20090616135308.25248.57593.sendpatchset@lts-notebook> (raw)
In-Reply-To: <20090616135228.25248.22018.sendpatchset@lts-notebook>
[PATCH 4/5] add sysctl for default hstate nodes_allowed.
Against: 17may09 mmotm
This patch adds a sysctl -- /proc/sys/vm/hugepages_nodes_allowed --
to set/query the default hstate's nodes_allowed. I don't know
that this patch is required, given that we have the per hstate
controls in /sys/kernel/mm/hugepages/*. However, we've added sysctls
for other recent hugepages controls, like nr_overcommit_hugepages,
so I've followed that convention.
Factor the formatting of the nodes_allowed mask out of nodes_allowed_show()
for use by both that function and the hugetlb_nodes_allowed_handler().
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp>
include/linux/hugetlb.h | 1 +
kernel/sysctl.c | 8 ++++++++
mm/hugetlb.c | 43 ++++++++++++++++++++++++++++++++++++++-----
3 files changed, 47 insertions(+), 5 deletions(-)
Index: linux-2.6.30-rc8-mmotm-090603-1633/include/linux/hugetlb.h
===================================================================
--- linux-2.6.30-rc8-mmotm-090603-1633.orig/include/linux/hugetlb.h 2009-06-04 12:59:32.000000000 -0400
+++ linux-2.6.30-rc8-mmotm-090603-1633/include/linux/hugetlb.h 2009-06-04 12:59:35.000000000 -0400
@@ -22,6 +22,7 @@ void reset_vma_resv_huge_pages(struct vm
int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
int hugetlb_overcommit_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
+int hugetlb_nodes_allowed_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int, int);
void unmap_hugepage_range(struct vm_area_struct *,
Index: linux-2.6.30-rc8-mmotm-090603-1633/kernel/sysctl.c
===================================================================
--- linux-2.6.30-rc8-mmotm-090603-1633.orig/kernel/sysctl.c 2009-06-04 12:59:26.000000000 -0400
+++ linux-2.6.30-rc8-mmotm-090603-1633/kernel/sysctl.c 2009-06-04 12:59:35.000000000 -0400
@@ -1108,6 +1108,14 @@ static struct ctl_table vm_table[] = {
.extra1 = (void *)&hugetlb_zero,
.extra2 = (void *)&hugetlb_infinity,
},
+ {
+ .ctl_name = CTL_UNNUMBERED,
+ .procname = "hugepages_nodes_allowed",
+ .data = NULL,
+ .maxlen = sizeof(unsigned long),
+ .mode = 0644,
+ .proc_handler = &hugetlb_nodes_allowed_handler,
+ },
#endif
{
.ctl_name = VM_LOWMEM_RESERVE_RATIO,
Index: linux-2.6.30-rc8-mmotm-090603-1633/mm/hugetlb.c
===================================================================
--- linux-2.6.30-rc8-mmotm-090603-1633.orig/mm/hugetlb.c 2009-06-04 12:59:33.000000000 -0400
+++ linux-2.6.30-rc8-mmotm-090603-1633/mm/hugetlb.c 2009-06-04 12:59:35.000000000 -0400
@@ -1354,19 +1354,27 @@ static ssize_t nr_overcommit_hugepages_s
}
HSTATE_ATTR(nr_overcommit_hugepages);
-static ssize_t nodes_allowed_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
+static int format_hstate_nodes_allowed(struct hstate *h, char *buf,
+ size_t buflen)
{
- struct hstate *h = kobj_to_hstate(kobj);
int len = 3;
if (h->nodes_allowed == &node_online_map)
strcpy(buf, "all");
else
- len = nodelist_scnprintf(buf, PAGE_SIZE,
+ len = nodelist_scnprintf(buf, buflen,
*h->nodes_allowed);
+ return len;
+
+}
+
+static ssize_t nodes_allowed_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct hstate *h = kobj_to_hstate(kobj);
+ int len = format_hstate_nodes_allowed(h, buf, PAGE_SIZE);
- if (len)
+ if (len && (len +1) < PAGE_SIZE)
buf[len++] = '\n';
return len;
@@ -1684,6 +1692,31 @@ int hugetlb_overcommit_handler(struct ct
return 0;
}
+#define NODES_ALLOWED_MAX 64
+int hugetlb_nodes_allowed_handler(struct ctl_table *table, int write,
+ struct file *file, void __user *buffer,
+ size_t *length, loff_t *ppos)
+{
+ struct hstate *h = &default_hstate;
+ int ret = 0;
+
+ if (write) {
+ (void)set_hstate_nodes_allowed(h, buffer, 1);
+ } else {
+ char buf[NODES_ALLOWED_MAX];
+ struct ctl_table tbl = {
+ .data = buf,
+ .maxlen = NODES_ALLOWED_MAX,
+ };
+ int len = format_hstate_nodes_allowed(h, buf, sizeof(buf));
+
+ if (len)
+ ret = proc_dostring(&tbl, write, file, buffer,
+ length, ppos);
+ }
+ return ret;
+}
+
#endif /* CONFIG_SYSCTL */
void hugetlb_report_meminfo(struct seq_file *m)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-06-16 13:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 13:52 [PATCH 0/5] Huge Pages Nodes Allowed Lee Schermerhorn
2009-06-16 13:52 ` [PATCH 1/5] Free huge pages round robin to balance across nodes Lee Schermerhorn
2009-06-17 13:18 ` Mel Gorman
2009-06-17 17:16 ` Lee Schermerhorn
2009-06-18 19:08 ` David Rientjes
2009-06-16 13:52 ` [PATCH 2/5] Add nodes_allowed members to hugepages hstate struct Lee Schermerhorn
2009-06-17 13:35 ` Mel Gorman
2009-06-17 17:38 ` Lee Schermerhorn
2009-06-18 9:17 ` Mel Gorman
2009-06-16 13:53 ` [PATCH 3/5] Use per hstate nodes_allowed to constrain huge page allocation Lee Schermerhorn
2009-06-17 13:39 ` Mel Gorman
2009-06-17 17:47 ` Lee Schermerhorn
2009-06-18 9:18 ` Mel Gorman
2009-06-16 13:53 ` Lee Schermerhorn [this message]
2009-06-17 13:41 ` [PATCH 4/5] Add sysctl for default hstate nodes_allowed Mel Gorman
2009-06-17 17:52 ` Lee Schermerhorn
2009-06-18 9:19 ` Mel Gorman
2009-06-16 13:53 ` [PATCH 5/5] Update huge pages kernel documentation Lee Schermerhorn
2009-06-18 18:49 ` David Rientjes
2009-06-18 19:06 ` Lee Schermerhorn
2009-06-17 13:02 ` [PATCH 0/5] Huge Pages Nodes Allowed Mel Gorman
2009-06-17 17:15 ` Lee Schermerhorn
2009-06-18 9:33 ` Mel Gorman
2009-06-18 14:46 ` Lee Schermerhorn
2009-06-18 15:00 ` Mel Gorman
2009-06-18 19:08 ` David Rientjes
2009-06-24 7:11 ` David Rientjes
2009-06-24 11:25 ` Lee Schermerhorn
2009-06-24 22:26 ` David Rientjes
2009-06-25 2:14 ` Lee Schermerhorn
2009-06-25 19:22 ` David Rientjes
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=20090616135308.25248.57593.sendpatchset@lts-notebook \
--to=lee.schermerhorn@hp.com \
--cc=agl@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=eric.whitney@hp.com \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=nacc@us.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.