]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/damon/sysfs-schemes: implement quota effective_bytes file
authorSeongJae Park <sj@kernel.org>
Mon, 19 Feb 2024 19:44:13 +0000 (11:44 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 24 Feb 2024 01:48:26 +0000 (17:48 -0800)
DAMON sysfs interface allows users to set two types of quotas, namely time
quota and size quota.  DAMOS converts time quota to a size quota and use
smaller one among the resulting two size quotas.  The resulting effective
size quota can be helpful for debugging and analysis, but not exposed to
the user.  The recently added feedback-driven quota auto-tuning is making
it even more mysterious.

Implement a DAMON sysfs interface read-only empty file, namely
'effective_bytes', under the quota goal DAMON sysfs directory.  It will be
extended to expose the effective quota to the end user.

Link: https://lkml.kernel.org/r/20240219194431.159606-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs-schemes.c

index f6c7f43f06cc07c30b2a6603c4f9d074218cd637..dd46b2db5455af41296a633a3f96e300d9d55a3b 100644 (file)
@@ -1139,6 +1139,7 @@ struct damon_sysfs_quotas {
        unsigned long ms;
        unsigned long sz;
        unsigned long reset_interval_ms;
+       unsigned long effective_sz;     /* Effective size quota in bytes */
 };
 
 static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void)
@@ -1252,6 +1253,15 @@ static ssize_t reset_interval_ms_store(struct kobject *kobj,
        return count;
 }
 
+static ssize_t effective_bytes_show(struct kobject *kobj,
+               struct kobj_attribute *attr, char *buf)
+{
+       struct damon_sysfs_quotas *quotas = container_of(kobj,
+                       struct damon_sysfs_quotas, kobj);
+
+       return sysfs_emit(buf, "%lu\n", quotas->effective_sz);
+}
+
 static void damon_sysfs_quotas_release(struct kobject *kobj)
 {
        kfree(container_of(kobj, struct damon_sysfs_quotas, kobj));
@@ -1266,10 +1276,14 @@ static struct kobj_attribute damon_sysfs_quotas_sz_attr =
 static struct kobj_attribute damon_sysfs_quotas_reset_interval_ms_attr =
                __ATTR_RW_MODE(reset_interval_ms, 0600);
 
+static struct kobj_attribute damon_sysfs_quotas_effective_bytes_attr =
+               __ATTR_RO_MODE(effective_bytes, 0400);
+
 static struct attribute *damon_sysfs_quotas_attrs[] = {
        &damon_sysfs_quotas_ms_attr.attr,
        &damon_sysfs_quotas_sz_attr.attr,
        &damon_sysfs_quotas_reset_interval_ms_attr.attr,
+       &damon_sysfs_quotas_effective_bytes_attr.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(damon_sysfs_quotas);