All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@virtuozzo.com>
To: Andrea Arcangeli <aarcange@redhat.com>,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH 1/1] soft_dirty: fix soft_dirty during THP split
Date: Fri, 19 Aug 2016 16:17:26 +0300	[thread overview]
Message-ID: <57B706E6.70507@virtuozzo.com> (raw)
In-Reply-To: <1471610515-30229-2-git-send-email-aarcange@redhat.com>

On 08/19/2016 03:41 PM, Andrea Arcangeli wrote:
> Transfer the soft_dirty from pmd to pte during THP splits.
> 
> This fix avoids losing the soft_dirty bit and avoids userland memory
> corruption in the checkpoint.

Nasty :( Thanks for catching this!

> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>

Acked-by: Pavel Emelyanov <xemul@virtuozzo.com>

> ---
>  mm/huge_memory.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index b9570b5..cb95a83 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1512,7 +1512,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
>  	struct page *page;
>  	pgtable_t pgtable;
>  	pmd_t _pmd;
> -	bool young, write, dirty;
> +	bool young, write, dirty, soft_dirty;
>  	unsigned long addr;
>  	int i;
>  
> @@ -1546,6 +1546,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
>  	write = pmd_write(*pmd);
>  	young = pmd_young(*pmd);
>  	dirty = pmd_dirty(*pmd);
> +	soft_dirty = pmd_soft_dirty(*pmd);
>  
>  	pmdp_huge_split_prepare(vma, haddr, pmd);
>  	pgtable = pgtable_trans_huge_withdraw(mm, pmd);
> @@ -1562,6 +1563,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
>  			swp_entry_t swp_entry;
>  			swp_entry = make_migration_entry(page + i, write);
>  			entry = swp_entry_to_pte(swp_entry);
> +			if (soft_dirty)
> +				entry = pte_swp_mksoft_dirty(entry);
>  		} else {
>  			entry = mk_pte(page + i, vma->vm_page_prot);
>  			entry = maybe_mkwrite(entry, vma);
> @@ -1569,6 +1572,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
>  				entry = pte_wrprotect(entry);
>  			if (!young)
>  				entry = pte_mkold(entry);
> +			if (soft_dirty)
> +				entry = pte_mksoft_dirty(entry);
>  		}
>  		if (dirty)
>  			SetPageDirty(page + i);
> .
> 

--
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:[~2016-08-19 13:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-19 12:41 [PATCH 0/1] soft_dirty: fix soft_dirty during THP split Andrea Arcangeli
2016-08-19 12:41 ` [PATCH 1/1] " Andrea Arcangeli
2016-08-19 13:17   ` Pavel Emelyanov [this message]
2016-08-19 13:20 ` [PATCH 0/1] " Pavel Emelyanov
2016-08-19 13:43   ` Andrea Arcangeli
2016-08-19 13:52     ` Pavel Emelyanov
2016-08-19 14:37       ` Andrea Arcangeli
2016-08-22 16:35         ` Pavel Emelyanov
2016-08-23 11:03       ` Mike Rapoport

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=57B706E6.70507@virtuozzo.com \
    --to=xemul@virtuozzo.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.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 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.