From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Jérôme Glisse" <jglisse@redhat.com>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Naoya Horiguchi" <n-horiguchi@ah.jp.nec.com>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Michal Hocko" <mhocko@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm: migration: fix migration of huge PMD shared pages
Date: Wed, 15 Aug 2018 11:47:54 +0300 [thread overview]
Message-ID: <20180815084754.6ea4z4pzjkcwepsv@kshutemo-mobl1> (raw)
In-Reply-To: <17bfe24d-957f-2985-f134-3ebe2648aecb@oracle.com>
On Tue, Aug 14, 2018 at 05:15:57PM -0700, Mike Kravetz wrote:
> On 08/14/2018 01:48 AM, Kirill A. Shutemov wrote:
> > On Mon, Aug 13, 2018 at 11:21:41PM +0000, Mike Kravetz wrote:
> >> On 08/13/2018 03:58 AM, Kirill A. Shutemov wrote:
> >>> On Sun, Aug 12, 2018 at 08:41:08PM -0700, Mike Kravetz wrote:
> >>>> I am not %100 sure on the required flushing, so suggestions would be
> >>>> appreciated. This also should go to stable. It has been around for
> >>>> a long time so still looking for an appropriate 'fixes:'.
> >>>
> >>> I believe we need flushing. And huge_pmd_unshare() usage in
> >>> __unmap_hugepage_range() looks suspicious: I don't see how we flush TLB in
> >>> that case.
> >>
> >> Thanks Kirill,
> >>
> >> __unmap_hugepage_range() has two callers:
> >> 1) unmap_hugepage_range, which wraps the call with tlb_gather_mmu and
> >> tlb_finish_mmu on the range. IIUC, this should cause an appropriate
> >> TLB flush.
> >> 2) __unmap_hugepage_range_final via unmap_single_vma. unmap_single_vma
> >> has three callers:
> >> - unmap_vmas which assumes the caller will flush the whole range after
> >> return.
> >> - zap_page_range wraps the call with tlb_gather_mmu/tlb_finish_mmu
> >> - zap_page_range_single wraps the call with tlb_gather_mmu/tlb_finish_mmu
> >>
> >> So, it appears we are covered. But, I could be missing something.
> >
> > My problem here is that the mapping that moved by huge_pmd_unshare() in
> > not accounted into mmu_gather and can be missed on tlb_finish_mmu().
>
> Ah, I think I now see the issue you are concerned with.
>
> When huge_pmd_unshare succeeds we effectively unmap a PUD_SIZE area.
> The routine __unmap_hugepage_range may only have been passed a range
> that is a subset of PUD_SIZE. In the case I was trying to address,
> try_to_unmap_one() the 'range' will certainly be less than PUD_SIZE.
> Upon further thought, I think that even in the case of try_to_unmap_one
> we should flush PUD_SIZE range.
>
> My first thought would be to embed this flushing within huge_pmd_unshare
> itself. Perhaps, whenever huge_pmd_unshare succeeds we should do an
> explicit:
> flush_cache_range(PUD_SIZE)
> flush_tlb_range(PUD_SIZE)
> mmu_notifier_invalidate_range(PUD_SIZE)
> That would take some of the burden off the callers of huge_pmd_unshare.
> However, I am not sure if the flushing calls above play nice in all the
> calling environments. I'll look into it some more, but would appreciate
> additional comments.
I don't think it would work: flush_tlb_range() does IPI and calling it
under spinlock will not go well. I think we need to find a way to account
it properly in the mmu_gather. It's not obvious to me how.
--
Kirill A. Shutemov
prev parent reply other threads:[~2018-08-15 8:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 3:41 [PATCH] mm: migration: fix migration of huge PMD shared pages Mike Kravetz
2018-08-13 4:10 ` kbuild test robot
2018-08-14 0:30 ` [PATCH v2] " Mike Kravetz
2018-08-14 6:28 ` Greg KH
2018-08-13 4:17 ` [PATCH] " kbuild test robot
2018-08-13 10:58 ` Kirill A. Shutemov
2018-08-13 23:21 ` Mike Kravetz
2018-08-14 8:48 ` Kirill A. Shutemov
2018-08-15 0:15 ` Mike Kravetz
2018-08-15 8:47 ` Kirill A. Shutemov [this message]
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=20180815084754.6ea4z4pzjkcwepsv@kshutemo-mobl1 \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=jglisse@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=vbabka@suse.cz \
/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).