static bool commit_inputs __read_mostly;
module_param(commit_inputs, bool, 0600);
+/*
+ * Desired active to [in]active memory ratio in bp (1/10,000).
+ *
+ * While keeping the caps that set by other quotas, DAMON_LRU_SORT
+ * automatically increases and decreases the effective level of the quota
+ * aiming the LRU [de]prioritizations of the hot and cold memory resulting in
+ * this active to [in]active memory ratio. Value zero means disabling this
+ * auto-tuning feature.
+ *
+ * Disabled by default.
+ */
+static unsigned long active_mem_bp __read_mostly;
+module_param(active_mem_bp, ulong, 0600);
+
/*
* Filter [non-]young pages accordingly for LRU [de]prioritizations.
*
return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO);
}
+static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme,
+ struct damos *cold_scheme)
+{
+ struct damos_quota_goal *goal;
+
+ if (!active_mem_bp)
+ return 0;
+ goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp);
+ if (!goal)
+ return -ENOMEM;
+ damos_add_quota_goal(&hot_scheme->quota, goal);
+ /* aim 0.2 % goal conflict, to keep little ping pong */
+ goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP,
+ 10000 - active_mem_bp + 2);
+ if (!goal)
+ return -ENOMEM;
+ damos_add_quota_goal(&cold_scheme->quota, goal);
+ return 0;
+}
+
static int damon_lru_sort_add_filters(struct damos *hot_scheme,
struct damos *cold_scheme)
{
damon_set_schemes(param_ctx, &hot_scheme, 1);
damon_add_scheme(param_ctx, cold_scheme);
+ err = damon_lru_sort_add_quota_goals(hot_scheme, cold_scheme);
+ if (err)
+ goto out;
err = damon_lru_sort_add_filters(hot_scheme, cold_scheme);
if (err)
goto out;