linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Lance Yang <ioworker0@gmail.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, ryan.roberts@arm.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 10:19:52 +0200	[thread overview]
Message-ID: <76d22c08-82db-4ea8-a7cd-c77589e132e3@redhat.com> (raw)
In-Reply-To: <20240417050426.66194-1-ioworker0@gmail.com>

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.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-04-17  8:20 UTC|newest]

Thread overview: 17+ 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 16:25   ` Ryan Roberts
2024-04-17  4:13     ` Lance Yang
     [not found]   ` <a0d9e198-8799-47b9-ac20-8460b984afee@redhat.com>
2024-04-17  4:12     ` Lance Yang
2024-04-17  5:04       ` Lance Yang
2024-04-17  8:19         ` David Hildenbrand [this message]
2024-04-17  9:01           ` Lance Yang
2024-04-17 10:53             ` Ryan Roberts
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=76d22c08-82db-4ea8-a7cd-c77589e132e3@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --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=ryan.roberts@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).