From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>, Andrew Morton <akpm@linux-foundation.org>
Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 13/18] mm/damon/sysfs-schemes: implement schemes/tried_regions directory
Date: Wed, 19 Oct 2022 00:13:12 +0000 [thread overview]
Message-ID: <20221019001317.104270-14-sj@kernel.org> (raw)
In-Reply-To: <20221019001317.104270-1-sj@kernel.org>
For deep level investigation of DAMON and efficient query-like
monitoring results reading, DAMON kernel API (include/linux/damon.h)
users can use 'before_damos_apply' DAMON callback. However, DAMON sysfs
interface users don't have such option. Add a directory, namely
'tried_regions', under each scheme directory to use it as the interface
for the purpose. That is, users will be able to signal DAMON to fill
the directory with the regions that corresponding scheme has tried to be
applied. By setting the access pattern of the scheme, users could do the
efficient query-like monitoring. Note that this commit is implementing
only the directory but the data filling.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 57 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 7ea4bcce90cb..f9714ac62565 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -9,6 +9,36 @@
#include "sysfs-common.h"
+/*
+ * scheme regions directory
+ */
+
+struct damon_sysfs_scheme_regions {
+ struct kobject kobj;
+};
+
+static struct damon_sysfs_scheme_regions *
+damon_sysfs_scheme_regions_alloc(void)
+{
+ return kzalloc(sizeof(struct damon_sysfs_scheme_regions), GFP_KERNEL);
+}
+
+static void damon_sysfs_scheme_regions_release(struct kobject *kobj)
+{
+ kfree(container_of(kobj, struct damon_sysfs_scheme_regions, kobj));
+}
+
+static struct attribute *damon_sysfs_scheme_regions_attrs[] = {
+ NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_scheme_regions);
+
+static struct kobj_type damon_sysfs_scheme_regions_ktype = {
+ .release = damon_sysfs_scheme_regions_release,
+ .sysfs_ops = &kobj_sysfs_ops,
+ .default_groups = damon_sysfs_scheme_regions_groups,
+};
+
/*
* schemes/stats directory
*/
@@ -635,6 +665,7 @@ struct damon_sysfs_scheme {
struct damon_sysfs_quotas *quotas;
struct damon_sysfs_watermarks *watermarks;
struct damon_sysfs_stats *stats;
+ struct damon_sysfs_scheme_regions *tried_regions;
};
/* This should match with enum damos_action */
@@ -743,6 +774,25 @@ static int damon_sysfs_scheme_set_stats(struct damon_sysfs_scheme *scheme)
return err;
}
+static int damon_sysfs_scheme_set_tried_regions(
+ struct damon_sysfs_scheme *scheme)
+{
+ struct damon_sysfs_scheme_regions *tried_regions =
+ damon_sysfs_scheme_regions_alloc();
+ int err;
+
+ if (!tried_regions)
+ return -ENOMEM;
+ err = kobject_init_and_add(&tried_regions->kobj,
+ &damon_sysfs_scheme_regions_ktype, &scheme->kobj,
+ "tried_regions");
+ if (err)
+ kobject_put(&tried_regions->kobj);
+ else
+ scheme->tried_regions = tried_regions;
+ return err;
+}
+
static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme)
{
int err;
@@ -759,8 +809,14 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme)
err = damon_sysfs_scheme_set_stats(scheme);
if (err)
goto put_watermarks_quotas_access_pattern_out;
+ err = damon_sysfs_scheme_set_tried_regions(scheme);
+ if (err)
+ goto put_tried_regions_out;
return 0;
+put_tried_regions_out:
+ kobject_put(&scheme->tried_regions->kobj);
+ scheme->tried_regions = NULL;
put_watermarks_quotas_access_pattern_out:
kobject_put(&scheme->watermarks->kobj);
scheme->watermarks = NULL;
@@ -781,6 +837,7 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme)
kobject_put(&scheme->quotas->kobj);
kobject_put(&scheme->watermarks->kobj);
kobject_put(&scheme->stats->kobj);
+ kobject_put(&scheme->tried_regions->kobj);
}
static ssize_t action_show(struct kobject *kobj, struct kobj_attribute *attr,
--
2.25.1
next prev parent reply other threads:[~2022-10-19 0:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 0:12 [RFC PATCH 00/18] efficiently expose damos action tried regions information SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 01/18] mm/damon/modules: deduplicate init steps for DAMON context setup SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 02/18] mm/damon/core: split out DAMOS-charged region skip logic into a new function SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 03/18] mm/damon/core: split damos application " SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 04/18] mm/damon/core: split out scheme stat update " SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 05/18] mm/damon/core: split out scheme quota adjustment " SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 06/18] mm/damon/core: add a DAMON callback for scheme target regions check SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 07/18] mm/damon/sysfs: Use damon_addr_range for regions' start and end values SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 08/18] mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc() SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 09/18] mm/damon/sysfs: move sysfs_lock to common module SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 10/18] mm/damon/sysfs: move unsigned long range directory " SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 11/18] mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 12/18] mm/damon/sysfs: move schemes directory implementation to separate module SeongJae Park
2022-10-19 0:13 ` SeongJae Park [this message]
2022-10-19 0:13 ` [RFC PATCH 14/18] mm/damon/sysfs-schemes: implement scheme region directory SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 15/18] mm/damon/sysfs: implement DAMOS-tried regions update command SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 16/18] mm/damon/sysfs-schemes: implement DAMOS tried regions clear command SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 17/18] Docs/admin-guide/mm/damon/usage: document schemes/<s>/tried_regions directory SeongJae Park
2022-10-19 0:13 ` [RFC PATCH 18/18] Docs/ABI/damon: document 'schemes/<s>/tried_regions' directory SeongJae Park
2022-10-19 17:32 ` [RFC PATCH 00/18] efficiently expose damos action tried regions information SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221019001317.104270-14-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox