From: Anshuman Khandual <anshuman.khandual@arm.com>
To: linux-mm@kvack.org
Cc: Anshuman Khandual <anshuman.khandual@arm.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH V2 1/2] mm/hugetlb: Make alloc_gigantic_page() available for general use
Date: Thu, 12 Sep 2019 11:32:52 +0530 [thread overview]
Message-ID: <1568268173-31302-2-git-send-email-anshuman.khandual@arm.com> (raw)
In-Reply-To: <1568268173-31302-1-git-send-email-anshuman.khandual@arm.com>
alloc_gigantic_page() implements an allocation method where it scans over
various zones looking for a large contiguous memory block which could not
have been allocated through the buddy allocator. A subsequent patch which
tests arch page table helpers needs such a method to allocate PUD_SIZE
sized memory block. In the future such methods might have other use cases
as well. So alloc_gigantic_page() has been split carving out actual memory
allocation method and made available via new alloc_gigantic_page_order().
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
Should we move alloc_gigantic_page_order() to page_alloc.c and declarations
to include/linux/gfp.h instead ? This is still very much HugeTLB specific.
include/linux/hugetlb.h | 9 +++++++++
mm/hugetlb.c | 24 ++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 53fc34f930d0..cc50d5ad4885 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -299,6 +299,9 @@ static inline bool is_file_hugepages(struct file *file)
}
+struct page *
+alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask,
+ int nid, nodemask_t *nodemask);
#else /* !CONFIG_HUGETLBFS */
#define is_file_hugepages(file) false
@@ -310,6 +313,12 @@ hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
return ERR_PTR(-ENOSYS);
}
+static inline struct page *
+alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask,
+ int nid, nodemask_t *nodemask)
+{
+ return NULL;
+}
#endif /* !CONFIG_HUGETLBFS */
#ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ef37c85423a5..3fb81252f52b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1112,10 +1112,9 @@ static bool zone_spans_last_pfn(const struct zone *zone,
return zone_spans_pfn(zone, last_pfn);
}
-static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
+struct page *alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask,
int nid, nodemask_t *nodemask)
{
- unsigned int order = huge_page_order(h);
unsigned long nr_pages = 1 << order;
unsigned long ret, pfn, flags;
struct zonelist *zonelist;
@@ -1151,6 +1150,14 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
return NULL;
}
+static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
+ int nid, nodemask_t *nodemask)
+{
+ unsigned int order = huge_page_order(h);
+
+ return alloc_gigantic_page_order(order, gfp_mask, nid, nodemask);
+}
+
static void prep_new_huge_page(struct hstate *h, struct page *page, int nid);
static void prep_compound_gigantic_page(struct page *page, unsigned int order);
#else /* !CONFIG_CONTIG_ALLOC */
@@ -1159,6 +1166,12 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
{
return NULL;
}
+
+struct page *alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask,
+ int nid, nodemask_t *nodemask)
+{
+ return NULL;
+}
#endif /* CONFIG_CONTIG_ALLOC */
#else /* !CONFIG_ARCH_HAS_GIGANTIC_PAGE */
@@ -1167,6 +1180,13 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
{
return NULL;
}
+
+struct page *alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask,
+ int nid, nodemask_t *nodemask)
+{
+ return NULL;
+}
+
static inline void free_gigantic_page(struct page *page, unsigned int order) { }
static inline void destroy_compound_gigantic_page(struct page *page,
unsigned int order) { }
--
2.20.1
next prev parent reply other threads:[~2019-09-12 6:03 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 6:02 [PATCH V2 0/2] mm/debug: Add tests for architecture exported page table helpers Anshuman Khandual
2019-09-12 6:02 ` Anshuman Khandual [this message]
2019-09-12 6:02 ` [PATCH V2 2/2] mm/pgtable/debug: Add test validating architecture " Anshuman Khandual
2019-09-12 11:00 ` Kirill A. Shutemov
2019-09-12 12:09 ` Anshuman Khandual
2019-09-12 15:00 ` Christophe Leroy
2019-09-12 15:36 ` Christophe Leroy
2019-09-12 15:52 ` Christophe Leroy
2019-09-13 6:30 ` Christophe Leroy
2019-09-12 17:14 ` Christophe Leroy
2019-09-13 6:23 ` [PATCH] mm/pgtable/debug: Fix " Christophe Leroy
2019-09-13 6:58 ` Anshuman Khandual
2019-09-13 7:03 ` Christophe Leroy
2019-09-13 7:11 ` Christophe Leroy
2019-09-13 8:42 ` Anshuman Khandual
2019-09-13 8:51 ` Kirill A. Shutemov
2019-09-18 7:32 ` Anshuman Khandual
2019-09-19 5:44 ` Christophe Leroy
2019-09-13 9:02 ` [PATCH V2 2/2] mm/pgtable/debug: Add " Anshuman Khandual
2019-09-13 9:13 ` Kirill A. Shutemov
2019-09-13 10:01 ` Christophe Leroy
2019-09-18 5:04 ` Anshuman Khandual
2019-09-18 16:26 ` Christophe Leroy
2019-09-18 18:22 ` Gerald Schaefer
2019-09-20 4:06 ` Anshuman Khandual
2019-09-19 4:56 ` Anshuman Khandual
2019-09-19 5:41 ` Christophe Leroy
2019-09-12 14:42 ` [PATCH V2 0/2] mm/debug: Add tests for architecture exported " Christophe Leroy
2019-09-13 6:24 ` Anshuman Khandual
2019-09-13 6:32 ` Christophe Leroy
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=1568268173-31302-2-git-send-email-anshuman.khandual@arm.com \
--to=anshuman.khandual@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.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).