linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Hugh Dickins <hughd@google.com>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH 3/9] mm/damon/vaddr: cleanup using pmd_trans_huge_lock()
Date: Mon, 17 Nov 2025 07:44:14 -0800	[thread overview]
Message-ID: <20251117154415.11041-1-sj@kernel.org> (raw)
In-Reply-To: <20251112154114.66053-4-sj@kernel.org>

On Wed, 12 Nov 2025 07:41:06 -0800 SeongJae Park <sj@kernel.org> wrote:

> Three pmd walk functions in vaddr.c are using pmd_trans_huge() and
> pmd_lock() to handle THPs.  Simplify the code by replacing the two
> function calls with a single pmd_trans_huge_lock() call.
> 
> Note that this cleanup is not only reducing the lines of code, but also
> simplifies code execution flows for migration entries case, as kindly
> explained [1] by Hugh, who suggested this cleanup.
> 
> [1] https://lore.kernel.org/296c2b3f-6748-158f-b85d-2952165c0588@google.com
> 
> Suggested-by: Hugh Dickins <hughd@google.com>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
>  mm/damon/vaddr.c | 48 ++++++++++++------------------------------------
>  1 file changed, 12 insertions(+), 36 deletions(-)
> 
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 7e834467b2d8..0ad1ce120aa1 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -307,24 +307,14 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
>  		unsigned long next, struct mm_walk *walk)
>  {
>  	pte_t *pte;
> -	pmd_t pmde;
>  	spinlock_t *ptl;
>  
> -	if (pmd_trans_huge(pmdp_get(pmd))) {
> -		ptl = pmd_lock(walk->mm, pmd);
> -		pmde = pmdp_get(pmd);
> -
> -		if (!pmd_present(pmde)) {
> -			spin_unlock(ptl);
> -			return 0;
> -		}
> -
> -		if (pmd_trans_huge(pmde)) {
> +	ptl = pmd_trans_huge_lock(pmd, walk->vma);
> +	if (ptl) {
> +		if (pmd_present(pmdp_get(pmd)))
>  			damon_pmdp_mkold(pmd, walk->vma, addr);
> -			spin_unlock(ptl);
> -			return 0;
> -		}
>  		spin_unlock(ptl);
> +		return 0;
>  	}
>  
>  	pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
> @@ -446,21 +436,12 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
>  	struct damon_young_walk_private *priv = walk->private;
>  
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> -	if (pmd_trans_huge(pmdp_get(pmd))) {
> -		pmd_t pmde;
> -
> -		ptl = pmd_lock(walk->mm, pmd);
> -		pmde = pmdp_get(pmd);
> +	ptl = pmd_trans_huge_lock(pmd, walk->vma);
> +	if (ptl) {
> +		pmd_t pmde = pmdp_get(pmd);

Kernel test robot reported [1] this is making m68k build fails.  Andrew, could
you please add below attaching patch as a fix?

[1] https://lore.kernel.org/202511172257.CjElDcRX-lkp@intel.com


Thanks,
SJ

[...]

---- >8 ----
From 0908bba1aec11997107af757a34136a14be619b7 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Mon, 17 Nov 2025 07:36:43 -0800
Subject: [PATCH] mm/damon/vaddr: provide lvalue to pmd_present()

On m68k, vaddr.c build fails since pmd_present() requires lvalue while
vaddr.c is passing pmdp_get().  Fix it.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202511172257.CjElDcRX-lkp@intel.com/
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/vaddr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index ef57e95eb422..2750c88e7225 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -311,7 +311,9 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
 
 	ptl = pmd_trans_huge_lock(pmd, walk->vma);
 	if (ptl) {
-		if (pmd_present(pmdp_get(pmd)))
+		pmd_t pmde = pmdp_get(pmd);
+
+		if (pmd_present(pmde))
 			damon_pmdp_mkold(pmd, walk->vma, addr);
 		spin_unlock(ptl);
 		return 0;
-- 
2.47.3



  reply	other threads:[~2025-11-17 15:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 15:41 [PATCH 0/9] mm/damon: misc cleanups SeongJae Park
2025-11-12 15:41 ` [PATCH 1/9] mm/damon: rename damos core filter helpers to have word core SeongJae Park
2025-11-12 15:41 ` [PATCH 2/9] mm/damon: rename damos->filters to damos->core_filters SeongJae Park
2025-11-12 15:41 ` [PATCH 3/9] mm/damon/vaddr: cleanup using pmd_trans_huge_lock() SeongJae Park
2025-11-17 15:44   ` SeongJae Park [this message]
2025-11-12 15:41 ` [PATCH 4/9] mm/damon/vaddr: use vm_normal_folio{,_pmd}() instead of damon_get_folio() SeongJae Park
2025-11-12 15:41 ` [PATCH 5/9] mm/damon/vaddr: consistently use only pmd_entry for damos_migrate SeongJae Park
2025-11-12 15:41 ` [PATCH 6/9] mm/damon/tests/core-kunit: remove DAMON_MIN_REGION redefinition SeongJae Park
2025-11-12 15:41 ` [PATCH 7/9] selftests/damon/sysfs.py: merge DAMON status dumping into commitment assertion SeongJae Park
2025-11-12 15:41 ` [PATCH 8/9] Docs/mm/damon/maintainer-profile: fix a typo on mm-untable link SeongJae Park
2025-11-12 15:41 ` [PATCH 9/9] Docs/mm/damon/maintainer-profile: fix grammartical errors SeongJae Park

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=20251117154415.11041-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.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