Skip to content

Commit

Permalink
mm/damon/reclaim: fix quota stauts loss due to online tunings
Browse files Browse the repository at this point in the history
commit 1b0ca4e upstream.

Patch series "mm/damon: fix quota status loss due to online tunings".

DAMON_RECLAIM and DAMON_LRU_SORT is not preserving internal quota status
when applying new user parameters, and hence could cause temporal quota
accuracy degradation.  Fix it by preserving the status.


This patch (of 2):

For online parameters change, DAMON_RECLAIM creates new scheme based on
latest values of the parameters and replaces the old scheme with the new
one.  When creating it, the internal status of the quota of the old
scheme is not preserved.  As a result, charging of the quota starts from
zero after the online tuning.  The data that collected to estimate the
throughput of the scheme's action is also reset, and therefore the
estimation should start from the scratch again.  Because the throughput
estimation is being used to convert the time quota to the effective size
quota, this could result in temporal time quota inaccuracy.  It would be
recovered over time, though.  In short, the quota accuracy could be
temporarily degraded after online parameters update.

Fix the problem by checking the case and copying the internal fields for
the status.

Link: https://lkml.kernel.org/r/20240216194025.9207-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20240216194025.9207-2-sj@kernel.org
Fixes: e035c28 ("mm/damon/reclaim: support online inputs update")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[5.19+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
sjp38 authored and gregkh committed Mar 1, 2024
1 parent 8350888 commit 9cad9a2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion mm/damon/reclaim.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,20 @@ static struct damos *damon_reclaim_new_scheme(void)
&damon_reclaim_wmarks);
}

static void damon_reclaim_copy_quota_status(struct damos_quota *dst,
struct damos_quota *src)
{
dst->total_charged_sz = src->total_charged_sz;
dst->total_charged_ns = src->total_charged_ns;
dst->charged_sz = src->charged_sz;
dst->charged_from = src->charged_from;
dst->charge_target_from = src->charge_target_from;
dst->charge_addr_from = src->charge_addr_from;
}

static int damon_reclaim_apply_parameters(void)
{
struct damos *scheme;
struct damos *scheme, *old_scheme;
struct damos_filter *filter;
int err = 0;

Expand All @@ -162,6 +173,11 @@ static int damon_reclaim_apply_parameters(void)
scheme = damon_reclaim_new_scheme();
if (!scheme)
return -ENOMEM;
if (!list_empty(&ctx->schemes)) {
damon_for_each_scheme(old_scheme, ctx)
damon_reclaim_copy_quota_status(&scheme->quota,
&old_scheme->quota);
}
if (skip_anon) {
filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true);
if (!filter) {
Expand Down

0 comments on commit 9cad9a2

Please sign in to comment.