From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Akinobu Mita <akinobu.mita@gmail.com>, SJ Park <sj@kernel.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, SJ Park <sj@kkernel.org>
Subject: [PATCH 1/5] mm/damon/core: use kvmalloc for target regions array
Date: Mon, 29 Jun 2026 07:55:32 -0700 [thread overview]
Message-ID: <20260629145538.134832-2-sj@kernel.org> (raw)
In-Reply-To: <20260629145538.134832-1-sj@kernel.org>
From: Akinobu Mita <akinobu.mita@gmail.com>
damon_commit_target_regions() temporarily allocates a single contiguous
memory region using kmalloc to store copies of all damon_regions of the
damon_target.
However, if the damon_target has a large number of damon_regions, the
total size may exceed KMALLOC_MAX_SIZE.
This problem can be avoided by using kvmalloc instead of kmalloc.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: SJ Park <sj@kkernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20260603112306.58490-1-akinobu.mita@gmail.com
- Collect R-b: from SJ.
- Rebase to latest mm-new.
mm/damon/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3dd2750c2ef20..ded76719e8a14 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1362,14 +1362,14 @@ static int damon_commit_target_regions(struct damon_target *dst,
if (!i)
return 0;
- ranges = kmalloc_objs(*ranges, i, GFP_KERNEL | __GFP_NOWARN);
+ ranges = kvmalloc_objs(*ranges, i, GFP_KERNEL | __GFP_NOWARN);
if (!ranges)
return -ENOMEM;
i = 0;
damon_for_each_region(src_region, src)
ranges[i++] = src_region->ar;
err = damon_set_regions(dst, ranges, i, src_min_region_sz);
- kfree(ranges);
+ kvfree(ranges);
return err;
}
--
2.47.3
next prev parent reply other threads:[~2026-06-29 14:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 14:55 [PATCH 0/5] mm/damon: five misc fixups SJ Park
2026-06-29 14:55 ` SJ Park [this message]
2026-06-30 5:57 ` [PATCH 1/5] mm/damon/core: use kvmalloc for target regions array SJ Park
2026-06-29 14:55 ` [PATCH 2/5] mm/damon/stat: use secs_to_jiffies() instead of msecs_to_jiffies() SJ Park
2026-06-29 14:55 ` [PATCH 3/5] Docs/{admin-guide,mm}/damon: fix DAMON documentation details SJ Park
2026-06-29 14:55 ` [PATCH 4/5] samples/damon: Fix typos in Kconfig help text SJ Park
2026-06-29 14:55 ` [PATCH 5/5] mm/damon/tests/core-kunit: add KUnit test for walk_control_obsolete behavior SJ 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=20260629145538.134832-2-sj@kernel.org \
--to=sj@kernel.org \
--cc=akinobu.mita@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@kkernel.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 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.