linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Michal Hocko <mhocko@suse.cz>, Mel Gorman <mgorman@suse.de>,
	Rik van Riel <riel@redhat.com>, Hillf Danton <dhillf@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Wanpeng Li <liwanp@linux.vnet.ibm.com>
Subject: [PATCH 1/6] mm/hugetlb: introduce new sysctl knob which control gigantic page pools shrinking
Date: Thu,  4 Apr 2013 17:09:09 +0800	[thread overview]
Message-ID: <1365066554-29195-2-git-send-email-liwanp@linux.vnet.ibm.com> (raw)
In-Reply-To: <1365066554-29195-1-git-send-email-liwanp@linux.vnet.ibm.com>

This patch introduces new sysctl knob to support gigantic hugetlb page
pools shrinking. The default value is 0 since gigantic page pools
aren't permitted shrinked by default, administrator can echo 1 to knob
to enable gigantic page pools shrinking after they confirm they won't
use them any more.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 Documentation/sysctl/vm.txt |   13 +++++++++++++
 include/linux/hugetlb.h     |    3 +++
 kernel/sysctl.c             |    7 +++++++
 mm/hugetlb.c                |    9 +++++++++
 4 files changed, 32 insertions(+)

diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
index 21ad181..3baf332 100644
--- a/Documentation/sysctl/vm.txt
+++ b/Documentation/sysctl/vm.txt
@@ -30,6 +30,7 @@ Currently, these files are in /proc/sys/vm:
 - extfrag_threshold
 - hugepages_treat_as_movable
 - hugetlb_shm_group
+- hugetlb_shrink_gigantic_pool
 - laptop_mode
 - legacy_va_layout
 - lowmem_reserve_ratio
@@ -211,6 +212,18 @@ shared memory segment using hugetlb page.
 
 ==============================================================
 
+hugetlb_shrink_gigantic_pool
+
+order >= MAX_ORDER pages are only allocated at boot stage using the bootmem
+allocator with the "hugepages=xxx" option. These pages are never free'd
+by default since it would be a one-way street(>= MAX_ORDER pages cannot
+be allocated later), but if administrator confirm not to use these gigantic
+pages any more, these pinned pages will waste memory since other users
+can't grab free pages from gigantic hugetlb pool even OOM. Administrator
+can enable this parameter to permit to shrink gigantic hugetlb pool
+
+==============================================================
+
 laptop_mode
 
 laptop_mode is a knob that controls "laptop mode". All the things that are
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 3a62df3..b7e4106 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -36,6 +36,8 @@ void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
 int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
 int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
 int hugetlb_treat_movable_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
+int hugetlb_shrink_gigantic_pool_handler(struct ctl_table *,
+				int, void __user *, size_t *, loff_t *);
 
 #ifdef CONFIG_NUMA
 int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int,
@@ -73,6 +75,7 @@ extern unsigned long hugepages_treat_as_movable;
 extern const unsigned long hugetlb_zero, hugetlb_infinity;
 extern int sysctl_hugetlb_shm_group;
 extern struct list_head huge_boot_pages;
+extern int hugetlb_shrink_gigantic_pool;
 
 /* arch callbacks */
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 3dadde5..25eb85f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1187,6 +1187,13 @@ static struct ctl_table vm_table[] = {
 		.extra1		= (void *)&hugetlb_zero,
 		.extra2		= (void *)&hugetlb_infinity,
 	},
+	{
+		.procname       = "hugetlb_shrink_gigantic_pool",
+		.data           = &hugetlb_shrink_gigantic_pool,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = hugetlb_shrink_gigantic_pool_handler,
+	},
 #ifdef CONFIG_NUMA
 	{
 		.procname       = "nr_hugepages_mempolicy",
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index bacdf38..4a0c270 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -35,6 +35,7 @@
 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
 static gfp_t htlb_alloc_mask = GFP_HIGHUSER;
 unsigned long hugepages_treat_as_movable;
+int hugetlb_shrink_gigantic_pool;
 
 int hugetlb_max_hstate __read_mostly;
 unsigned int default_hstate_idx;
@@ -671,6 +672,14 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order)
 	}
 }
 
+int hugetlb_shrink_gigantic_pool_handler(struct ctl_table *table, int write,
+			void __user *buffer,
+			size_t *length, loff_t *ppos)
+{
+	proc_dointvec(table, write, buffer, length, ppos);
+	return 0;
+}
+
 /*
  * PageHuge() only returns true for hugetlbfs pages, but not for normal or
  * transparent huge pages.  See the PageTransHuge() documentation for more
-- 
1.7.10.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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-04-04  9:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04  9:09 [PATCH 0/6] mm/hugetlb: gigantic hugetlb page pools shrink supporting Wanpeng Li
2013-04-04  9:09 ` Wanpeng Li [this message]
2013-04-04  9:09 ` [PATCH 2/6] mm/hugetlb: update_and_free_page gigantic pages awareness Wanpeng Li
2013-04-04  9:09 ` [PATCH 3/6] mm/hugetlb: enable gigantic hugetlb page pools shrinking Wanpeng Li
2013-04-04  9:09 ` [PATCH 4/6] mm/hugetlb: use already exist huge_page_order() instead of h->order Wanpeng Li
2013-04-04  9:09 ` [PATCH 5/6] mm/hugetlb: remove redundant hugetlb_prefault Wanpeng Li
2013-04-04  9:09 ` [PATCH 6/6] mm/hugetlb: use already exist interface huge_page_shift Wanpeng Li
2013-04-04 16:17 ` [PATCH 0/6] mm/hugetlb: gigantic hugetlb page pools shrink supporting Michal Hocko
2013-04-04 16:20   ` Michal Hocko
2013-04-05  1:29     ` Wanpeng Li
2013-04-05  1:29     ` Wanpeng Li
2013-04-04 23:41   ` Wanpeng Li
2013-04-04 23:41   ` Wanpeng Li
2013-04-05  8:12     ` Michal Hocko
2013-04-05  8:27       ` Wanpeng Li
2013-04-05  8:27       ` Wanpeng Li
2013-04-05  9:27         ` Michal Hocko
2013-04-05  8:54       ` Simon Jeons
2013-04-05  9:52         ` Michal Hocko
2013-04-04 23:35 ` Wanpeng Li
2013-04-04 23:35 ` Wanpeng Li
2013-04-11 23:29 ` Wanpeng Li
2013-04-12 15:22   ` Andi Kleen
2013-07-15 11:31     ` Wanpeng Li
2013-07-15 11:31     ` Wanpeng Li
2014-08-21 23:37     ` Wanpeng Li
2014-08-22  1:34       ` Zhang Yanfei
2014-08-22  4:04         ` Wanpeng Li
2014-08-22 14:18           ` Andi Kleen
2013-04-11 23:29 ` Wanpeng Li

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=1365066554-29195-2-git-send-email-liwanp@linux.vnet.ibm.com \
    --to=liwanp@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=dhillf@gmail.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.cz \
    --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 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).