All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Wei Yang <richardw.yang@linux.intel.com>
Cc: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	richard.weiyang@gmail.com
Subject: Re: [RFC PATCH] mm/rmap.c: finer hwpoison granularity for PTE-mapped THP
Date: Thu, 9 Jan 2020 15:32:33 +0300	[thread overview]
Message-ID: <20200109123233.ye2h4dxaubu4ad22@box> (raw)
In-Reply-To: <20200102030421.30799-1-richardw.yang@linux.intel.com>

On Thu, Jan 02, 2020 at 11:04:21AM +0800, Wei Yang wrote:
> Currently we behave differently between PMD-mapped THP and PTE-mapped
> THP on memory_failure.
> 
> User detected difference:
> 
>     For PTE-mapped THP, the whole 2M range will trigger MCE after
>     memory_failure(), while only 4K range for PMD-mapped THP will.
> 
> Direct reason:
> 
>     All the 512 PTE entry will be marked as hwpoison entry for a PTE-mapped
>     THP while only one PTE will be marked for a PMD-mapped THP.
> 
> Root reason:
> 
>     The root cause is PTE-mapped page doesn't need to split pmd which skip
>     the SPLIT_FREEZE process.

I don't follow how SPLIT_FREEZE is related to pisoning. Cold you
laraborate?

>     This makes try_to_unmap_one() do its job when
>     the THP is not splited. And since page is HWPOISON, all the entries in
>     THP is marked as hwpoison entry.
> 
>     While for the PMD-mapped THP, SPLIT_FREEZE will save migration entry to
>     pte and this skip try_to_unmap_one() before THP splited. And then only
>     the affected 4k page is marked as hwpoison entry.
> 
> This patch tries to provide a finer granularity for PTE-mapped THP by
> only mark the affected subpage as hwpoison entry when THP is not
> split.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> 
> ---
> This complicates the picture a little, while I don't find a better way to
> improve. 
> 
> Also I may miss some case or not handle this properly.
> 
> Look forward your comments.
> ---
>  mm/rmap.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/rmap.c b/mm/rmap.c
> index b3e381919835..90229917dd64 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1554,10 +1554,11 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
>  				set_huge_swap_pte_at(mm, address,
>  						     pvmw.pte, pteval,
>  						     vma_mmu_pagesize(vma));
> -			} else {
> +			} else if (!PageAnon(page) || page == subpage) {
>  				dec_mm_counter(mm, mm_counter(page));
>  				set_pte_at(mm, address, pvmw.pte, pteval);
> -			}
> +			} else
> +				goto freeze;
>  
>  		} else if (pte_unused(pteval) && !userfaultfd_armed(vma)) {
>  			/*
> @@ -1579,6 +1580,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
>  			swp_entry_t entry;
>  			pte_t swp_pte;
>  
> +freeze:
>  			if (arch_unmap_one(mm, vma, address, pteval) < 0) {
>  				set_pte_at(mm, address, pvmw.pte, pteval);
>  				ret = false;
> -- 
> 2.17.1
> 
> 

-- 
 Kirill A. Shutemov


  reply	other threads:[~2020-01-09 12:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-02  3:04 [RFC PATCH] mm/rmap.c: finer hwpoison granularity for PTE-mapped THP Wei Yang
2020-01-09 12:32 ` Kirill A. Shutemov [this message]
2020-01-10  1:55   ` Wei Yang

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=20200109123233.ye2h4dxaubu4ad22@box \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=richard.weiyang@gmail.com \
    --cc=richardw.yang@linux.intel.com \
    /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 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.