linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Zi Yan <zi.yan@cs.rutgers.edu>
Cc: "kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"minchan@kernel.org" <minchan@kernel.org>,
	"vbabka@suse.cz" <vbabka@suse.cz>,
	"mgorman@techsingularity.net" <mgorman@techsingularity.net>,
	"mhocko@kernel.org" <mhocko@kernel.org>,
	"khandual@linux.vnet.ibm.com" <khandual@linux.vnet.ibm.com>,
	"dnellans@nvidia.com" <dnellans@nvidia.com>,
	"dave.hansen@intel.com" <dave.hansen@intel.com>
Subject: Re: [PATCH v8 05/10] mm: thp: enable thp migration in generic path
Date: Fri, 14 Jul 2017 00:06:42 +0000	[thread overview]
Message-ID: <20170714000641.GA6588@hori1.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <F7B0F5C1-F8ED-4029-87ED-F1757975E767@cs.rutgers.edu>

On Thu, Jul 13, 2017 at 07:28:24AM -0400, Zi Yan wrote:
> On 13 Jul 2017, at 5:30, Naoya Horiguchi wrote:
> 
> > On Tue, Jul 11, 2017 at 10:00:30AM -0400, Zi Yan wrote:
> >> On 11 Jul 2017, at 2:47, Naoya Horiguchi wrote:
> >>
> >>> On Sat, Jul 01, 2017 at 09:40:03AM -0400, Zi Yan wrote:
> >>>> From: Zi Yan <zi.yan@cs.rutgers.edu>
> >>>>
> >>>> This patch adds thp migration's core code, including conversions
> >>>> between a PMD entry and a swap entry, setting PMD migration entry,
> >>>> removing PMD migration entry, and waiting on PMD migration entries.
> >>>>
> >>>> This patch makes it possible to support thp migration.
> >>>> If you fail to allocate a destination page as a thp, you just split
> >>>> the source thp as we do now, and then enter the normal page migration.
> >>>> If you succeed to allocate destination thp, you enter thp migration.
> >>>> Subsequent patches actually enable thp migration for each caller of
> >>>> page migration by allowing its get_new_page() callback to
> >>>> allocate thps.
> >>>>
> >>>> ChangeLog v1 -> v2:
> >>>> - support pte-mapped thp, doubly-mapped thp
> >>>>
> >>>> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> >>>>
> >>>> ChangeLog v2 -> v3:
> >>>> - use page_vma_mapped_walk()
> >>>> - use pmdp_huge_clear_flush() instead of pmdp_huge_get_and_clear() in
> >>>>   set_pmd_migration_entry()
> >>>>
> >>>> ChangeLog v3 -> v4:
> >>>> - factor out the code of removing pte pgtable page in zap_huge_pmd()
> >>>>
> >>>> ChangeLog v4 -> v5:
> >>>> - remove unnecessary PTE-mapped THP code in remove_migration_pmd()
> >>>>   and set_pmd_migration_entry()
> >>>> - restructure the code in zap_huge_pmd() to avoid factoring out
> >>>>   the pte pgtable page code
> >>>> - in zap_huge_pmd(), check that PMD swap entries are migration entries
> >>>> - change author information
> >>>>
> >>>> ChangeLog v5 -> v7
> >>>> - use macro to disable the code when thp migration is not enabled
> >>>>
> >>>> ChangeLog v7 -> v8
> >>>> - use IS_ENABLED instead of macro to make code look clean in
> >>>>   zap_huge_pmd() and page_vma_mapped_walk()
> >>>> - remove BUILD_BUG() in pmd_to_swp_entry() and swp_entry_to_pmd() to
> >>>>   avoid compilation error
> >>>> - rename variable 'migration' to 'flush_needed' and invert the logic in
> >>>>   zap_huge_pmd() to make code more descriptive
> >>>> - use pmdp_invalidate() in set_pmd_migration_entry() to avoid race
> >>>>   with MADV_DONTNEED
> >>>> - remove unnecessary tlb flush in remove_migration_pmd()
> >>>> - add the missing migration flag check in page_vma_mapped_walk()
> >>>>
> >>>> Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
> >>>> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >>>> ---
> >>>>  arch/x86/include/asm/pgtable_64.h |  2 +
> >>>>  include/linux/swapops.h           | 67 ++++++++++++++++++++++++++++++-
> >>>>  mm/huge_memory.c                  | 84 ++++++++++++++++++++++++++++++++++++---
> >>>>  mm/migrate.c                      | 32 ++++++++++++++-
> >>>>  mm/page_vma_mapped.c              | 18 +++++++--
> >>>>  mm/pgtable-generic.c              |  3 +-
> >>>>  mm/rmap.c                         | 13 ++++++
> >>>>  7 files changed, 207 insertions(+), 12 deletions(-)
> >>>>
> >>> ...
> >>>
> >>>> diff --git a/mm/rmap.c b/mm/rmap.c
> >>>> index 91948fbbb0bb..b28f633cd569 100644
> >>>> --- a/mm/rmap.c
> >>>> +++ b/mm/rmap.c
> >>>> @@ -1302,6 +1302,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
> >>>>  	bool ret = true;
> >>>>  	enum ttu_flags flags = (enum ttu_flags)arg;
> >>>>
> >>>> +
> >>>>  	/* munlock has nothing to gain from examining un-locked vmas */
> >>>>  	if ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED))
> >>>>  		return true;
> >>>> @@ -1312,6 +1313,18 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
> >>>>  	}
> >>>>
> >>>>  	while (page_vma_mapped_walk(&pvmw)) {
> >>>> +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
> >>>> +		/* PMD-mapped THP migration entry */
> >>>> +		if (flags & TTU_MIGRATION) {
> >>>
> >>> My testing based on mmotm-2017-07-06-16-18 showed that migrating shmem thp
> >>> caused kernel crash. I don't think this is critical because that case is
> >>> just not-prepared yet. So in order to avoid the crash, please add
> >>> PageAnon(page) check here. This makes shmem thp migration just fail.
> >>>
> >>> +			if (!PageAnon(page))
> >>> +				continue;
> >>>
> >>
> >> Thanks for your testing. I will add this check in my next version.
> >
> > Sorry, the code I'm suggesting above doesn't work because it makes normal
> > pagecache migration fail.  This check should come after making sure that
> > pvmw.pte is NULL.
> 
> Right. I think the two ifs are confusing. Replacing the chunk with:
> 
> if (!pvmw.pte && (flags & TTU_MIGRATION)) {
>     VM_BUG_ON_PAGE(PageHuge(page) || !PageTransCompound(page),
>             page);
> 
>     if (!PageAnon(page))
>         continue;
> 
>     set_pmd_migration_entry(&pvmw, page);
>     continue;
> }
> 
> would be better.

Yes, it looks good.

> 
> BTW, is your page migration test suite available online? If so, I could use
> it to test my code.

Please refer to https://github.com/Naoya-Horiguchi/mm_regression.

Thanks,
Naoya Horiguchi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-07-14  0:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-01 13:39 [PATCH v8 00/10] mm: page migration enhancement for thp Zi Yan
2017-07-01 13:39 ` [PATCH v8 01/10] mm: mempolicy: add queue_pages_required() Zi Yan
2017-07-01 13:40 ` [PATCH v8 02/10] mm: x86: move _PAGE_SWP_SOFT_DIRTY from bit 7 to bit 1 Zi Yan
2017-07-01 13:40 ` [PATCH v8 03/10] mm: thp: introduce separate TTU flag for thp freezing Zi Yan
2017-07-01 13:40 ` [PATCH v8 04/10] mm: thp: introduce CONFIG_ARCH_ENABLE_THP_MIGRATION Zi Yan
2017-07-01 13:40 ` [PATCH v8 05/10] mm: thp: enable thp migration in generic path Zi Yan
2017-07-02 17:57   ` Kirill A. Shutemov
2017-07-03  1:26     ` Zi Yan
2017-07-11  6:47   ` Naoya Horiguchi
2017-07-11 14:00     ` Zi Yan
2017-07-13  9:30       ` Naoya Horiguchi
2017-07-13 11:28         ` Zi Yan
2017-07-14  0:06           ` Naoya Horiguchi [this message]
2017-07-01 13:40 ` [PATCH v8 06/10] mm: thp: check pmd migration entry in common path Zi Yan
2017-07-14  9:29   ` Naoya Horiguchi
2017-07-14 18:29     ` Zi Yan
2017-07-01 13:40 ` [PATCH v8 07/10] mm: soft-dirty: keep soft-dirty bits over thp migration Zi Yan
2017-07-01 13:40 ` [PATCH v8 08/10] mm: mempolicy: mbind and migrate_pages support " Zi Yan
2017-07-01 13:40 ` [PATCH v8 09/10] mm: migrate: move_pages() supports " Zi Yan
2017-07-01 13:40 ` [PATCH v8 10/10] mm: memory_hotplug: memory hotremove " Zi Yan

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=20170714000641.GA6588@hori1.linux.bs1.fc.nec.co.jp \
    --to=n-horiguchi@ah.jp.nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=dnellans@nvidia.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=zi.yan@cs.rutgers.edu \
    /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).