linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Li Xinhai <lixinhai.lxh@gmail.com>, linux-mm@kvack.org
Cc: Jan Kara <jack@suse.cz>
Subject: Re: [PATCH] mm/memory.c: avoid repeated set_page_dirty in fault_dirty_shared_page
Date: Thu, 12 Dec 2019 16:35:08 +0100	[thread overview]
Message-ID: <7478f044-5bc6-0081-387e-de6bacd8ca86@redhat.com> (raw)
In-Reply-To: <1576164078-28402-1-git-send-email-lixinhai.lxh@gmail.com>

On 12.12.19 16:21, Li Xinhai wrote:
> When vm_ops->page_mkwrite is defined, and called from wp_page_shared and
> do_shared_fault, the set_page_dirty must already called by page_mkwrite.
> Then in fault_dirty_shared_page, avoid this repeated call.
> 
> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
> Cc: Jan Kara <jack@suse.cz>
> ---
>  mm/memory.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index 606da18..34a83d7 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2300,10 +2300,11 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf)
>  	struct vm_area_struct *vma = vmf->vma;
>  	struct address_space *mapping;
>  	struct page *page = vmf->page;
> -	bool dirtied;
> +	bool dirtied = false;
>  	bool page_mkwrite = vma->vm_ops && vma->vm_ops->page_mkwrite;
>  
> -	dirtied = set_page_dirty(page);
> +	if(!page_mkwrite)
> +		dirtied = set_page_dirty(page);
>  	VM_BUG_ON_PAGE(PageAnon(page), page);
>  	/*
>  	 * Take a local copy of the address_space - page.mapping may be zeroed
> @@ -3645,7 +3646,7 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
>  	 * Check if the backing address space wants to know that the page is
>  	 * about to become writable
>  	 */
> -	if (vma->vm_ops->page_mkwrite) {
> +	if (vma->vm_ops && vma->vm_ops->page_mkwrite) {
>  		unlock_page(vmf->page);
>  		tmp = do_page_mkwrite(vmf);
>  		if (unlikely(!tmp ||
> 

This hunk looks like an unrelated change to me.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2019-12-12 15:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 15:21 Li Xinhai
2019-12-12 15:35 ` David Hildenbrand [this message]
2019-12-12 16:55 ` Kirill A. Shutemov
2019-12-13  7:28   ` lixinhai.lxh
2019-12-13 17:50     ` Jan Kara

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=7478f044-5bc6-0081-387e-de6bacd8ca86@redhat.com \
    --to=david@redhat.com \
    --cc=jack@suse.cz \
    --cc=linux-mm@kvack.org \
    --cc=lixinhai.lxh@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox