linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] mm/migrate: do not call prep_transhuge_page if !thp_migration_supported
@ 2017-11-20 16:17 Andrea Reale
  2017-11-20 16:17 ` [PATCH 1/1] " Andrea Reale
  0 siblings, 1 reply; 4+ messages in thread
From: Andrea Reale @ 2017-11-20 16:17 UTC (permalink / raw)
  To: linux-kernel, zi.yan, n-horiguchi; +Cc: akpm, jglisse, realean2

Hi all,

While working on a second round of patches to introduce memory hotplug /
hot remove to arm64 (original attempt at [1]), and trying to rebase them
on 4.14, I stumbled in some problematic behaviour during page migration
when offlining for hot remove, whereas target pages for migration where
found in a bad state.

I believe that this behaviour may be originating from commit 8135d8926c08
("mm: memory_hotplug: memory hotremove supports thp migration")
and it is triggered when migrating pages for builds that have no
ARCH_ENABLE_THP_MIGRATION but have thp support on (arm64, in my case).
Specifically, my understanding is that prep_transhuge_page should not be
called in linux/migrate.h:new_page_nodemask if !thp_migration_supported
because, in that case, new_page would not be a thp.

A tiny patch follows, showing what I mean. Please, let me know if my
understanding is bogus.

Best regards,
Andrea

[1] https://lkml.org/lkml/2017/4/11/536

Andrea Reale (1):
  mm/migrate: do not call prep_transhuge_page if
    !thp_migration_supported

 include/linux/migrate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.7.4

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

* [PATCH 1/1] mm/migrate: do not call prep_transhuge_page if !thp_migration_supported
  2017-11-20 16:17 [PATCH 0/1] mm/migrate: do not call prep_transhuge_page if !thp_migration_supported Andrea Reale
@ 2017-11-20 16:17 ` Andrea Reale
  2017-11-20 16:33   ` Zi Yan
  0 siblings, 1 reply; 4+ messages in thread
From: Andrea Reale @ 2017-11-20 16:17 UTC (permalink / raw)
  To: linux-kernel, zi.yan, n-horiguchi; +Cc: akpm, jglisse, realean2

new_page_nodemask in linux/migrate.h should not call prep_transhuge_page
if thp_migration_support is false.

Fixes commit 8135d8926c08 ("mm: memory_hotplug: memory hotremove supports
thp migration")

Signed-off-by: Andrea Reale <ar@linux.vnet.ibm.com>
---
 include/linux/migrate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 895ec0c..725eac5 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -54,7 +54,7 @@ static inline struct page *new_page_nodemask(struct page *page,
 	new_page = __alloc_pages_nodemask(gfp_mask, order,
 				preferred_nid, nodemask);
 
-	if (new_page && PageTransHuge(page))
+	if (thp_migration_supported() && new_page && PageTransHuge(page))
 		prep_transhuge_page(new_page);
 
 	return new_page;
-- 
2.7.4

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

* Re: [PATCH 1/1] mm/migrate: do not call prep_transhuge_page if !thp_migration_supported
  2017-11-20 16:17 ` [PATCH 1/1] " Andrea Reale
@ 2017-11-20 16:33   ` Zi Yan
  2017-11-20 17:07     ` Andrea Reale
  0 siblings, 1 reply; 4+ messages in thread
From: Zi Yan @ 2017-11-20 16:33 UTC (permalink / raw)
  To: Andrea Reale; +Cc: linux-kernel, n-horiguchi, akpm, jglisse, realean2

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

Hi Andrea,

Thanks for pointing this out.

I think the problem is that we should not prep_transhuge_page(new_page)
unless new_page is allocated and PageTransHuge(). And several lines above,
the allocation flags and the order is changed to make new_page a THP
only if thp_migration_supported() is true.

