From: SeongJae Park <sj@kernel.org>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
SeongJae Park <sj@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Lorenzo Stoakes <lstoakes@gmail.com>,
Uladzislau Rezki <urezki@gmail.com>, Zi Yan <ziy@nvidia.com>,
Yu Zhao <yuzhao@google.com>, Mike Rapoport <rppt@kernel.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
damon@lists.linux.dev
Subject: Re: [PATCH v3 3/4] mm/damon/ops-common: Refactor to use {pte|pmd}p_clear_young_notify()
Date: Fri, 2 Jun 2023 21:54:49 +0000 [thread overview]
Message-ID: <20230602215449.107659-1-sj@kernel.org> (raw)
In-Reply-To: <20230602092949.545577-4-ryan.roberts@arm.com>
Hi Ryan,
On Fri, 2 Jun 2023 10:29:48 +0100 Ryan Roberts <ryan.roberts@arm.com> wrote:
> With the fix in place to atomically test and clear young on ptes and
> pmds, simplify the code to handle the clearing for both the primary mmu
> and the mmu notifier with a single API call.
>
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
> ---
> mm/damon/ops-common.c | 22 ++--------------------
> 1 file changed, 2 insertions(+), 20 deletions(-)
>
> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index acc264b97903..d4ab81229136 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -39,21 +39,12 @@ struct folio *damon_get_folio(unsigned long pfn)
>
> void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr)
> {
> - bool referenced = false;
> struct folio *folio = damon_get_folio(pte_pfn(*pte));
>
> if (!folio)
> return;
>
> - if (ptep_test_and_clear_young(vma, addr, pte))
> - referenced = true;
> -
> -#ifdef CONFIG_MMU_NOTIFIER
> - if (mmu_notifier_clear_young(vma->vm_mm, addr, addr + PAGE_SIZE))
> - referenced = true;
> -#endif /* CONFIG_MMU_NOTIFIER */
> -
> - if (referenced)
> + if (ptep_clear_young_notify(vma, addr, pte))
> folio_set_young(folio);
>
> folio_set_idle(folio);
> @@ -63,21 +54,12 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr
> void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr)
> {
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> - bool referenced = false;
> struct folio *folio = damon_get_folio(pmd_pfn(*pmd));
>
> if (!folio)
> return;
>
> - if (pmdp_test_and_clear_young(vma, addr, pmd))
> - referenced = true;
> -
> -#ifdef CONFIG_MMU_NOTIFIER
> - if (mmu_notifier_clear_young(vma->vm_mm, addr, addr + HPAGE_PMD_SIZE))
> - referenced = true;
> -#endif /* CONFIG_MMU_NOTIFIER */
> -
> - if (referenced)
> + if (pmdp_clear_young_notify(vma, addr, pmd))
> folio_set_young(folio);
>
> folio_set_idle(folio);
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2023-06-02 21:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 9:29 [PATCH v3 0/4] Fixes for pte encapsulation bypasses Ryan Roberts
2023-06-02 9:29 ` [PATCH v3 1/4] mm: vmalloc must set pte via arch code Ryan Roberts
2023-06-02 9:29 ` [PATCH v3 2/4] mm/damon/ops-common: atomically test and clear young on ptes and pmds Ryan Roberts
2023-06-02 16:35 ` Yu Zhao
2023-06-02 17:14 ` Ryan Roberts
2023-06-02 17:35 ` Yu Zhao
2023-06-02 19:15 ` SeongJae Park
2023-06-02 21:43 ` SeongJae Park
2023-06-03 18:20 ` Ryan Roberts
2023-06-02 9:29 ` [PATCH v3 3/4] mm/damon/ops-common: Refactor to use {pte|pmd}p_clear_young_notify() Ryan Roberts
2023-06-02 16:28 ` Yu Zhao
2023-06-02 21:54 ` SeongJae Park [this message]
2023-06-02 9:29 ` [PATCH v3 4/4] mm: Fix failure to unmap pte on highmem systems Ryan Roberts
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=20230602215449.107659-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=hch@infradead.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=urezki@gmail.com \
--cc=willy@infradead.org \
--cc=yuzhao@google.com \
--cc=ziy@nvidia.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).