All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: Disable movable allocation for TRANSHUGE pages
@ 2018-09-25  7:25 Ashish Mhetre
  2018-09-25 11:51 ` Kirill A. Shutemov
  0 siblings, 1 reply; 5+ messages in thread
From: Ashish Mhetre @ 2018-09-25  7:25 UTC (permalink / raw)
  To: linux-mm, akpm; +Cc: amhetre, vdumpa, Snikam

TRANSHUGE pages have no migration support. Using CMA memory
for TRANSHUGE pages makes the memory reclaim not possible.
If TRANSHUGE pages are allocated as movable then the
allocations can come from CMA memory and make CMA reclaim fail.
To avoid this, disable movable page allocations for TRANSHUGE
pages.

Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
 mm/huge_memory.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 63edf18..bef509d 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -631,19 +631,26 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf,
  */
 static inline gfp_t alloc_hugepage_direct_gfpmask(struct vm_area_struct *vma)
 {
+	gfp_t gfp = GFP_TRANSHUGE_LIGHT;
 	const bool vma_madvised = !!(vma->vm_flags & VM_HUGEPAGE);
 
-	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags))
-		return GFP_TRANSHUGE | (vma_madvised ? 0 : __GFP_NORETRY);
-	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags))
-		return GFP_TRANSHUGE_LIGHT | __GFP_KSWAPD_RECLAIM;
-	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags))
-		return GFP_TRANSHUGE_LIGHT | (vma_madvised ? __GFP_DIRECT_RECLAIM :
-							     __GFP_KSWAPD_RECLAIM);
-	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags))
-		return GFP_TRANSHUGE_LIGHT | (vma_madvised ? __GFP_DIRECT_RECLAIM :
-							     0);
-	return GFP_TRANSHUGE_LIGHT;
+	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG,
+				&transparent_hugepage_flags))
+		gfp = GFP_TRANSHUGE | (vma_madvised ? 0 : __GFP_NORETRY);
+	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG,
+				&transparent_hugepage_flags))
+		gfp = GFP_TRANSHUGE_LIGHT | __GFP_KSWAPD_RECLAIM;
+	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG,
+					&transparent_hugepage_flags))
+		gfp = GFP_TRANSHUGE_LIGHT | (vma_madvised ?
+			__GFP_DIRECT_RECLAIM : __GFP_KSWAPD_RECLAIM);
+	if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG,
+					&transparent_hugepage_flags))
+		gfp = GFP_TRANSHUGE_LIGHT | (vma_madvised ?
+					__GFP_DIRECT_RECLAIM : 0);
+	gfp &= ~__GFP_MOVABLE;
+
+	return gfp;
 }
 
 /* Caller must hold page table lock. */
-- 
2.1.4


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: Disable movable allocation for TRANSHUGE pages
  2018-09-25  7:25 [PATCH] mm: Disable movable allocation for TRANSHUGE pages Ashish Mhetre
@ 2018-09-25 11:51 ` Kirill A. Shutemov
  2018-09-25 18:30   ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Kirill A. Shutemov @ 2018-09-25 11:51 UTC (permalink / raw)
  To: Ashish Mhetre; +Cc: linux-mm, akpm, vdumpa, Snikam

On Tue, Sep 25, 2018 at 12:55:33PM +0530, Ashish Mhetre wrote:
> TRANSHUGE pages have no migration support.

