Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/lru_sort: support addr_unit for DAMON_LRU_SORT

Patch series "mm/damon: add addr_unit for DAMON_LRU_SORT and
DAMON_RECLAIM".

In DAMON_LRU_SORT and DAMON_RECLAIM, damon_ctx is independent of the core.
Add addr_unit to these modules to support systems like ARM32 with LPAE.


This patch (of 2):

Implement a sysfs file to expose addr_unit for DAMON_LRU_SORT users.
During parameter application, use the configured addr_unit parameter to
perform the necessary initialization. Similar to the core layer, prevent
setting addr_unit to zero.

It is worth noting that when monitor_region_start and monitor_region_end
are unset (i.e., 0), their values will later be set to biggest_system_ram.
At that point, addr_unit may not be the default value 1. Although we
could divide the biggest_system_ram value by addr_unit, changing addr_unit
without setting monitor_region_start/end should be considered a user
misoperation. And biggest_system_ram is only within the 0~ULONG_MAX
range, system can clearly work correctly with addr_unit=1. Therefore, if
monitor_region_start/end are unset, always silently reset addr_unit to 1.

Link: https://lkml.kernel.org/r/20250910113221.1065764-1-yanquanmin1@huawei.com
Link: https://lkml.kernel.org/r/20250910113221.1065764-2-yanquanmin1@huawei.com
Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: ze zuo <zuoze1@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Quanmin Yan and committed by
Andrew Morton
2e0fe924 a5883fa9

+40
+40
mm/damon/lru_sort.c
··· 112 112 module_param(monitor_region_end, ulong, 0600); 113 113 114 114 /* 115 + * Scale factor for DAMON_LRU_SORT to ops address conversion. 116 + * 117 + * This parameter must not be set to 0. 118 + */ 119 + static unsigned long addr_unit __read_mostly = 1; 120 + 121 + /* 115 122 * PID of the DAMON thread 116 123 * 117 124 * If DAMON_LRU_SORT is enabled, this becomes the PID of the worker thread. ··· 204 197 err = damon_modules_new_paddr_ctx_target(&param_ctx, &param_target); 205 198 if (err) 206 199 return err; 200 + 201 + /* 202 + * If monitor_region_start/end are unset, always silently 203 + * reset addr_unit to 1. 204 + */ 205 + if (!monitor_region_start && !monitor_region_end) 206 + addr_unit = 1; 207 + param_ctx->addr_unit = addr_unit; 208 + param_ctx->min_sz_region = max(DAMON_MIN_REGION / addr_unit, 1); 207 209 208 210 if (!damon_lru_sort_mon_attrs.sample_interval) { 209 211 err = -EINVAL; ··· 305 289 kdamond_pid = ctx->kdamond->pid; 306 290 return damon_call(ctx, &call_control); 307 291 } 292 + 293 + static int damon_lru_sort_addr_unit_store(const char *val, 294 + const struct kernel_param *kp) 295 + { 296 + unsigned long input_addr_unit; 297 + int err = kstrtoul(val, 0, &input_addr_unit); 298 + 299 + if (err) 300 + return err; 301 + if (!input_addr_unit) 302 + return -EINVAL; 303 + 304 + addr_unit = input_addr_unit; 305 + return 0; 306 + } 307 + 308 + static const struct kernel_param_ops addr_unit_param_ops = { 309 + .set = damon_lru_sort_addr_unit_store, 310 + .get = param_get_ulong, 311 + }; 312 + 313 + module_param_cb(addr_unit, &addr_unit_param_ops, &addr_unit, 0600); 314 + MODULE_PARM_DESC(addr_unit, 315 + "Scale factor for DAMON_LRU_SORT to ops address conversion (default: 1)"); 308 316 309 317 static int damon_lru_sort_enabled_store(const char *val, 310 318 const struct kernel_param *kp)