linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org, 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] mm: introduce pmd|pte_need_soft_dirty_wp helpers for softdirty write-protect
Date: Fri, 7 Jun 2024 21:00:38 +1200	[thread overview]
Message-ID: <CAGsJ_4wSFWMpgd38XqZNNdfDT9PHp+xNjfFYY46yHvjqwJ5QkA@mail.gmail.com> (raw)
In-Reply-To: <a04dd2d6-8526-488f-b46a-80c530891415@redhat.com>

On Fri, Jun 7, 2024 at 8:46 PM David Hildenbrand <david@redhat.com> wrote:
>
> On 06.06.24 05:40, Barry Song wrote:
> > From: Barry Song <v-songbaohua@oppo.com>
> >
> > This patch introduces the pte_need_soft_dirty_wp and
> > pmd_need_soft_dirty_wp helpers to determine if write protection is
> > required for softdirty tracking. This can enhance code readability
> > and improve its overall appearance.
> >
> > These new helpers are utilized in gup, huge_memory, and protect,
> > and are particularly applied in do_swap_page() to optimize a
> > softdirty scenario where mkwrite can still be performed.
>
> [...]
>
> > +static inline bool pmd_need_soft_dirty_wp(struct vm_area_struct *vma, pmd_t pmd)
> > +{
> > +     return vma_soft_dirty_enabled(vma) && !pmd_soft_dirty(pmd);
> > +}
> > +
> > +static inline bool pte_need_soft_dirty_wp(struct vm_area_struct *vma, pte_t pte)
> > +{
> > +     return vma_soft_dirty_enabled(vma) && !pte_soft_dirty(pte);
> > +}
> > +
>
> Should these be "needs" ? I tend to like these names/semantics.

yes. "needs" is better. Glad to know you have the common liking
for these names.

>
>
> >   static inline void vma_iter_config(struct vma_iterator *vmi,
> >               unsigned long index, unsigned long last)
> >   {
> > diff --git a/mm/memory.c b/mm/memory.c
> > index db9130488231..6307c43796aa 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_need_soft_dirty_wp(vma, pte)) {
> >                       pte = pte_mkwrite(pte, vma);
>
> I would move that into a separate patch, as it's not a simple conversion.
>

cool. will separate it in v2.

> --
> Cheers,
>
> David / dhildenb
>

Thanks
Barry


      reply	other threads:[~2024-06-07  9:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  3:40 Barry Song
2024-06-07  8:46 ` David Hildenbrand
2024-06-07  9:00   ` Barry Song [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=CAGsJ_4wSFWMpgd38XqZNNdfDT9PHp+xNjfFYY46yHvjqwJ5QkA@mail.gmail.com \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=david@redhat.com \
    --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