Does the patch below look better?

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 895ec0c..725eac5 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -54,7 +54,7 @@ static inline struct page *new_page_nodemask(struct page *page,
 	new_page = __alloc_pages_nodemask(gfp_mask, order,
 				preferred_nid, nodemask);

-	if (new_page && PageTransHuge(page))
+	if (new_page && PageTransHuge(new_page))
 		prep_transhuge_page(new_page);

 	return new_page;
-- 


--
Best Regards
Yan Zi

On 20 Nov 2017, at 11:17, Andrea Reale wrote:

> new_page_nodemask in linux/migrate.h should not call prep_transhuge_page
> if thp_migration_support is false.
>
> Fixes commit 8135d8926c08 ("mm: memory_hotplug: memory hotremove supports
> thp migration")
>
> Signed-off-by: Andrea Reale <ar@linux.vnet.ibm.com>
> ---
>  include/linux/migrate.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index 895ec0c..725eac5 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -54,7 +54,7 @@ static inline struct page *new_page_nodemask(struct page *page,
>  	new_page = __alloc_pages_nodemask(gfp_mask, order,
>  				preferred_nid, nodemask);
>
> -	if (new_page && PageTransHuge(page))
> +	if (thp_migration_supported() && new_page && PageTransHuge(page))
>  		prep_transhuge_page(new_page);
>
>  	return new_page;
> -- 
> 2.7.4

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 496 bytes --]

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

* Re: [PATCH 1/1] mm/migrate: do not call prep_transhuge_page if !thp_migration_supported
  2017-11-20 16:33   ` Zi Yan
@ 2017-11-20 17:07     ` Andrea Reale
  0 siblings, 0 replies; 4+ messages in thread
From: Andrea Reale @ 2017-11-20 17:07 UTC (permalink / raw)
  To: Zi Yan; +Cc: linux-kernel, n-horiguchi, akpm, jglisse, realean2

Hi Yan Zi,

thanks for the feedback. Yes, it looks definitely less redundant :)

Regards,
Andrea

On Mon, Nov 20, 2017 at 11:33:06AM -0500, Zi Yan wrote:
> Hi Andrea,
> 
> Thanks for pointing this out.
> 
> I think the problem is that we should not prep_transhuge_page(new_page)
> unless new_page is allocated and PageTransHuge(). And several lines above,
> the allocation flags and the order is changed to make new_page a THP
> only if thp_migration_supported() is true.
> 
> Does the patch below look better?
> 
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index 895ec0c..725eac5 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -54,7 +54,7 @@ static inline struct page *new_page_nodemask(struct page *page,
>  	new_page = __alloc_pages_nodemask(gfp_mask, order,
>  				preferred_nid, nodemask);
> 
> -	if (new_page && PageTransHuge(page))
> +	if (new_page && PageTransHuge(new_page))
>  		prep_transhuge_page(new_page);
> 
>  	return new_page;
> -- 
> 
> 
> --
> Best Regards
> Yan Zi
> 
> On 20 Nov 2017, at 11:17, Andrea Reale wrote:
> 
> > new_page_nodemask in linux/migrate.h should not call prep_transhuge_page
> > if thp_migration_support is false.
> >
> > Fixes commit 8135d8926c08 ("mm: memory_hotplug: memory hotremove supports
> > thp migration")
> >
> > Signed-off-by: Andrea Reale <ar@linux.vnet.ibm.com>
> > ---
> >  include/linux/migrate.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> > index 895ec0c..725eac5 100644
> > --- a/include/linux/migrate.h
> > +++ b/include/linux/migrate.h
> > @@ -54,7 +54,7 @@ static inline struct page *new_page_nodemask(struct page *page,
> >  	new_page = __alloc_pages_nodemask(gfp_mask, order,
> >  				preferred_nid, nodemask);
> >
> > -	if (new_page && PageTransHuge(page))
> > +	if (thp_migration_supported() && new_page && PageTransHuge(page))
> >  		prep_transhuge_page(new_page);
> >
> >  	return new_page;
> > -- 
> > 2.7.4

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

end of thread, other threads:[~2017-11-20 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-20 16:17 [PATCH 0/1] mm/migrate: do not call prep_transhuge_page if !thp_migration_supported Andrea Reale
2017-11-20 16:17 ` [PATCH 1/1] " Andrea Reale
2017-11-20 16:33   ` Zi Yan
2017-11-20 17:07     ` Andrea Reale

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).