summaryrefslogtreecommitdiff
path: root/mm/damon
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2024-02-19 11:44:18 -0800
committerAndrew Morton <akpm@linux-foundation.org>2024-02-23 17:48:27 -0800
commit106e26fc1c4c1a0e3747246e15df2bc3aa9d46b2 (patch)
tree44bd885a71315399d43fd215ff9ad36141cd0629 /mm/damon
parent4d791a0a2ab47d70131909942009f12f61db20ab (diff)
mm/damon/core: split out quota goal related fields to a struct
'struct damos_quota' is not small now. Split out fields for quota goal to a separate struct for easier reading. Link: https://lkml.kernel.org/r/20240219194431.159606-8-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/damon')
-rw-r--r--mm/damon/core.c13
-rw-r--r--mm/damon/sysfs-schemes.c10
2 files changed, 12 insertions, 11 deletions
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 0656966a6fc4..fe4209672121 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1083,21 +1083,22 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input,
return min_input;
}
-/* Shouldn't be called if quota->ms, quota->sz, and quota->get_score unset */
+/* Called only if quota->ms, quota->sz, or quota->goal.get_score are set */
static void damos_set_effective_quota(struct damos_quota *quota)
{
unsigned long throughput;
unsigned long esz;
- if (!quota->ms && !quota->get_score) {
+ if (!quota->ms && !quota->goal.get_score) {
quota->esz = quota->sz;
return;
}
- if (quota->get_score) {
+ if (quota->goal.get_score) {
quota->esz_bp = damon_feed_loop_next_input(
max(quota->esz_bp, 10000UL),
- quota->get_score(quota->get_score_arg));
+ quota->goal.get_score(
+ quota->goal.get_score_arg));
esz = quota->esz_bp / 10000;
}
@@ -1107,7 +1108,7 @@ static void damos_set_effective_quota(struct damos_quota *quota)
quota->total_charged_ns;
else
throughput = PAGE_SIZE * 1024;
- if (quota->get_score)
+ if (quota->goal.get_score)
esz = min(throughput * quota->ms, esz);
else
esz = throughput * quota->ms;
@@ -1127,7 +1128,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
unsigned long cumulated_sz;
unsigned int score, max_score = 0;
- if (!quota->ms && !quota->sz && !quota->get_score)
+ if (!quota->ms && !quota->sz && !quota->goal.get_score)
return;
/* New charge window starts */
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 9d90e7b757b7..85ef58f98a87 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -1894,19 +1894,19 @@ static void damos_sysfs_set_quota_score(
struct damos_sysfs_quota_goal *sysfs_goal;
int i;
- quota->get_score = NULL;
- quota->get_score_arg = (void *)0;
+ quota->goal.get_score = NULL;
+ quota->goal.get_score_arg = (void *)0;
for (i = 0; i < sysfs_goals->nr; i++) {
sysfs_goal = sysfs_goals->goals_arr[i];
if (!sysfs_goal->target_value)
continue;
/* Higher score makes scheme less aggressive */
- quota->get_score_arg = (void *)max(
- (unsigned long)quota->get_score_arg,
+ quota->goal.get_score_arg = (void *)max(
+ (unsigned long)quota->goal.get_score_arg,
sysfs_goal->current_value * 10000 /
sysfs_goal->target_value);
- quota->get_score = damos_sysfs_get_quota_score;
+ quota->goal.get_score = damos_sysfs_get_quota_score;
}
}