linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Barry Song <21cnbao@gmail.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org
Cc: chrisl@kernel.org, kasong@tencent.com,
	linux-kernel@vger.kernel.org, minchan@kernel.org,
	ryan.roberts@arm.com, surenb@google.com, v-songbaohua@oppo.com,
	willy@infradead.org
Subject: Re: [PATCH v2 2/2] mm: set pte writable while pte_soft_dirty() is true in do_swap_page()
Date: Mon, 10 Jun 2024 10:32:53 +0200	[thread overview]
Message-ID: <bf22ef0e-0bb0-4533-838f-365b2078f03e@redhat.com> (raw)
In-Reply-To: <20240607211358.4660-3-21cnbao@gmail.com>

On 07.06.24 23:13, Barry Song wrote:
> From: Barry Song <v-songbaohua@oppo.com>
> 
> This patch leverages the new pte_needs_soft_dirty_wp() helper to optimize
> a scenario where softdirty is enabled, but the softdirty flag has already
> been set in do_swap_page(). In this situation, we can use pte_mkwrite
> instead of applying write-protection since we don't depend on write
> faults.
> 
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> ---
>   mm/memory.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index db9130488231..a063e489446d 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4322,7 +4322,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
>   	if (!folio_test_ksm(folio) &&
>   	    (exclusive || folio_ref_count(folio) == 1)) {
>   		if ((vma->vm_flags & VM_WRITE) && !userfaultfd_pte_wp(vma, pte) &&
> -		    !vma_soft_dirty_enabled(vma)) {
> +		    !pte_needs_soft_dirty_wp(vma, pte)) {
>   			pte = pte_mkwrite(pte, vma);
>   			if (vmf->flags & FAULT_FLAG_WRITE) {
>   				pte = pte_mkdirty(pte);

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2024-06-10  8:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 21:13 [PATCH v2 0/2] mm: introduce pmd|pte_needs_soft_dirty_wp helpers and utilize them Barry Song
2024-06-07 21:13 ` [PATCH v2 1/2] mm: introduce pmd|pte_needs_soft_dirty_wp helpers for softdirty write-protect Barry Song
2024-06-07 21:13 ` [PATCH v2 2/2] mm: set pte writable while pte_soft_dirty() is true in do_swap_page() Barry Song
2024-06-10  8:32   ` David Hildenbrand [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=bf22ef0e-0bb0-4533-838f-365b2078f03e@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=v-songbaohua@oppo.com \
    --cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox