linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Zi Yan" <zi.yan@cs.rutgers.edu>
To: Michal Hocko <mhocko@kernel.org>
Cc: "Naoya Horiguchi" <n-horiguchi@ah.jp.nec.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	"Andrea Reale" <ar@linux.vnet.ibm.com>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mm: migrate: fix an incorrect call of prep_transhuge_page()
Date: Wed, 22 Nov 2017 04:18:35 -0500	[thread overview]
Message-ID: <26CA724E-070E-4D06-B75E-F1880B1F2CF9@cs.rutgers.edu> (raw)
In-Reply-To: <20171122085416.ycrvahu2bznlx37s@dhcp22.suse.cz>

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

On 22 Nov 2017, at 3:54, Michal Hocko wrote:

> On Mon 20-11-17 21:18:55, Zi Yan wrote:
>> From: Zi Yan <zi.yan@cs.rutgers.edu>
>>
>> In [1], Andrea reported that during memory hotplug/hot remove
>> prep_transhuge_page() is called incorrectly on non-THP pages for
>> migration, when THP is on but THP migration is not enabled.
>> This leads to a bad state of target pages for migration.
>>
>> This patch fixes it by only calling prep_transhuge_page() when we are
>> certain that the target page is THP.
>>
>> [1] https://lkml.org/lkml/2017/11/20/411
>
> lkml.org tends to be quite unstable so a
> http://lkml.kernel.org/r/$msg-id is usually a preferred way.

Got it. Thanks.

>
>>
>> Cc: stable@vger.kernel.org # v4.14
>> Fixes: 8135d8926c08 ("mm: memory_hotplug: memory hotremove supports thp migration")
>> Reported-by: Andrea Reale <ar@linux.vnet.ibm.com>
>> Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
>> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
>> Cc: "Jérôme Glisse" <jglisse@redhat.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 895ec0c4942e..a2246cf670ba 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);
>
> I would keep the two checks consistent. But that leads to a more
> interesting question. new_page_nodemask does
>
> 	if (thp_migration_supported() && PageTransHuge(page)) {
> 		order = HPAGE_PMD_ORDER;
> 		gfp_mask |= GFP_TRANSHUGE;
> 	}
>
> How come it is safe to allocate an order-0 page if
> !thp_migration_supported() when we are about to migrate THP? This
> doesn't make any sense to me. Are we working around this somewhere else?
> Why shouldn't we simply return NULL here?

If !thp_migration_supported(), we will first split a THP and migrate its head page. This process
is done in unmap_and_move() after get_new_page() (the function pointer to this new_page_nodemask())
is called. The situation can be PageTransHuge(page) is true here, but the page is split
in unmap_and_move(), so we want to return a order-0 page here.

I think the confusion comes from that there is no guarantee of THP allocation when we are
doing THP migration. If we can allocate a THP during THP migration, we are good. Otherwise, we want to
fallback to the old way, splitting the original THP and migrating the head page, to preserve
the original code behavior.

Does it clarify your confusion?


—
Best Regards,
Yan Zi

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

  reply	other threads:[~2017-11-22  9:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  2:18 Zi Yan
2017-11-21 22:12 ` Andrew Morton
2017-11-21 22:35   ` Zi Yan
2017-11-22  9:43     ` Andrea Reale
2017-11-22  8:54 ` Michal Hocko
2017-11-22  9:18   ` Zi Yan [this message]
2017-11-22  9:35     ` Michal Hocko
2017-11-22 10:14       ` Michal Hocko
2017-11-22 12:13         ` Zi Yan
2017-11-22 12:29           ` Zi Yan
2017-11-22 13:01             ` Michal Hocko
2017-11-22 13:40   ` Michal Hocko
2017-11-22 14:43     ` Zi Yan
2017-11-22 14:53       ` Michal Hocko
2017-11-22 15:09         ` Zi Yan
2017-11-22 15:39           ` Michal Hocko

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=26CA724E-070E-4D06-B75E-F1880B1F2CF9@cs.rutgers.edu \
    --to=zi.yan@cs.rutgers.edu \
    --cc=akpm@linux-foundation.org \
    --cc=ar@linux.vnet.ibm.com \
    --cc=jglisse@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=stable@vger.kernel.org \
    /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