All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Amerigo Wang <amwang@redhat.com>,
	dave@linux.vnet.ibm.com, Andrea Arcangeli <aarcange@redhat.com>,
	Mel Gorman <mel@csn.ul.ie>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Rik van Riel <riel@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	linux-mm@kvack.org
Subject: [PATCH v2 2/4] mm: make the threshold of enabling THP configurable
Date: Tue, 21 Jun 2011 16:10:43 +0800	[thread overview]
Message-ID: <1308643849-3325-2-git-send-email-amwang@redhat.com> (raw)
In-Reply-To: <1308643849-3325-1-git-send-email-amwang@redhat.com>

Don't hard-code 512M as the threshold in kernel, make it configruable,
and set 512M by default.

And print info when THP is disabled automatically on small systems.

V2: Add more description in help messages, correct some typos,
print the mini threshold too.

Cc: dave@linux.vnet.ibm.com
Signed-off-by: WANG Cong <amwang@redhat.com>
---
 mm/Kconfig       |   20 ++++++++++++++++++++
 mm/huge_memory.c |    7 ++++++-
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index 8ca47a5..f1b3175f 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -340,6 +340,26 @@ choice
 	  benefit.
 endchoice
 
+config TRANSPARENT_HUGEPAGE_THRESHOLD
+	depends on TRANSPARENT_HUGEPAGE
+	int "The minimal threshold of enabling Transparent Hugepage"
+	range 512 8192
+	default "512"
+	help
+	  The threshold of enabling Transparent Huagepage automatically,
+	  in Mbytes, below this value Transparent Hugepage will be disabled
+	  by default during boot. You can still enable it via /sys after
+	  boot.
+
+	  Transparent hugepages are created by moving other pages out of
+	  the way to create large, contiguous swaths of free memory.
+	  However, some memory on a system can not be easily moved.  It is
+	  likely on small systems that this unmovable memory will occupy a
+	  large portion of total memory, which makes even attempting to
+	  create transparent hugepages very expensive.
+
+	  If you are unsure, set this to the smallest possible value.
+
 #
 # UP and nommu archs use km based percpu allocator
 #
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index e4a4f2b..126c96b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -546,8 +546,13 @@ static int __init hugepage_init(void)
 	 * where the extra memory used could hurt more than TLB overhead
 	 * is likely to save.  The admin can still enable it through /sys.
 	 */
-	if (totalram_pages < (512 << (20 - PAGE_SHIFT)))
+	if (totalram_pages < (CONFIG_TRANSPARENT_HUGEPAGE_THRESHOLD
+					<< (20 - PAGE_SHIFT))) {
+		printk(KERN_INFO "THP: disabled automatically"
+				 "with less than %dMB of RAM\n",
+				 CONFIG_TRANSPARENT_HUGEPAGE_THRESHOLD);
 		transparent_hugepage_flags = 0;
+	}
 
 	start_khugepaged();
 
-- 
1.7.4.4


WARNING: multiple messages have this Message-ID (diff)
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Amerigo Wang <amwang@redhat.com>,
	dave@linux.vnet.ibm.com, Andrea Arcangeli <aarcange@redhat.com>,
	Mel Gorman <mel@csn.ul.ie>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Rik van Riel <riel@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	linux-mm@kvack.org
Subject: [PATCH v2 2/4] mm: make the threshold of enabling THP configurable
Date: Tue, 21 Jun 2011 16:10:43 +0800	[thread overview]
Message-ID: <1308643849-3325-2-git-send-email-amwang@redhat.com> (raw)
In-Reply-To: <1308643849-3325-1-git-send-email-amwang@redhat.com>

Don't hard-code 512M as the threshold in kernel, make it configruable,
and set 512M by default.

And print info when THP is disabled automatically on small systems.

V2: Add more description in help messages, correct some typos,
print the mini threshold too.

Cc: dave@linux.vnet.ibm.com
Signed-off-by: WANG Cong <amwang@redhat.com>
---
 mm/Kconfig       |   20 ++++++++++++++++++++
 mm/huge_memory.c |    7 ++++++-
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index 8ca47a5..f1b3175f 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -340,6 +340,26 @@ choice
 	  benefit.
 endchoice
 
