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 active:inactive memory ratio based auto-tuning

Doing DAMOS_LRU_[DE]PRIO with DAMOS_QUOTA_[IN]ACTIVE_MEM_BP based quota
auto-tuning can be easy and intuitive, compared to the manual
[de]prioritization target access pattern thresholds tuning. For example,
users can ask DAMON to "find hot/cold pages and activate/deactivate those
aiming 50:50 active:inactive memory size." But DAMON_LRU_SORT has no
interface to do that. Add a module parameter for setting the target
ratio.

[sj@kernel.org: add inactive mem ratio quota goal to cold_scheme]
Link: https://lkml.kernel.org/r/20260114055308.79884-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20260113152717.70459-9-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
40d98d31 b36aefb8

+37
+37
mm/damon/lru_sort.c
··· 42 42 module_param(commit_inputs, bool, 0600); 43 43 44 44 /* 45 + * Desired active to [in]active memory ratio in bp (1/10,000). 46 + * 47 + * While keeping the caps that set by other quotas, DAMON_LRU_SORT 48 + * automatically increases and decreases the effective level of the quota 49 + * aiming the LRU [de]prioritizations of the hot and cold memory resulting in 50 + * this active to [in]active memory ratio. Value zero means disabling this 51 + * auto-tuning feature. 52 + * 53 + * Disabled by default. 54 + */ 55 + static unsigned long active_mem_bp __read_mostly; 56 + module_param(active_mem_bp, ulong, 0600); 57 + 58 + /* 45 59 * Filter [non-]young pages accordingly for LRU [de]prioritizations. 46 60 * 47 61 * If this is set, check page level access (youngness) once again before each ··· 222 208 return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); 223 209 } 224 210 211 + static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme, 212 + struct damos *cold_scheme) 213 + { 214 + struct damos_quota_goal *goal; 215 + 216 + if (!active_mem_bp) 217 + return 0; 218 + goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp); 219 + if (!goal) 220 + return -ENOMEM; 221 + damos_add_quota_goal(&hot_scheme->quota, goal); 222 + /* aim 0.2 % goal conflict, to keep little ping pong */ 223 + goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP, 224 + 10000 - active_mem_bp + 2); 225 + if (!goal) 226 + return -ENOMEM; 227 + damos_add_quota_goal(&cold_scheme->quota, goal); 228 + return 0; 229 + } 230 + 225 231 static int damon_lru_sort_add_filters(struct damos *hot_scheme, 226 232 struct damos *cold_scheme) 227 233 { ··· 311 277 damon_set_schemes(param_ctx, &hot_scheme, 1); 312 278 damon_add_scheme(param_ctx, cold_scheme); 313 279 280 + err = damon_lru_sort_add_quota_goals(hot_scheme, cold_scheme); 281 + if (err) 282 + goto out; 314 283 err = damon_lru_sort_add_filters(hot_scheme, cold_scheme); 315 284 if (err) 316 285 goto out;