Transparent pages have migration support since v4.14.

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: Disable movable allocation for TRANSHUGE pages
  2018-09-25 11:51 ` Kirill A. Shutemov
@ 2018-09-25 18:30   ` Michal Hocko
  2018-09-25 21:00     ` Kirill A. Shutemov
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2018-09-25 18:30 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: Ashish Mhetre, linux-mm, akpm, vdumpa, Snikam

On Tue 25-09-18 14:51:53, Kirill A. Shutemov wrote:
> On Tue, Sep 25, 2018 at 12:55:33PM +0530, Ashish Mhetre wrote:
> > TRANSHUGE pages have no migration support.
> 
> Transparent pages have migration support since v4.14.

This is true but not for all architectures AFAICS. In fact git grep
suggests that only x86 supports the migration. So unless I am missing
something the patch has some merit. But the implementation is simply
wrong. If anything it should be something like

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 76f8db0b0e71..2aff77966d92 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -297,7 +297,14 @@ struct vm_area_struct;
 #define GFP_DMA32	__GFP_DMA32
 #define GFP_HIGHUSER	(GFP_USER | __GFP_HIGHMEM)
 #define GFP_HIGHUSER_MOVABLE	(GFP_HIGHUSER | __GFP_MOVABLE)
-#define GFP_TRANSHUGE_LIGHT	((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
+
+#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
+#define GFP_TRANSHUGE_MOVABLE __GFP_MOVABLE
+#else
+#define GFP_TRANSHUGE_MOVABLE 0
+#endif
+
+#define GFP_TRANSHUGE_LIGHT	((GFP_HIGHUSER |GFP_TRANSHUGE_MOVABLE | __GFP_COMP | \
 			 __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
 #define GFP_TRANSHUGE	(GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)
 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: Disable movable allocation for TRANSHUGE pages
  2018-09-25 18:30   ` Michal Hocko
@ 2018-09-25 21:00     ` Kirill A. Shutemov
  2018-09-25 21:11       ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Kirill A. Shutemov @ 2018-09-25 21:00 UTC (permalink / raw)
  To: Michal Hocko; +Cc: Ashish Mhetre, linux-mm, akpm, vdumpa, Snikam

On Tue, Sep 25, 2018 at 08:30:19PM +0200, Michal Hocko wrote:
> On Tue 25-09-18 14:51:53, Kirill A. Shutemov wrote:
> > On Tue, Sep 25, 2018 at 12:55:33PM +0530, Ashish Mhetre wrote:
> > > TRANSHUGE pages have no migration support.
> > 
> > Transparent pages have migration support since v4.14.
> 
> This is true but not for all architectures AFAICS. In fact git grep
> suggests that only x86 supports the migration. So unless I am missing
> something the patch has some merit.

THP pages are movable from the beginning. Before 4.14, the cost of
migration was THP split. From my PoV __GFP_MOVABLE is justified and we
should keep it there.

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm: Disable movable allocation for TRANSHUGE pages
  2018-09-25 21:00     ` Kirill A. Shutemov
@ 2018-09-25 21:11       ` Michal Hocko
  0 siblings, 0 replies; 5+ messages in thread
From: Michal Hocko @ 2018-09-25 21:11 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: Ashish Mhetre, linux-mm, akpm, vdumpa, Snikam

On Wed 26-09-18 00:00:02, Kirill A. Shutemov wrote:
> On Tue, Sep 25, 2018 at 08:30:19PM +0200, Michal Hocko wrote:
> > On Tue 25-09-18 14:51:53, Kirill A. Shutemov wrote:
> > > On Tue, Sep 25, 2018 at 12:55:33PM +0530, Ashish Mhetre wrote:
> > > > TRANSHUGE pages have no migration support.
> > > 
> > > Transparent pages have migration support since v4.14.
> > 
> > This is true but not for all architectures AFAICS. In fact git grep
> > suggests that only x86 supports the migration. So unless I am missing
> > something the patch has some merit.
> 
> THP pages are movable from the beginning. Before 4.14, the cost of
> migration was THP split. From my PoV __GFP_MOVABLE is justified and we
> should keep it there.

A very good point! I haven't really looked closer to what happens in the
cma/migration code when the migration is not supported. As you've said
THP migt be split into 4kB pages and those are migrateable by
definition. So I take back my proposal and if this doesn't work properly
now then it should really be handled by splitting up the thp.

Thanks and sorry I've missed this!
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-25 21:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25  7:25 [PATCH] mm: Disable movable allocation for TRANSHUGE pages Ashish Mhetre
2018-09-25 11:51 ` Kirill A. Shutemov
2018-09-25 18:30   ` Michal Hocko
2018-09-25 21:00     ` Kirill A. Shutemov
2018-09-25 21:11       ` Michal Hocko

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.