Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1325744 > unrolled thread

[PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages

Started byVlastimil Babka <vbabka@suse.cz>
First post2016-02-03 19:00 +0100
Last post2016-02-05 13:10 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages Vlastimil Babka <vbabka@suse.cz> - 2016-02-03 19:00 +0100
    Re: [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-02-04 07:10 +0100
      Re: [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages Vlastimil Babka <vbabka@suse.cz> - 2016-02-04 10:40 +0100
        Re: [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages Vlastimil Babka <vbabka@suse.cz> - 2016-02-04 11:20 +0100
          Re: [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-02-05 01:20 +0100
            Re: [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages Vlastimil Babka <vbabka@suse.cz> - 2016-02-05 13:10 +0100

#1325744 — [PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages

FromVlastimil Babka <vbabka@suse.cz>
Date2016-02-03 19:00 +0100
Subject[PATCH] mm, hugetlb: don't require CMA for runtime gigantic pages
Message-ID<qY9SG-58b-17@gated-at.bofh.it>
Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
runtime") has added the runtime gigantic page allocation via
alloc_contig_range(), making this support available only when CONFIG_CMA is
enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
associated infrastructure, it is possible with few simple adjustments to
require only CONFIG_MEMORY_ISOLATION instead of full CONFIG_CMA.

After this patch, alloc_contig_range() and related functions are available
and used for gigantic pages with just CONFIG_MEMORY_ISOLATION enabled. Note
CONFIG_CMA selects CONFIG_MEMORY_ISOLATION. This allows supporting runtime
gigantic pages without the CMA-specific checks in page allocator fastpaths.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
---
 include/linux/gfp.h | 6 +++---
 mm/hugetlb.c        | 2 +-
 mm/page_alloc.c     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 8942af0813e3..752bb6259218 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -539,16 +539,16 @@ static inline bool pm_suspended_storage(void)
 }
 #endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_CMA
-
+#ifdef CONFIG_MEMORY_ISOLATION
 /* The below functions must be run on a range from a single zone. */
 extern int alloc_contig_range(unsigned long start, unsigned long end,
 			      unsigned migratetype);
 extern void free_contig_range(unsigned long pfn, unsigned nr_pages);
+#endif
 
+#ifdef CONFIG_CMA
 /* CMA stuff */
 extern void init_cma_reserved_pageblock(struct page *page);
-
 #endif
 
 #endif /* __LINUX_GFP_H */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ef6963b577fd..66529a1c7929 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1002,7 +1002,7 @@ static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed)
 		((node = hstate_next_node_to_free(hs, mask)) || 1);	\
 		nr_nodes--)
 
-#if defined(CONFIG_CMA) && defined(CONFIG_X86_64)
+#if defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_X86_64)
 static void destroy_compound_gigantic_page(struct page *page,
 					unsigned int order)
 {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9d666df5ef95..29c530cdd7f4 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6599,7 +6599,7 @@ bool is_pageblock_removable_nolock(struct page *page)
 	return !has_unmovable_pages(zone, page, 0, true);
 }
 
-#ifdef CONFIG_CMA
+#ifdef CONFIG_MEMORY_ISOLATION
 
 static unsigned long pfn_max_align_down(unsigned long pfn)
 {
-- 
2.7.0

[toc] | [next] | [standalone]


#1326427

FromJoonsoo Kim <iamjoonsoo.kim@lge.com>
Date2016-02-04 07:10 +0100
Message-ID<qYlh9-4Ml-11@gated-at.bofh.it>
In reply to#1325744
On Wed, Feb 03, 2016 at 06:50:11PM +0100, Vlastimil Babka wrote:
> Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
> runtime") has added the runtime gigantic page allocation via
> alloc_contig_range(), making this support available only when CONFIG_CMA is
> enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
> associated infrastructure, it is possible with few simple adjustments to
> require only CONFIG_MEMORY_ISOLATION instead of full CONFIG_CMA.
> 
> After this patch, alloc_contig_range() and related functions are available
> and used for gigantic pages with just CONFIG_MEMORY_ISOLATION enabled. Note
> CONFIG_CMA selects CONFIG_MEMORY_ISOLATION. This allows supporting runtime
> gigantic pages without the CMA-specific checks in page allocator fastpaths.

You need to set CONFIG_COMPACTION or CONFIG_CMA to use
isolate_migratepages_range() and others in alloc_contig_range().

Thanks.

[toc] | [prev] | [next] | [standalone]


#1326517

FromVlastimil Babka <vbabka@suse.cz>
Date2016-02-04 10:40 +0100
Message-ID<qYoym-6KS-5@gated-at.bofh.it>
In reply to#1326427
On 02/04/2016 07:02 AM, Joonsoo Kim wrote:
> On Wed, Feb 03, 2016 at 06:50:11PM +0100, Vlastimil Babka wrote:
>> Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
>> runtime") has added the runtime gigantic page allocation via
>> alloc_contig_range(), making this support available only when CONFIG_CMA is
>> enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
>> associated infrastructure, it is possible with few simple adjustments to
>> require only CONFIG_MEMORY_ISOLATION instead of full CONFIG_CMA.
>>
>> After this patch, alloc_contig_range() and related functions are available
>> and used for gigantic pages with just CONFIG_MEMORY_ISOLATION enabled. Note
>> CONFIG_CMA selects CONFIG_MEMORY_ISOLATION. This allows supporting runtime
>> gigantic pages without the CMA-specific checks in page allocator fastpaths.
>
> You need to set CONFIG_COMPACTION or CONFIG_CMA to use
> isolate_migratepages_range() and others in alloc_contig_range().

Hm, right, thanks for catching this. I admit I didn't try disabling 
compaction during the tests.

> Thanks.
>

[toc] | [prev] | [next] | [standalone]


#1326563

FromVlastimil Babka <vbabka@suse.cz>
Date2016-02-04 11:20 +0100
Message-ID<qYpb4-7ep-9@gated-at.bofh.it>
In reply to#1326517
On 02/04/2016 10:30 AM, Vlastimil Babka wrote:
> On 02/04/2016 07:02 AM, Joonsoo Kim wrote:
>> On Wed, Feb 03, 2016 at 06:50:11PM +0100, Vlastimil Babka wrote:
>>> Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
>>> runtime") has added the runtime gigantic page allocation via
>>> alloc_contig_range(), making this support available only when CONFIG_CMA is
>>> enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
>>> associated infrastructure, it is possible with few simple adjustments to
>>> require only CONFIG_MEMORY_ISOLATION instead of full CONFIG_CMA.
>>>
>>> After this patch, alloc_contig_range() and related functions are available
>>> and used for gigantic pages with just CONFIG_MEMORY_ISOLATION enabled. Note
>>> CONFIG_CMA selects CONFIG_MEMORY_ISOLATION. This allows supporting runtime
>>> gigantic pages without the CMA-specific checks in page allocator fastpaths.
>>
>> You need to set CONFIG_COMPACTION or CONFIG_CMA to use
>> isolate_migratepages_range() and others in alloc_contig_range().
> 
> Hm, right, thanks for catching this. I admit I didn't try disabling
> compaction during the tests.

Here's a v2. Not the prettiest thing, admittedly.

----8<----
From: Vlastimil Babka <vbabka@suse.cz>
Date: Wed, 3 Feb 2016 17:45:26 +0100
Subject: [PATCH v2] mm, hugetlb: don't require CMA for runtime gigantic pages

Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
runtime") has added the runtime gigantic page allocation via
alloc_contig_range(), making this support available only when CONFIG_CMA is
enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
associated infrastructure, it is possible with few simple adjustments to
require only CONFIG_MEMORY_ISOLATION and CONFIG_COMPACTION instead of full
CONFIG_CMA.

After this patch, alloc_contig_range() and related functions are available
and used for gigantic pages with just CONFIG_MEMORY_ISOLATION and
CONFIG_COMPACTION enabled (or CONFIG_CMA as before). Note CONFIG_CMA selects
CONFIG_MEMORY_ISOLATION. This allows supporting runtime gigantic pages without
the CMA-specific checks in page allocator fastpaths.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
---
 include/linux/gfp.h | 6 +++---
 mm/hugetlb.c        | 2 +-
 mm/page_alloc.c     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 8942af0813e3..4cb589ae6c4b 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -539,16 +539,16 @@ static inline bool pm_suspended_storage(void)
 }
 #endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_CMA
-
+#if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA)
 /* The below functions must be run on a range from a single zone. */
 extern int alloc_contig_range(unsigned long start, unsigned long end,
 			      unsigned migratetype);
 extern void free_contig_range(unsigned long pfn, unsigned nr_pages);
+#endif
 
+#ifdef CONFIG_CMA
 /* CMA stuff */
 extern void init_cma_reserved_pageblock(struct page *page);
-
 #endif
 
 #endif /* __LINUX_GFP_H */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ef6963b577fd..50700ec80009 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1002,7 +1002,7 @@ static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed)
 		((node = hstate_next_node_to_free(hs, mask)) || 1);	\
 		nr_nodes--)
 
-#if defined(CONFIG_CMA) && defined(CONFIG_X86_64)
+#if defined(CONFIG_X86_64) && ((defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA))
 static void destroy_compound_gigantic_page(struct page *page,
 					unsigned int order)
 {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9d666df5ef95..5fcfac52ca5a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6599,7 +6599,7 @@ bool is_pageblock_removable_nolock(struct page *page)
 	return !has_unmovable_pages(zone, page, 0, true);
 }
 
-#ifdef CONFIG_CMA
+#if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA)
 
 static unsigned long pfn_max_align_down(unsigned long pfn)
 {
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1327372

From"Kirill A. Shutemov" <kirill@shutemov.name>
Date2016-02-05 01:20 +0100
Message-ID<qYChZ-XM-21@gated-at.bofh.it>
In reply to#1326563
On Thu, Feb 04, 2016 at 11:15:48AM +0100, Vlastimil Babka wrote:
> On 02/04/2016 10:30 AM, Vlastimil Babka wrote:
> > On 02/04/2016 07:02 AM, Joonsoo Kim wrote:
> >> On Wed, Feb 03, 2016 at 06:50:11PM +0100, Vlastimil Babka wrote:
> >>> Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
> >>> runtime") has added the runtime gigantic page allocation via
> >>> alloc_contig_range(), making this support available only when CONFIG_CMA is
> >>> enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
> >>> associated infrastructure, it is possible with few simple adjustments to
> >>> require only CONFIG_MEMORY_ISOLATION instead of full CONFIG_CMA.
> >>>
> >>> After this patch, alloc_contig_range() and related functions are available
> >>> and used for gigantic pages with just CONFIG_MEMORY_ISOLATION enabled. Note
> >>> CONFIG_CMA selects CONFIG_MEMORY_ISOLATION. This allows supporting runtime
> >>> gigantic pages without the CMA-specific checks in page allocator fastpaths.
> >>
> >> You need to set CONFIG_COMPACTION or CONFIG_CMA to use
> >> isolate_migratepages_range() and others in alloc_contig_range().
> > 
> > Hm, right, thanks for catching this. I admit I didn't try disabling
> > compaction during the tests.
> 
> Here's a v2. Not the prettiest thing, admittedly.
> 
> ----8<----
> From: Vlastimil Babka <vbabka@suse.cz>
> Date: Wed, 3 Feb 2016 17:45:26 +0100
> Subject: [PATCH v2] mm, hugetlb: don't require CMA for runtime gigantic pages
> 
> Commit 944d9fec8d7a ("hugetlb: add support for gigantic page allocation at
> runtime") has added the runtime gigantic page allocation via
> alloc_contig_range(), making this support available only when CONFIG_CMA is
> enabled. Because it doesn't depend on MIGRATE_CMA pageblocks and the
> associated infrastructure, it is possible with few simple adjustments to
> require only CONFIG_MEMORY_ISOLATION and CONFIG_COMPACTION instead of full
> CONFIG_CMA.
> 
> After this patch, alloc_contig_range() and related functions are available
> and used for gigantic pages with just CONFIG_MEMORY_ISOLATION and
> CONFIG_COMPACTION enabled (or CONFIG_CMA as before). Note CONFIG_CMA selects
> CONFIG_MEMORY_ISOLATION. This allows supporting runtime gigantic pages without
> the CMA-specific checks in page allocator fastpaths.
> 
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Luiz Capitulino <lcapitulino@redhat.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: Mel Gorman <mgorman@techsingularity.net>
> Cc: Davidlohr Bueso <dave@stgolabs.net>
> Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> ---
>  include/linux/gfp.h | 6 +++---
>  mm/hugetlb.c        | 2 +-
>  mm/page_alloc.c     | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)

One more place missed: gigantic_pages_init() in arch/x86/mm/hugetlbpage.c
Could you relax the check there as well?

-- 
 Kirill A. Shutemov

[toc] | [prev] | [next] | [standalone]


#1327625

FromVlastimil Babka <vbabka@suse.cz>
Date2016-02-05 13:10 +0100
Message-ID<qYNn4-8os-11@gated-at.bofh.it>
In reply to#1327372
On 02/05/2016 01:14 AM, Kirill A. Shutemov wrote:
>>  include/linux/gfp.h | 6 +++---
>>  mm/hugetlb.c        | 2 +-
>>  mm/page_alloc.c     | 2 +-
>>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> One more place missed: gigantic_pages_init() in arch/x86/mm/hugetlbpage.c
> Could you relax the check there as well?

Crap, thanks. This file was hidden in different commit and didn't cause
compilation failure. Patch below, tested that 1gb pages are available
with COMPACTION+ISOLATION.

----8<----
From: Vlastimil Babka <vbabka@suse.cz>
Date: Fri, 5 Feb 2016 10:59:38 +0100
Subject: [PATCH 2/2] 
 mm-hugetlb-dont-require-cma-for-runtime-gigantic-pages-fix2

Update also arch-specific code as Kirill pointed out.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 arch/x86/mm/hugetlbpage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 42982b26e32b..740d7ac03a55 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -173,10 +173,10 @@ static __init int setup_hugepagesz(char *opt)
 }
 __setup("hugepagesz=", setup_hugepagesz);
 
-#ifdef CONFIG_CMA
+#if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA)
 static __init int gigantic_pages_init(void)
 {
-	/* With CMA we can allocate gigantic pages at runtime */
+	/* With compaction or CMA we can allocate gigantic pages at runtime */
 	if (cpu_has_gbpages && !size_to_hstate(1UL << PUD_SHIFT))
 		hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
 	return 0;
-- 
2.7.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web