linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: CAI Qian <caiqian@redhat.com>
To: linux-mm <linux-mm@kvack.org>
Subject: [PATCH] hugetlb: remove overcommit sysfs for 1GB pages
Date: Tue, 4 Jan 2011 02:42:44 -0500 (EST)	[thread overview]
Message-ID: <519552481.119951.1294126964024.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <2026935485.119940.1294126785849.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2254 bytes --]

1GB pages cannot be over-commited, attempting to do so results in corruption,
so remove those files for simplicity.

Symptoms:
1) setup 1gb hugepages.

cat /proc/cmdline
...default_hugepagesz=1g hugepagesz=1g hugepages=1...

cat /proc/meminfo
...
HugePages_Total:       1
HugePages_Free:        1
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB
...

2) set nr_overcommit_hugepages

echo 1 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages
cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages
1

3) overcommit 2gb hugepages.

mmap(NULL, 18446744071562067968, PROT_READ|PROT_WRITE, MAP_SHARED, 3,
	   0) = -1 ENOMEM (Cannot allocate memory)

cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages
18446744071589420672

Signed-off-by: CAI Qian <caiqian@redhat.com>
---
 mm/hugetlb.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c4a3558..adc9a9f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1587,6 +1587,20 @@ static struct attribute_group hstate_attr_group = {
 	.attrs = hstate_attrs,
 };
 
+static struct attribute *hstate_1gb_attrs[] = {
+	&nr_hugepages_attr.attr,
+	&free_hugepages_attr.attr,
+	&resv_hugepages_attr.attr,
+#ifdef CONFIG_NUMA
+	&nr_hugepages_mempolicy_attr.attr,
+#endif
+	NULL,
+};
+
+static struct attribute_group hstate_1gb_attr_group = {
+	.attrs = hstate_1gb_attrs,
+};
+
 static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,
 				    struct kobject **hstate_kobjs,
 				    struct attribute_group *hstate_attr_group)
@@ -1615,8 +1629,13 @@ static void __init hugetlb_sysfs_init(void)
 		return;
 
 	for_each_hstate(h) {
-		err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
-					 hstate_kobjs, &hstate_attr_group);
+		/* 1GB pages can not be over-committed, so don't need those files. */
+		if (huge_page_size(h) == 1UL << 30)
+			err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
+						hstate_kobjs, &hstate_1gb_attr_group);
+		else
+			err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
+						hstate_kobjs, &hstate_attr_group);
 		if (err)
 			printk(KERN_ERR "Hugetlb: Unable to add hstate %s",
 								h->name);
-- 
1.7.3.2

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-hugetlb-remove-overcommit-sysfs-for-1GB-pages.patch --]
[-- Type: text/x-patch; name=0001-hugetlb-remove-overcommit-sysfs-for-1GB-pages.patch, Size: 2465 bytes --]

From c88209f7a21ed0c257cc215a7874df50d5e525d5 Mon Sep 17 00:00:00 2001
From: CAI Qian <caiqian@redhat.com>
Date: Tue, 4 Jan 2011 15:30:00 +0800
Subject: [PATCH] hugetlb: remove overcommit sysfs for 1GB pages

1GB pages cannot be over-commited, attempting to do so results in corruption,
so remove those files for simplicity.

Symptoms:
1) setup 1gb hugepages.

cat /proc/cmdline
...default_hugepagesz=1g hugepagesz=1g hugepages=1...

cat /proc/meminfo
...
HugePages_Total:       1
HugePages_Free:        1
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB
...

2) set nr_overcommit_hugepages

echo 1 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages
cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages
1

3) overcommit 2gb hugepages.

mmap(NULL, 18446744071562067968, PROT_READ|PROT_WRITE, MAP_SHARED, 3,
	   0) = -1 ENOMEM (Cannot allocate memory)

cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages
18446744071589420672

Signed-off-by: CAI Qian <caiqian@redhat.com>
---
 mm/hugetlb.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c4a3558..adc9a9f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1587,6 +1587,20 @@ static struct attribute_group hstate_attr_group = {
 	.attrs = hstate_attrs,
 };
 
+static struct attribute *hstate_1gb_attrs[] = {
+	&nr_hugepages_attr.attr,
+	&free_hugepages_attr.attr,
+	&resv_hugepages_attr.attr,
+#ifdef CONFIG_NUMA
+	&nr_hugepages_mempolicy_attr.attr,
+#endif
+	NULL,
+};
+
+static struct attribute_group hstate_1gb_attr_group = {
+	.attrs = hstate_1gb_attrs,
+};
+
 static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,
 				    struct kobject **hstate_kobjs,
 				    struct attribute_group *hstate_attr_group)
@@ -1615,8 +1629,13 @@ static void __init hugetlb_sysfs_init(void)
 		return;
 
 	for_each_hstate(h) {
-		err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
-					 hstate_kobjs, &hstate_attr_group);
+		/* 1GB pages can not be over-committed, so don't need those files. */
+		if (huge_page_size(h) == 1UL << 30)
+			err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
+						hstate_kobjs, &hstate_1gb_attr_group);
+		else
+			err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
+						hstate_kobjs, &hstate_attr_group);
 		if (err)
 			printk(KERN_ERR "Hugetlb: Unable to add hstate %s",
 								h->name);
-- 
1.7.3.2


       reply	other threads:[~2011-01-04  7:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2026935485.119940.1294126785849.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2011-01-04  7:42 ` CAI Qian [this message]
2011-01-04 17:56   ` [PATCH] hugetlb: remove overcommit sysfs for 1GB pages Eric B Munson
2011-01-05  5:02     ` CAI Qian
2011-01-05  7:31       ` CAI Qian
2011-01-05 11:36         ` CAI Qian
2011-01-05 15:02     ` CAI Qian
2011-01-05 16:44       ` Eric B Munson

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=519552481.119951.1294126964024.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com \
    --to=caiqian@redhat.com \
    --cc=linux-mm@kvack.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).