+config TRANSPARENT_HUGEPAGE_THRESHOLD
+	depends on TRANSPARENT_HUGEPAGE
+	int "The minimal threshold of enabling Transparent Hugepage"
+	range 512 8192
+	default "512"
+	help
+	  The threshold of enabling Transparent Huagepage automatically,
+	  in Mbytes, below this value Transparent Hugepage will be disabled
+	  by default during boot. You can still enable it via /sys after
+	  boot.
+
+	  Transparent hugepages are created by moving other pages out of
+	  the way to create large, contiguous swaths of free memory.
+	  However, some memory on a system can not be easily moved.  It is
+	  likely on small systems that this unmovable memory will occupy a
+	  large portion of total memory, which makes even attempting to
+	  create transparent hugepages very expensive.
+
+	  If you are unsure, set this to the smallest possible value.
+
 #
 # UP and nommu archs use km based percpu allocator
 #
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index e4a4f2b..126c96b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -546,8 +546,13 @@ static int __init hugepage_init(void)
 	 * where the extra memory used could hurt more than TLB overhead
 	 * is likely to save.  The admin can still enable it through /sys.
 	 */
-	if (totalram_pages < (512 << (20 - PAGE_SHIFT)))
+	if (totalram_pages < (CONFIG_TRANSPARENT_HUGEPAGE_THRESHOLD
+					<< (20 - PAGE_SHIFT))) {
+		printk(KERN_INFO "THP: disabled automatically"
+				 "with less than %dMB of RAM\n",
+				 CONFIG_TRANSPARENT_HUGEPAGE_THRESHOLD);
 		transparent_hugepage_flags = 0;
+	}
 
 	start_khugepaged();
 
-- 
1.7.4.4

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-06-21  8:12 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21  8:10 [PATCH v2 1/4] mm: completely disable THP by transparent_hugepage=0 Amerigo Wang
2011-06-21  8:10 ` Amerigo Wang
2011-06-21  8:10 ` Amerigo Wang [this message]
2011-06-21  8:10   ` [PATCH v2 2/4] mm: make the threshold of enabling THP configurable Amerigo Wang
2011-06-21 14:44   ` Dave Hansen
2011-06-21 14:44     ` Dave Hansen
2011-06-21 20:17     ` Dave Hansen
2011-06-21 20:17       ` Dave Hansen
2011-06-22  1:23   ` David Rientjes
2011-06-22  1:23     ` David Rientjes
2011-06-22  3:06     ` Cong Wang
2011-06-22  3:06       ` Cong Wang
2011-06-22  3:29       ` David Rientjes
2011-06-22  3:29         ` David Rientjes
2011-06-22  5:40         ` Cong Wang
2011-06-22  5:40           ` Cong Wang
2011-06-22  6:32           ` David Rientjes
2011-06-22  6:32             ` David Rientjes
2011-06-22 11:07             ` Cong Wang
2011-06-22 11:07               ` Cong Wang
2011-06-22 14:40               ` Andrea Arcangeli
2011-06-22 14:40                 ` Andrea Arcangeli
2011-06-23  6:51                 ` Cong Wang
2011-06-23  6:51                   ` Cong Wang
2011-06-21  8:10 ` [PATCH 3/4] mm: improve THP printk messages Amerigo Wang
2011-06-21  8:10   ` Amerigo Wang
2011-06-22  1:23   ` David Rientjes
2011-06-22  1:23     ` David Rientjes
2011-06-22  3:04     ` Cong Wang
2011-06-22  3:04       ` Cong Wang
2011-06-21  8:10 ` [PATCH 4/4] mm: introduce no_ksm to disable totally KSM Amerigo Wang
2011-06-21  8:10   ` Amerigo Wang
2011-06-21 13:32   ` Andrea Arcangeli
2011-06-21 13:32     ` Andrea Arcangeli
2011-06-22  3:13     ` Cong Wang
2011-06-22  3:13       ` Cong Wang
2011-06-21 11:52 ` [PATCH v2 1/4] mm: completely disable THP by transparent_hugepage=0 Michal Hocko
2011-06-21 11:52   ` Michal Hocko
2011-06-21 11:58   ` Michal Hocko
2011-06-21 11:58     ` Michal Hocko
2011-06-21 13:30 ` Andrea Arcangeli
2011-06-21 13:30   ` Andrea Arcangeli
2011-06-22  3:11   ` Cong Wang
2011-06-22  3:11     ` Cong Wang
2011-06-22  1:16 ` David Rientjes
2011-06-22  1:16   ` David Rientjes
2011-06-22  3:08   ` Cong Wang
2011-06-22  3:08     ` Cong Wang
2011-06-22  3:24     ` David Rientjes
2011-06-22  3:24       ` David Rientjes
2011-06-22  5:45       ` Cong Wang
2011-06-22  5:45         ` Cong Wang
2011-06-22  6:23         ` David Rientjes
2011-06-22  6:23           ` David Rientjes
2011-06-22 11:08           ` Cong Wang
2011-06-22 11:08             ` Cong Wang

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=1308643849-3325-2-git-send-email-amwang@redhat.com \
    --to=amwang@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=hannes@cmpxchg.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=riel@redhat.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.