From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: mhocko@suse.com, js1304@gmail.com, vbabka@suse.cz,
mgorman@suse.de, minchan@kernel.org, akpm@linux-foundation.org,
aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com
Subject: [DRAFT 2/2] mm/hugetlb: Restrict HugeTLB allocations only to the system RAM nodes
Date: Thu, 17 Nov 2016 13:29:09 +0530 [thread overview]
Message-ID: <1479369549-13309-2-git-send-email-khandual@linux.vnet.ibm.com> (raw)
In-Reply-To: <1479369549-13309-1-git-send-email-khandual@linux.vnet.ibm.com>
HugeTLB allocation/release/accounting currently spans across all the nodes
under N_MEMORY mask. CDM nodes should not be part of these. So use
system_ram() call to fetch system RAM only nodes on the platform which can
then be used for HugeTLB purpose instead of N_MEMORY. This isolates CDM
nodes from HugeTLB allocation.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
This also completely isolates CDM nodes from user space HugeTLB allocations
. Hence explicit allocation to the CDM nodes would not be possible any more
. To again enable explicit HugeTLB allocation capability from user space,
HugeTLB subsystem needs to be changed.
mm/hugetlb.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 418bf01..1936c5a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1782,6 +1782,9 @@ static void return_unused_surplus_pages(struct hstate *h,
unsigned long unused_resv_pages)
{
unsigned long nr_pages;
+ nodemask_t nodes;
+
+ nodes = system_ram();
/* Uncommit the reservation */
h->resv_huge_pages -= unused_resv_pages;
@@ -1801,7 +1804,7 @@ static void return_unused_surplus_pages(struct hstate *h,
* on-line nodes with memory and will handle the hstate accounting.
*/
while (nr_pages--) {
- if (!free_pool_huge_page(h, &node_states[N_MEMORY], 1))
+ if (!free_pool_huge_page(h, &nodes, 1))
break;
cond_resched_lock(&hugetlb_lock);
}
@@ -2088,8 +2091,10 @@ int __weak alloc_bootmem_huge_page(struct hstate *h)
{
struct huge_bootmem_page *m;
int nr_nodes, node;
+ nodemask_t nodes;
- for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) {
+ nodes = system_ram();
+ for_each_node_mask_to_alloc(h, nr_nodes, node, &nodes) {
void *addr;
addr = memblock_virt_alloc_try_nid_nopanic(
@@ -2158,13 +2163,15 @@ static void __init gather_bootmem_prealloc(void)
static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
{
unsigned long i;
+ nodemask_t nodes;
+
+ nodes = system_ram();
for (i = 0; i < h->max_huge_pages; ++i) {
if (hstate_is_gigantic(h)) {
if (!alloc_bootmem_huge_page(h))
break;
- } else if (!alloc_fresh_huge_page(h,
- &node_states[N_MEMORY]))
+ } else if (!alloc_fresh_huge_page(h, &nodes))
break;
}
h->max_huge_pages = i;
@@ -2401,8 +2408,11 @@ static ssize_t __nr_hugepages_store_common(bool obey_mempolicy,
unsigned long count, size_t len)
{
int err;
+ nodemask_t ram_nodes;
+
NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
+ ram_nodes = system_ram();
if (hstate_is_gigantic(h) && !gigantic_page_supported()) {
err = -EINVAL;
goto out;
@@ -2415,7 +2425,7 @@ static ssize_t __nr_hugepages_store_common(bool obey_mempolicy,
if (!(obey_mempolicy &&
init_nodemask_of_mempolicy(nodes_allowed))) {
NODEMASK_FREE(nodes_allowed);
- nodes_allowed = &node_states[N_MEMORY];
+ nodes_allowed = &ram_nodes;
}
} else if (nodes_allowed) {
/*
@@ -2425,11 +2435,11 @@ static ssize_t __nr_hugepages_store_common(bool obey_mempolicy,
count += h->nr_huge_pages - h->nr_huge_pages_node[nid];
init_nodemask_of_node(nodes_allowed, nid);
} else
- nodes_allowed = &node_states[N_MEMORY];
+ nodes_allowed = &ram_nodes;
h->max_huge_pages = set_max_huge_pages(h, count, nodes_allowed);
- if (nodes_allowed != &node_states[N_MEMORY])
+ if (nodes_allowed != &ram_nodes)
NODEMASK_FREE(nodes_allowed);
return len;
@@ -2726,9 +2736,11 @@ static void hugetlb_register_node(struct node *node)
*/
static void __init hugetlb_register_all_nodes(void)
{
+ nodemask_t nodes;
int nid;
- for_each_node_state(nid, N_MEMORY) {
+ nodes = system_ram();
+ for_each_node_mask(nid, nodes) {
struct node *node = node_devices[nid];
if (node->dev.id == nid)
hugetlb_register_node(node);
@@ -2998,13 +3010,15 @@ int hugetlb_report_node_meminfo(int nid, char *buf)
void hugetlb_show_meminfo(void)
{
+ nodemask_t nodes;
struct hstate *h;
int nid;
if (!hugepages_supported())
return;
- for_each_node_state(nid, N_MEMORY)
+ nodes = system_ram();
+ for_each_node_mask(nid, nodes)
for_each_hstate(h)
pr_info("Node %d hugepages_total=%u hugepages_free=%u hugepages_surp=%u hugepages_size=%lukB\n",
nid,
--
1.8.3.1
next prev parent reply other threads:[~2016-11-17 7:59 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 4:31 [RFC 0/8] Define coherent device memory node Anshuman Khandual
2016-10-24 4:31 ` [RFC 1/8] mm: " Anshuman Khandual
2016-10-24 17:09 ` Dave Hansen
2016-10-25 1:22 ` Anshuman Khandual
2016-10-25 15:47 ` Dave Hansen
2016-10-24 4:31 ` [RFC 2/8] mm: Add specialized fallback zonelist for coherent device memory nodes Anshuman Khandual
2016-10-24 17:10 ` Dave Hansen
2016-10-25 1:27 ` Anshuman Khandual
2016-11-17 7:40 ` Anshuman Khandual
2016-11-17 7:59 ` [DRAFT 1/2] mm/cpuset: Exclude CDM nodes from each task's mems_allowed node mask Anshuman Khandual
2016-11-17 7:59 ` Anshuman Khandual [this message]
2016-11-17 8:28 ` kbuild test robot
2016-10-24 4:31 ` [RFC 3/8] mm: Isolate coherent device memory nodes from HugeTLB allocation paths Anshuman Khandual
2016-10-24 17:16 ` Dave Hansen
2016-10-25 4:15 ` Aneesh Kumar K.V
2016-10-25 7:17 ` Balbir Singh
2016-10-25 7:25 ` Balbir Singh
2016-10-24 4:31 ` [RFC 4/8] mm: Accommodate coherent device memory nodes in MPOL_BIND implementation Anshuman Khandual
2016-10-24 4:31 ` [RFC 5/8] mm: Add new flag VM_CDM for coherent device memory Anshuman Khandual
2016-10-24 17:38 ` Dave Hansen
2016-10-24 18:00 ` Dave Hansen
2016-10-25 12:36 ` Balbir Singh
2016-10-25 19:20 ` Aneesh Kumar K.V
2016-10-25 20:01 ` Dave Hansen
2016-10-24 4:31 ` [RFC 6/8] mm: Make VM_CDM marked VMAs non migratable Anshuman Khandual
2016-10-24 4:31 ` [RFC 7/8] mm: Add a new migration function migrate_virtual_range() Anshuman Khandual
2016-10-24 4:31 ` [RFC 8/8] mm: Add N_COHERENT_DEVICE node type into node_states[] Anshuman Khandual
2016-10-25 7:22 ` Balbir Singh
2016-10-26 4:52 ` Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 00/10] Test and debug patches for coherent device memory Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 01/10] dt-bindings: Add doc for ibm,hotplug-aperture Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 02/10] powerpc/mm: Create numa nodes for hotplug memory Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 03/10] powerpc/mm: Allow memory hotplug into a memory less node Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 04/10] mm: Enable CONFIG_MOVABLE_NODE on powerpc Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 05/10] powerpc/mm: Identify isolation seeking coherent memory nodes during boot Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 06/10] mm: Export definition of 'zone_names' array through mmzone.h Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 07/10] mm: Add debugfs interface to dump each node's zonelist information Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 08/10] powerpc: Enable CONFIG_MOVABLE_NODE for PPC64 platform Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 09/10] drivers: Add two drivers for coherent device memory tests Anshuman Khandual
2016-10-24 4:42 ` [DEBUG 10/10] test: Add a script to perform random VMA migrations across nodes Anshuman Khandual
2016-10-24 17:09 ` [RFC 0/8] Define coherent device memory node Jerome Glisse
2016-10-25 4:26 ` Aneesh Kumar K.V
2016-10-25 15:16 ` Jerome Glisse
2016-10-26 11:09 ` Aneesh Kumar K.V
2016-10-26 16:07 ` Jerome Glisse
2016-10-28 5:29 ` Aneesh Kumar K.V
2016-10-28 16:16 ` Jerome Glisse
2016-11-05 5:21 ` Anshuman Khandual
2016-11-05 18:02 ` Jerome Glisse
2016-10-25 4:59 ` Aneesh Kumar K.V
2016-10-25 15:32 ` Jerome Glisse
2016-10-25 17:31 ` Aneesh Kumar K.V
2016-10-25 18:52 ` Jerome Glisse
2016-10-26 11:13 ` Anshuman Khandual
2016-10-26 16:02 ` Jerome Glisse
2016-10-27 4:38 ` Anshuman Khandual
2016-10-27 7:03 ` Anshuman Khandual
2016-10-27 15:05 ` Jerome Glisse
2016-10-28 5:47 ` Anshuman Khandual
2016-10-28 16:08 ` Jerome Glisse
2016-10-26 12:56 ` Anshuman Khandual
2016-10-26 16:28 ` Jerome Glisse
2016-10-27 10:23 ` Balbir Singh
2016-10-25 12:07 ` Balbir Singh
2016-10-25 15:21 ` Jerome Glisse
2016-10-24 18:04 ` Dave Hansen
2016-10-24 18:32 ` David Nellans
2016-10-24 19:36 ` Dave Hansen
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=1479369549-13309-2-git-send-email-khandual@linux.vnet.ibm.com \
--to=khandual@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=bsingharora@gmail.com \
--cc=js1304@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=vbabka@suse.cz \
/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).