All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Lance Yang <ioworker0@gmail.com>, David Hildenbrand <david@redhat.com>
Cc: 21cnbao@gmail.com, akpm@linux-foundation.org,
	fengwei.yin@intel.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, mhocko@suse.com, minchan@kernel.org,
	peterx@redhat.com, shy828301@gmail.com, songmuchun@bytedance.com,
	wangkefeng.wang@huawei.com, xiehuan09@gmail.com,
	zokeefe@google.com
Subject: Re: [PATCH v7 1/3] mm/madvise: introduce clear_young_dirty_ptes() batch helper
Date: Wed, 17 Apr 2024 11:53:09 +0100	[thread overview]
Message-ID: <39905c50-a228-4e85-a5de-3b10cae5f2bc@arm.com> (raw)
In-Reply-To: <CAK1f24mFfwXky9Patwmcq-VQ8y1hxcRm8K4B4o0RO+dsr-7Q=A@mail.gmail.com>

On 17/04/2024 10:01, Lance Yang wrote:
> On Wed, Apr 17, 2024 at 4:19 PM David Hildenbrand <david@redhat.com> wrote:
>>
>> On 17.04.24 07:04, Lance Yang wrote:
>>> Hey David, Ryan,
>>>
>>> How about this change?
>>>
>>> static inline void clear_young_dirty_ptes(struct vm_area_struct *vma,
>>>                                         unsigned long addr, pte_t *ptep,
>>>                                         unsigned int nr, cydp_t flags)
>>> {
>>>       if (flags == CYDP_CLEAR_YOUNG) {
>>>               for (;;) {
>>>                       ptep_test_and_clear_young(vma, addr, ptep);
>>>                       if (--nr == 0)
>>>                               break;
>>>                       ptep++;
>>>                       addr += PAGE_SIZE;
>>>               }
>>>               return;
>>>       }
>>>
>>>       pte_t pte;
>>>
>>>       for (;;) {
>>>               pte = ptep_get_and_clear(vma->vm_mm, addr, ptep);
>>>
>>>               if (flags & CYDP_CLEAR_YOUNG)
>>>                       pte = pte_mkold(pte);
>>>               if (flags & CYDP_CLEAR_DIRTY)
>>>                       pte = pte_mkclean(pte);
>>>
>>>               if (--nr == 0)
>>>                       break;
>>>               ptep++;
>>>               addr += PAGE_SIZE;
>>>       }
>>> }
>>
>> Likely it might be best to just KIS for now and leave it as is. The
>> compiler should optimize out based on flags already, that's what I ignored.
> 
> Got it. Let's keep it as is for now :)

Yep agreed; you're passing the flags as constants so the compiler should be
completely removing one half of the conditional. And if the input isn't a
constant, I'd still expect the compiler to hoist the conditional out of the loop.

> 
> Thanks,
> Lance
> 
>>
>> --
>> Cheers,
>>
>> David / dhildenb
>>



  reply	other threads:[~2024-04-17 10:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16  3:34 [PATCH v7 0/3] mm/madvise: enhance lazyfreeing with mTHP in madvise_free Lance Yang
2024-04-16  3:34 ` [PATCH v7 1/3] mm/madvise: introduce clear_young_dirty_ptes() batch helper Lance Yang
2024-04-16 15:01   ` David Hildenbrand
2024-04-17  4:12     ` Lance Yang
2024-04-17  5:04       ` Lance Yang
2024-04-17  8:19         ` David Hildenbrand
2024-04-17  9:01           ` Lance Yang
2024-04-17 10:53             ` Ryan Roberts [this message]
2024-04-16 16:25   ` Ryan Roberts
2024-04-17  4:13     ` Lance Yang
2024-04-16  3:34 ` [PATCH v7 2/3] mm/arm64: override " Lance Yang
2024-04-16 15:02   ` David Hildenbrand
2024-04-16 16:29   ` Ryan Roberts
2024-04-17  4:16     ` Lance Yang
2024-04-16  3:34 ` [PATCH v7 3/3] mm/madvise: optimize lazyfreeing with mTHP in madvise_free Lance Yang
2024-04-16 16:35   ` Ryan Roberts
2024-04-16 16:52     ` David Hildenbrand
2024-04-17  4:35       ` Lance 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=39905c50-a228-4e85-a5de-3b10cae5f2bc@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=fengwei.yin@intel.com \
    --cc=ioworker0@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=peterx@redhat.com \
    --cc=shy828301@gmail.com \
    --cc=songmuchun@bytedance.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=xiehuan09@gmail.com \
    --cc=zokeefe@google.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.