From: Cunlong Li <shenxiaogll@gmail.com>
To: SeongJae Park <sj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: damon@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Cunlong Li <shenxiaogll@gmail.com>
Subject: [PATCH] mm/damon/vaddr: drop redundant mmap_read_lock from damon_va_three_regions
Date: Sun, 07 Jun 2026 21:48:52 +0800 [thread overview]
Message-ID: <20260607-rcu-v1-1-3c9f5995a3a0@gmail.com> (raw)
__damon_va_three_regions() already walks VMAs under rcu_read_lock(), so
the outer mmap_read_lock() is no longer needed.
---
Signed-off-by: Cunlong Li <shenxiaogll@gmail.com>
---
mm/damon/vaddr.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b069dbc7e3d2..27e34596c43b 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -77,7 +77,7 @@ static int __damon_va_three_regions(struct mm_struct *mm,
struct damon_addr_range first_gap = {0}, second_gap = {0};
VMA_ITERATOR(vmi, mm, 0);
struct vm_area_struct *vma, *prev = NULL;
- unsigned long start;
+ unsigned long start = 0, last_vma_end = 0;
/*
* Find the two biggest gaps so that first_gap > second_gap > others.
@@ -104,6 +104,7 @@ static int __damon_va_three_regions(struct mm_struct *mm,
}
next:
prev = vma;
+ last_vma_end = vma->vm_end;
}
rcu_read_unlock();
@@ -120,7 +121,7 @@ static int __damon_va_three_regions(struct mm_struct *mm,
regions[1].start = ALIGN(first_gap.end, DAMON_MIN_REGION_SZ);
regions[1].end = ALIGN(second_gap.start, DAMON_MIN_REGION_SZ);
regions[2].start = ALIGN(second_gap.end, DAMON_MIN_REGION_SZ);
- regions[2].end = ALIGN(prev->vm_end, DAMON_MIN_REGION_SZ);
+ regions[2].end = ALIGN(last_vma_end, DAMON_MIN_REGION_SZ);
return 0;
}
@@ -140,9 +141,7 @@ static int damon_va_three_regions(struct damon_target *t,
if (!mm)
return -EINVAL;
- mmap_read_lock(mm);
rc = __damon_va_three_regions(mm, regions);
- mmap_read_unlock(mm);
mmput(mm);
return rc;
---
base-commit: 8e65320d91cdc3b241d4b94855c88459b91abf66
change-id: 20260607-rcu-24b324e0f076
Best regards,
--
Cunlong Li <shenxiaogll@gmail.com>
next reply other threads:[~2026-06-07 13:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-07 13:48 Cunlong Li [this message]
2026-06-07 17:36 ` SeongJae Park
2026-06-08 3:32 ` Cunlong Li
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=20260607-rcu-v1-1-3c9f5995a3a0@gmail.com \
--to=shenxiaogll@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.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
all inboxes | Powered by JetHome®