From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41CCD29C325; Wed, 15 Apr 2026 01:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216057; cv=none; b=nbnH1GTAjpJuTyRhhxUWOsCACE7a3hLshM+7uHQWqP9OacWPueOa6QX3pRORWVi1LnusyAfV6PmsGy8FOKDh+gy7l5JDg/XGxkrnRsfw6lyj5EV+RwwiKSns7tEbi6WFK/XhINQm+cSxR3Gb8ftsOhU+NE2vncGlQKI+aZ1MapI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216057; c=relaxed/simple; bh=9rMAkySwPwOzbR0wIgkJ8MpOnAl8M9axmSlqMcxmgDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QVY5a/VQz/giywZVUQLf1TjiL3d5a2eIZAEcdBXnaCLfkyrR2JZdWaL91QPCnZC7Pd6lUwerD+vv6ScnY06f36INKy6wlGC5gqOWQksoENH9OF8OK3tIUne4YMfe8XvTysbsbiyqIO566ujx4fd3hkmKMwoYE9rfD/5ULPnfRTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aK64Gw2u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aK64Gw2u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD95BC4AF0B; Wed, 15 Apr 2026 01:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216057; bh=9rMAkySwPwOzbR0wIgkJ8MpOnAl8M9axmSlqMcxmgDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aK64Gw2ur1hChS7ihUc5Z+ZtOlcOMO6rKxfPpk1x12xYtp19gCrx5YtOmmiBtsPLK Nqfa/HwiNAbxNJge6BC928eI8Xc+Q58dLxSglm8rjoRI/Q0VzDq5xkrIa/gEO/Ubde l8XKuPG8BsYipTEhAL6hqA/zB1rIyBUhkdlvhJ1AhokMkEbgtx5lmuI3LG4/jKUq9z ezcuoQVS0T6tB+Q0hsPVTC2KFJidYWEnPxw3QxLYf5NgjD9Yih2CXxndfAnxqnLd+k Gd6TIaEhRv86iDjoaTWErgw12wq+oISGaWy/z7ebg5f382XxNZ6wTKYOVlbm0jcSxw zMZ31oUofRvSQ== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 1/7] mm/damon: introduce damon_set_region_system_rams_default() Date: Tue, 14 Apr 2026 18:20:29 -0700 Message-ID: <20260415012048.76508-2-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" damon_set_region_biggest_system_ram_default() sets the monitoring target region as the caller requested. If the caller didn't specify the region, it finds the biggest System RAM of the system and sets it as the target region. When there are more than one considerable size of System RAM resources in the system, the default target setup makes no sense. Introduce a variant, namely damon_set_region_system_rams_default(). It sets a physical address range that covers all System RAM resources as the default target region. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 +++ mm/damon/core.c | 77 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 5fb1dc585658b..c4cdaa01ea530 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -1007,6 +1007,11 @@ int damon_kdamond_pid(struct damon_ctx *ctx); int damon_call(struct damon_ctx *ctx, struct damon_call_control *control); int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control); =20 +int damon_set_region_system_rams_default(struct damon_target *t, + unsigned long *start, unsigned long *end, + unsigned long addr_unit, + unsigned long min_region_sz); + int damon_set_region_biggest_system_ram_default(struct damon_target *t, unsigned long *start, unsigned long *end, unsigned long addr_unit, diff --git a/mm/damon/core.c b/mm/damon/core.c index 48633da449104..3cef74ba7f0f4 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -3186,14 +3186,20 @@ static int kdamond_fn(void *data) return 0; } =20 -static int walk_system_ram(struct resource *res, void *arg) +struct damon_system_ram_range_walk_arg { + bool walked; + struct resource res; +}; + +static int damon_system_ram_walk_fn(struct resource *res, void *arg) { - struct resource *a =3D arg; + struct damon_system_ram_range_walk_arg *a =3D arg; =20 - if (resource_size(a) < resource_size(res)) { - a->start =3D res->start; - a->end =3D res->end; + if (!a->walked) { + a->walked =3D true; + a->res.start =3D res->start; } + a->res.end =3D res->end; return 0; } =20 @@ -3210,6 +3216,67 @@ static unsigned long damon_res_to_core_addr(resource= _size_t ra, return ra / addr_unit; } =20 +static bool damon_find_system_rams_range(unsigned long *start, + unsigned long *end, unsigned long addr_unit) +{ + struct damon_system_ram_range_walk_arg arg =3D {}; + + walk_system_ram_res(0, -1, &arg, damon_system_ram_walk_fn); + if (!arg.walked) + return false; + *start =3D damon_res_to_core_addr(arg.res.start, addr_unit); + *end =3D damon_res_to_core_addr(arg.res.end + 1, addr_unit); + if (*end <=3D *start) + return false; + return true; +} + +/** + * damon_set_region_system_rams_default() - Set the region of the given + * monitoring target as requested, or to cover all 'System RAM' resources. + * @t: The monitoring target to set the region. + * @start: The pointer to the start address of the region. + * @end: The pointer to the end address of the region. + * @addr_unit: The address unit for the damon_ctx of @t. + * @min_region_sz: Minimum region size. + * + * This function sets the region of @t as requested by @start and @end. I= f the + * values of @start and @end are zero, however, this function finds 'System + * RAM' resources and sets the region to cover all the resource. In the l= atter + * case, this function saves the start and the end addresseses of the firs= t and + * the last resources in @start and @end, respectively. + * + * Return: 0 on success, negative error code otherwise. + */ +int damon_set_region_system_rams_default(struct damon_target *t, + unsigned long *start, unsigned long *end, + unsigned long addr_unit, unsigned long min_region_sz) +{ + struct damon_addr_range addr_range; + + if (*start > *end) + return -EINVAL; + + if (!*start && !*end && + !damon_find_system_rams_range(start, end, addr_unit)) + return -EINVAL; + + addr_range.start =3D *start; + addr_range.end =3D *end; + return damon_set_regions(t, &addr_range, 1, min_region_sz); +} + +static int walk_system_ram(struct resource *res, void *arg) +{ + struct resource *a =3D arg; + + if (resource_size(a) < resource_size(res)) { + a->start =3D res->start; + a->end =3D res->end; + } + return 0; +} + /* * Find biggest 'System RAM' resource and store its start and end address = in * @start and @end, respectively. If no System RAM is found, returns fals= e. --=20 2.47.3 From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F9042D73B6; Wed, 15 Apr 2026 01:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216057; cv=none; b=QX3SEDoocux4kx8zZJvkxcXjQsGr4O2WjP9Mskem6JYdokXo1J6xCqJ7Bep7bf1gewGOliKkQJEwjeHmnGMySgDvMffWvxVbgEs3XdV6X17l1rCELNQvXoL7gMDPVYWmNwpOLN7HvgadZpCZqckhcZ/Y/tn7kRL3V4Ko2upSjxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216057; c=relaxed/simple; bh=jusaHabcDbQG2msd5Ko6TcArzh+c8u/ACR+D/XNuFA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=draiy4EOYLCLov7snPa/mqfO+gi1a8FjlJ82g9n9+6GlvWXmQQTN8pRKtv6xOof8rGdeOxEiLGyiQhijTJRiScp7iPbKloXPjf2wKnsj9QTGUZgO5m6xyd0cPLngfDBinpBYwyFi5pp/sDUHE6IIAchKztonL0ve6CoP1czqrVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h4YEOuW3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h4YEOuW3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28AA8C2BCB6; Wed, 15 Apr 2026 01:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216057; bh=jusaHabcDbQG2msd5Ko6TcArzh+c8u/ACR+D/XNuFA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4YEOuW3v6TayFitmmPN1KXvhRyqJNLlBeiZr6uJv0SIZTjQXNY9G+5hS/pPRT/Pf 032qZ9MuhlNV8BEM+oO3RGijzwIVVvhxeWRWHe/uTBFAP2ENXqBNfhSOD+s/8pjVcx ibUlN43hxTJ0pME0M2I8qZ1RCIdfDa0YJ8m1+MgjhUkStI1nNE0PFEkqE06rUJ/Iuf Omndah1zQpByfZBAIsRcajFnuZyzxCtQPjYlcgPA1PZIwia2vV9gptv4NRTtgnzKLN m9a/8Kz3KAEM9gVVQXBJwc2laVm/hbB24KVlHdM+t/lksqNaLcYLXQETCgF9aSZdcy DVtudT8vLYUbA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 2/7] mm/damon/reclaim: cover all system rams Date: Tue, 14 Apr 2026 18:20:30 -0700 Message-ID: <20260415012048.76508-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON_RECLAIM allows users to set the physical address range to monitor and do the work on. When users don't explicitly set the range, the biggest System RAM resource of the system is selected as the monitoring target address range. The intention was to reduce the overhead from monitoring non-System RAM areas because monitoring of non-System RAM may be meaningless. However, because of the sampling based access check and adaptive regions adjustment, the overhead should be negligible. It makes more sense to just cover all system rams of the system. Do so. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 89998d28628c4..ecfc6b58d07d2 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -127,7 +127,8 @@ DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(damon_reclaim_mon= _attrs); * Start of the target memory region in physical address. * * The start physical address of memory region that DAMON_RECLAIM will do = work - * against. By default, biggest System RAM is used as the region. + * against. By default, the system's entire physical memory is used as the + * region. */ static unsigned long monitor_region_start __read_mostly; module_param(monitor_region_start, ulong, 0600); @@ -136,7 +137,8 @@ module_param(monitor_region_start, ulong, 0600); * End of the target memory region in physical address. * * The end physical address of memory region that DAMON_RECLAIM will do wo= rk - * against. By default, biggest System RAM is used as the region. + * against. By default, the system's entire physical memory is used as the + * region. */ static unsigned long monitor_region_end __read_mostly; module_param(monitor_region_end, ulong, 0600); @@ -264,11 +266,9 @@ static int damon_reclaim_apply_parameters(void) damos_add_filter(scheme, filter); } =20 - err =3D damon_set_region_biggest_system_ram_default(param_target, - &monitor_region_start, - &monitor_region_end, - param_ctx->addr_unit, - param_ctx->min_region_sz); + err =3D damon_set_region_system_rams_default(param_target, + &monitor_region_start, &monitor_region_end, + param_ctx->addr_unit, param_ctx->min_region_sz); if (err) goto out; err =3D damon_commit_ctx(ctx, param_ctx); --=20 2.47.3 From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD7ED2DB7BE; Wed, 15 Apr 2026 01:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216057; cv=none; b=Q+w9ZsK92UIXFl8j036QArgCz8wEGgvM5A+rCWtjD0FDBnsMBXR2OohPP1BN2jVW+Fddv2LBg/i9CCTBAXqxPsEzywiGLnmAhoRWwrRAVLAeWr0FCi33jNQqPycGueI8HoknAqc0wfmYgrcKJWy6ZwiQbFthDpGDgpWef/38KkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216057; c=relaxed/simple; bh=d7zJukuGsoRpeCy4tkwyJwYBmFc6TkPv6uDC4T8m6EI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DzUoDtDTYZ7U2jSSs6tVoBqF1E8th85WvSps2zdz5eFi8Kpy2NVJvTcBAJhjFZrySl6UfpQLU+jaKgtA1CrzSF3D8uF/CAG4jZZXmGViKqh/w7UaE9As2nzqqnT4uW+igCi0ChiNWXZBmXHO/aAIEoeDCKy5ak5R198TO1DWhYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zuqu7Ybr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zuqu7Ybr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79892C19425; Wed, 15 Apr 2026 01:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216057; bh=d7zJukuGsoRpeCy4tkwyJwYBmFc6TkPv6uDC4T8m6EI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zuqu7YbrOifqoHzSY082nxiqYcDO/tBge91J9GrdcWoRwoXkGeQ+IdioKg/uFdhVC Xw5IkdfhzRbLL0QuUQSeCTDI1STf4I3rQTG4DVoGdQP6Q2/HDQca7pXzAG075Lt0Fc hTIva8vcI3ZgBAbV7aZ6xuPpLRSYcFx/LpNUsKE7+iR8X4FpHVAYWlOFQJNbmXwGNP 8efYV/WT7rBKYs7BNNlmLw2iFodhCBc9nIKpA2pnhjuXxVYsOCikiRmKCAvUr3EEUW y2jbBC31jEJqRWuVOrGWNLPbASVU2+GGqnDJEPGHCIeX9YMJsA1hmoJxcptzLUaMB2 1te8pUaaWPvog== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 3/7] mm/damon/lru_sort: cover all system rams Date: Tue, 14 Apr 2026 18:20:31 -0700 Message-ID: <20260415012048.76508-4-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON_LRU_SORT allows users to set the physical address range to monitor and do the work on. When users don't explicitly set the range, the biggest system ram resource of the system is selected as the monitoring target address range. The intention was to reduce the overhead from monitoring non-System RAM areas because monitoring non-System RAM may be meaningless. However, because of the sampling based access check and adaptive regions adjustment, the overhead should be negligible. It makes more sense to just cover all system rams of the system. Do so. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 641af42cc2d1a..48ddfa6369c93 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -139,7 +139,8 @@ DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(damon_lru_sort_mo= n_attrs); * Start of the target memory region in physical address. * * The start physical address of memory region that DAMON_LRU_SORT will do= work - * against. By default, biggest System RAM is used as the region. + * against. By default, the system's entire phyiscal memory is used as the + * region. */ static unsigned long monitor_region_start __read_mostly; module_param(monitor_region_start, ulong, 0600); @@ -148,7 +149,8 @@ module_param(monitor_region_start, ulong, 0600); * End of the target memory region in physical address. * * The end physical address of memory region that DAMON_LRU_SORT will do w= ork - * against. By default, biggest System RAM is used as the region. + * against. By default, the system's entire phyiscal memory is used as the + * region. */ static unsigned long monitor_region_end __read_mostly; module_param(monitor_region_end, ulong, 0600); @@ -335,7 +337,7 @@ static int damon_lru_sort_apply_parameters(void) if (err) goto out; =20 - err =3D damon_set_region_biggest_system_ram_default(param_target, + err =3D damon_set_region_system_rams_default(param_target, &monitor_region_start, &monitor_region_end, param_ctx->addr_unit, --=20 2.47.3 From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42F0E2F069D; Wed, 15 Apr 2026 01:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216058; cv=none; b=FZLcPy5+tDopKJVGbR+vlTd4NAXg5s4uKQqPNGl24Kzi69uyK50wAAZHJ/JGQL/9ZlI3wZe7XUdlKtM3WPR3qxnYCbXHUV2nySa88AndrGcvzo9acDL07fi76rSzZtdYbfrSgBSQBFKGqIafe9HjUHmr/Gz5rcnwZk5BRqPT50c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216058; c=relaxed/simple; bh=x8bXl3PuqEzl+QG+OoYKgf8IyRa9wew4podtKeqi3D0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aa6wF97YqpIfm6cbdyi/r8ubz180xHrmNZVdMojfPoCst4oVK6jSNZickR+W0ypEgY3qbH8JrmVVGbnMXl6CSixVa7qEUsv7ewb1uOmTuhFjgci5YMB3NcsWqWVeFIPb8a+KDhmW348etBCkUzOrjK6dGMQIaInQ3eXaCL3rAdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oMrHzTi8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oMrHzTi8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5D54C2BCB6; Wed, 15 Apr 2026 01:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216058; bh=x8bXl3PuqEzl+QG+OoYKgf8IyRa9wew4podtKeqi3D0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMrHzTi8vNNouQyMdH3ZOkAv3j0wwweVvEdNKI41DrZLVNbhCIT9jmPJDnD/JXK+/ 30PpgQOhHTwS7OvwdxHIlvIphHz4B1QHKR3pW56SG4c5/ZO2zj1rBjI/XgFjHXDMFO Thvbx8JtZpJ6W99VJl5uQg6EAkitdmAYCYvb6dURq0UhoZ8KVL92WUK68WCwalo/JJ GTBFb6A+Hl8DEJnjOddgTkqBd2QEXv892+FonCHsvi7TYsJkwxo5Cuz7gTYIfuPpQD yeFPui7fpyYyYr0kEP0b7iVA7PZ0w+5vws9Co4PpBAToZIJL4trYe5LUkMvNBnAgGv bsDP9QWnmzzXg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 4/7] mm/damon/core: remove damon_set_region_biggest_system_ram_default() Date: Tue, 14 Apr 2026 18:20:32 -0700 Message-ID: <20260415012048.76508-5-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now nobody is using damon_set_region_biggest_system_ram_default(). Remove it. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 ---- mm/damon/core.c | 64 ------------------------------------------- 2 files changed, 69 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index c4cdaa01ea530..1a4f754ad89be 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -1012,11 +1012,6 @@ int damon_set_region_system_rams_default(struct damo= n_target *t, unsigned long addr_unit, unsigned long min_region_sz); =20 -int damon_set_region_biggest_system_ram_default(struct damon_target *t, - unsigned long *start, unsigned long *end, - unsigned long addr_unit, - unsigned long min_region_sz); - #endif /* CONFIG_DAMON */ =20 #endif /* _DAMON_H */ diff --git a/mm/damon/core.c b/mm/damon/core.c index 3cef74ba7f0f4..d2c8c088e7451 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -3266,70 +3266,6 @@ int damon_set_region_system_rams_default(struct damo= n_target *t, return damon_set_regions(t, &addr_range, 1, min_region_sz); } =20 -static int walk_system_ram(struct resource *res, void *arg) -{ - struct resource *a =3D arg; - - if (resource_size(a) < resource_size(res)) { - a->start =3D res->start; - a->end =3D res->end; - } - return 0; -} - -/* - * Find biggest 'System RAM' resource and store its start and end address = in - * @start and @end, respectively. If no System RAM is found, returns fals= e. - */ -static bool damon_find_biggest_system_ram(unsigned long *start, - unsigned long *end, unsigned long addr_unit) - -{ - struct resource res =3D {}; - - walk_system_ram_res(0, -1, &res, walk_system_ram); - *start =3D damon_res_to_core_addr(res.start, addr_unit); - *end =3D damon_res_to_core_addr(res.end + 1, addr_unit); - if (*end <=3D *start) - return false; - return true; -} - -/** - * damon_set_region_biggest_system_ram_default() - Set the region of the g= iven - * monitoring target as requested, or biggest 'System RAM'. - * @t: The monitoring target to set the region. - * @start: The pointer to the start address of the region. - * @end: The pointer to the end address of the region. - * @addr_unit: The address unit for the damon_ctx of @t. - * @min_region_sz: Minimum region size. - * - * This function sets the region of @t as requested by @start and @end. I= f the - * values of @start and @end are zero, however, this function finds the bi= ggest - * 'System RAM' resource and sets the region to cover the resource. In the - * latter case, this function saves the start and end addresses of the res= ource - * in @start and @end, respectively. - * - * Return: 0 on success, negative error code otherwise. - */ -int damon_set_region_biggest_system_ram_default(struct damon_target *t, - unsigned long *start, unsigned long *end, - unsigned long addr_unit, unsigned long min_region_sz) -{ - struct damon_addr_range addr_range; - - if (*start > *end) - return -EINVAL; - - if (!*start && !*end && - !damon_find_biggest_system_ram(start, end, addr_unit)) - return -EINVAL; - - addr_range.start =3D *start; - addr_range.end =3D *end; - return damon_set_regions(t, &addr_range, 1, min_region_sz); -} - /* * damon_moving_sum() - Calculate an inferred moving sum value. * @mvsum: Inferred sum of the last @len_window values. --=20 2.47.3 From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A7232F531F; Wed, 15 Apr 2026 01:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216058; cv=none; b=i+61HDjM9ezvOFpRFqhqG7znCcH5GWLRRP63W9s1MUlE1VQzb6CGQ3Qei53XLwSiPu5724UEOh0SX4g5o8DWE9xulrF0Kdv4UgKUEx5XR2Nx6fTm1aYxwjAAaLi2m5c8B99dXOA13ASaPHqYYb2VqAQA8poGtAaXs06bWX2uRyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216058; c=relaxed/simple; bh=N5D6bRH3BZfS+yc275UKlEY8TXSI6Z9gc0T71/W6wpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A9ed/KWaTuuKwdpNx8nguCrcFsCofoCF3U2NkjsKw/TbPDkAApUkbNzlmrYUfsNvt6DPeHJkEEmTiXECxMSVLSYiYNh6YaeCZ9Ck4ZH0vLQ/Oyvfh2a89jxhPbANH2lYHxpPKR2SF77AghIV5kD6aMPo4lQfnk+4QSvnE7r64DU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CnTw+psW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CnTw+psW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20456C2BCB3; Wed, 15 Apr 2026 01:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216058; bh=N5D6bRH3BZfS+yc275UKlEY8TXSI6Z9gc0T71/W6wpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CnTw+psWl8aAIVYof592X9ltj79ixjRksFlUcDFybT/C6QT2R2sbnm3AxFn1pR3o7 OzbY23Ixwq4WX/1PGbQz/OX5w+x0VxoPXNhppwDvNFK3P37PgEjHP/BxYHsbDXDAST U/TW5Wm9RS3HuiaaPtcYlya0QIBrgWWg+pExCZWd52QbUmGH/aYLjh+ekFGKGBSlAH py3vdGmOoFW7Ha48wm9YpXVhnISzH6Btws5rRhpSNK8YKVOt2VlWJWziWeCvUNVkgg /Smgt+0dqFKVUSt+EfZ5F4x3qXV/P2iWuyHqfGsy3ehDtgJ4Kbh18nEIaeEA8FwGGD xTsZRBYdnDSaA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 5/7] mm/damon/stat: use damon_set_region_system_rams_default() Date: Tue, 14 Apr 2026 18:20:33 -0700 Message-ID: <20260415012048.76508-6-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" damon_stat_set_moniotirng_region() is nearly a duplicate of the core function, damon_set_region_system_rams_default(). Use the core implementation. Signed-off-by: SeongJae Park --- mm/damon/stat.c | 53 +++---------------------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/mm/damon/stat.c b/mm/damon/stat.c index 4901e9a7c3398..da2ebf90ef64e 100644 --- a/mm/damon/stat.c +++ b/mm/damon/stat.c @@ -154,59 +154,12 @@ static int damon_stat_damon_call_fn(void *data) return 0; } =20 -struct damon_stat_system_ram_range_walk_arg { - bool walked; - struct resource res; -}; - -static int damon_stat_system_ram_walk_fn(struct resource *res, void *arg) -{ - struct damon_stat_system_ram_range_walk_arg *a =3D arg; - - if (!a->walked) { - a->walked =3D true; - a->res.start =3D res->start; - } - a->res.end =3D res->end; - return 0; -} - -static unsigned long damon_stat_res_to_core_addr(resource_size_t ra, - unsigned long addr_unit) -{ - /* - * Use div_u64() for avoiding linking errors related with __udivdi3, - * __aeabi_uldivmod, or similar problems. This should also improve the - * performance optimization (read div_u64() comment for the detail). - */ - if (sizeof(ra) =3D=3D 8 && sizeof(addr_unit) =3D=3D 4) - return div_u64(ra, addr_unit); - return ra / addr_unit; -} - -static int damon_stat_set_monitoring_region(struct damon_target *t, - unsigned long addr_unit, unsigned long min_region_sz) -{ - struct damon_addr_range addr_range; - struct damon_stat_system_ram_range_walk_arg arg =3D {}; - - walk_system_ram_res(0, -1, &arg, damon_stat_system_ram_walk_fn); - if (!arg.walked) - return -EINVAL; - addr_range.start =3D damon_stat_res_to_core_addr( - arg.res.start, addr_unit); - addr_range.end =3D damon_stat_res_to_core_addr( - arg.res.end + 1, addr_unit); - if (addr_range.end <=3D addr_range.start) - return -EINVAL; - return damon_set_regions(t, &addr_range, 1, min_region_sz); -} - static struct damon_ctx *damon_stat_build_ctx(void) { struct damon_ctx *ctx; struct damon_attrs attrs; struct damon_target *target; + unsigned long start =3D 0, end =3D 0; =20 ctx =3D damon_new_ctx(); if (!ctx) @@ -236,8 +189,8 @@ static struct damon_ctx *damon_stat_build_ctx(void) if (!target) goto free_out; damon_add_target(ctx, target); - if (damon_stat_set_monitoring_region(target, ctx->addr_unit, - ctx->min_region_sz)) + if (damon_set_region_system_rams_default(target, &start, &end, + ctx->addr_unit, ctx->min_region_sz)) goto free_out; return ctx; free_out: --=20 2.47.3 From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 180313016EB; Wed, 15 Apr 2026 01:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216059; cv=none; b=LhyyRB6feVY0bMWL1fsN+qSWv4g4quhdwVO+mhiL9xN6KJi6/DUmcfIcDqVXVjm/I+4Ziafsw7Q2QQbLGUpke+p/v6CLb5QuqLL4gLBq0tvQpWYLPskFHhxUKu/GnfdAaKeadphmkW/lpZiRVUo5ifUN5YNXRszXC6/qVNvWBMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216059; c=relaxed/simple; bh=Da5/SEejhoG/cyXVJpn39CgULzBmR9p+dGF7QD34w0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zf39zLgaCt1+URkTSu5kNsR/UvAigO/zSpeQa4RvMVNbsTDsjdM+BNgs8KXvNMMBF0uDl0O88+R8vGTYg74mcXYpDSyHVBIqCR7mTHLr5POcQZaWIIZv/tvTpjkH8F/VYnn2v0yccV3yJLUU5MVMZGRil/KFYFbf8IwAd+K83RI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ojB68Fzi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ojB68Fzi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E061C19425; Wed, 15 Apr 2026 01:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216058; bh=Da5/SEejhoG/cyXVJpn39CgULzBmR9p+dGF7QD34w0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ojB68FziWg70XqRdPmUGGSPM9jWyeQ4u7trrbqB1Hu3t6tG1YQXVtcaenU4cBf6ra zUzQW8zSjRdN0UxfF0dE4bXQD5A/pAhUKi1iX32c9xDlHQpfyYw5OIbdJOKTCHMTqS Z7bAmSg0KDpdRi0lzWxYKehwY3a20/hfE9GAPuUwwpdvGOaX3/tF484sPWQYVAbfkC 1vx/1AYP16HMLhc9UnI7mK9m/DLOM3toZXrBHus3FPoNp/jjGZ1kkV3vSVE48t8gFU qDx2S0zXE+oRHQ0+UPG0XZwmnWdPHLO4w3h9E45MQKJkt9MbnPpMnA49bHqcmrprBC fXrHGfeALiHqw== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 6/7] Docs/admin-guide/mm/damon/reclaim: update for entire memory monitoring Date: Tue, 14 Apr 2026 18:20:34 -0700 Message-ID: <20260415012048.76508-7-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMON_RECLAIM usage document for the changed default monitoring target region selection. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/reclaim.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation= /admin-guide/mm/damon/reclaim.rst index b14a065586271..ec7e3e32b4ac6 100644 --- a/Documentation/admin-guide/mm/damon/reclaim.rst +++ b/Documentation/admin-guide/mm/damon/reclaim.rst @@ -240,7 +240,8 @@ Start of target memory region in physical address. =20 The start physical address of memory region that DAMON_RECLAIM will do work against. That is, DAMON_RECLAIM will find cold memory regions in this reg= ion -and reclaims. By default, biggest System RAM is used as the region. +and reclaims. By default, the system's entire physical memory is used as = the +region. =20 monitor_region_end ------------------ @@ -249,7 +250,8 @@ End of target memory region in physical address. =20 The end physical address of memory region that DAMON_RECLAIM will do work against. That is, DAMON_RECLAIM will find cold memory regions in this reg= ion -and reclaims. By default, biggest System RAM is used as the region. +and reclaims. By default, the system's entire physical memory is used as = the +region. =20 addr_unit --------- --=20 2.47.3 From nobody Tue Jun 16 01:16:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5D8B7260D; Wed, 15 Apr 2026 01:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216059; cv=none; b=lmluEuRDJ3s16Se0efaNL2+c91SPa7a937ptZm8o9dj9tztsJUPq2JXZ5C4rEFOCIVGWNVxNc+p6OcZTbe0441HV+safqCxScExrrUSDMjNcqs9UT7nGHu00piKk0M/0nBgp/VAStAlCdE8u+6IMctQB10Pi7Ooet5M8CfJREtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776216059; c=relaxed/simple; bh=DstdtJTxjDChhGDlgpo8hhIle9ABxcUjhKJsfY7hfhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tvV2qrl4poADsW6kmLrIodZyW0wtlTGYJPmeSR4PGCv9tnfEouwbuTEJCykOtEVsdkV0Wu+ei+7vW2UQ/t9ywZeu5QDK+tQV22ZE2lToDK8HlHC7aUZeDf7FnZ5E4RCmqS1sYIGvlWsdvVx0M+hhzcciDFgp3b9hMmnHaJcilxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X11PWJG3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X11PWJG3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B8B3C2BCB3; Wed, 15 Apr 2026 01:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776216059; bh=DstdtJTxjDChhGDlgpo8hhIle9ABxcUjhKJsfY7hfhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X11PWJG3DoyCdwo0kmy8K1QumXjfCBzqpVmpQ8z6UHj45Tx7uZkXnsrlkqQKR/fpA vKiVuxnMUpslv9P9F/VaHo89XVjAcCJHnRVB/HXTBK/9HWJS3d9Dm5+HDAAdmhNr1g VfNO3aEC/3GsPS5oLDVCsgAlUtoh2uHmj1jx2z1OAsc7GYNrqyT5WJJwCxrfW562mC ETt0+5MXhtpvii2faQu/fIRzhfpdyen8YqDfgMf8667O3sqp4a4/oHRnaG0R4Qw8vX uh11VIHnV/wRdEgo5OI83UclPt3xpe2ysGbpDHLX/iXFt/jUoiJbi0BbSSdNbTHb9A TDnP20D5ppmFg== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 7/7] Docs/admin-guide/mm/damon/lru_sort: update for entire memory monitoring Date: Tue, 14 Apr 2026 18:20:35 -0700 Message-ID: <20260415012048.76508-8-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260415012048.76508-1-sj@kernel.org> References: <20260415012048.76508-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMON_LRU_SORT usage document for the changed default monitoring target region selection. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/lru_sort.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentatio= n/admin-guide/mm/damon/lru_sort.rst index 25e2f042a383f..796b0a028555d 100644 --- a/Documentation/admin-guide/mm/damon/lru_sort.rst +++ b/Documentation/admin-guide/mm/damon/lru_sort.rst @@ -246,7 +246,8 @@ monitor_region_start Start of target memory region in physical address. =20 The start physical address of memory region that DAMON_LRU_SORT will do wo= rk -against. By default, biggest System RAM is used as the region. +against. By default, the system's entire phyiscal memory is used as the +region. =20 monitor_region_end ------------------ @@ -254,7 +255,8 @@ monitor_region_end End of target memory region in physical address. =20 The end physical address of memory region that DAMON_LRU_SORT will do work -against. By default, biggest System RAM is used as the region. +against. By default, the system's entire physical memory is used as the +region. =20 addr_unit --------- --=20 2.47.3