2020-09-15 18:08:13

by SeongJae Park

[permalink] [raw]
Subject: [RFC PATCH 1/2] mm/damon: Put more information in kdamond thread name

From: SeongJae Park <[email protected]>

While multiple kdamond threads can run, it is hard to distinguish each
thread as all kdamond threads has same name, 'kdamond'. This commit
puts more information including if it is spawned from the user context
(via the debugfs interface) and for what context it is running. The
format of the name is:

kdamond.<current pid>.<# of context>

If it is not spawned from the user context, <current pid> becomes 0.
Using this information, for example, the user space could easily account
CPU usage of DAMON that they requested in fine granularity.

Signed-off-by: SeongJae Park <[email protected]>
---
mm/damon.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/damon.c b/mm/damon.c
index c92e4c76aa53..abb8c07a4c7d 100644
--- a/mm/damon.c
+++ b/mm/damon.c
@@ -1552,6 +1552,8 @@ static bool damon_kdamond_running(struct damon_ctx *ctx)
* __damon_start() - Starts monitoring with given context.
* @ctx: monitoring context
*
+ * This function should be called while damon_lock is hold.
+ *
* Return: 0 on success, negative error code otherwise.
*/
static int __damon_start(struct damon_ctx *ctx)
@@ -1562,7 +1564,8 @@ static int __damon_start(struct damon_ctx *ctx)
if (!ctx->kdamond) {
err = 0;
ctx->kdamond_stop = false;
- ctx->kdamond = kthread_create(kdamond_fn, ctx, "kdamond");
+ ctx->kdamond = kthread_create(kdamond_fn, ctx, "kdamond.%d.%d",
+ current ? current->pid : 0, nr_running_ctxs);
if (IS_ERR(ctx->kdamond))
err = PTR_ERR(ctx->kdamond);
else
--
2.17.1


2020-09-15 18:17:57

by SeongJae Park

[permalink] [raw]
Subject: [RFC PATCH 0/2] DAMON: Improve User Space Interface

From: SeongJae Park <[email protected]>

Seems lore.kernel.org missed original posting of this mail. Resending.

NOTE: This is only an RFC for future features of DAMON patchset[1], which is
not merged in the mainline yet. The aim of this RFC is to show how DAMON would
be evolved once it is merged in. So, if you have some interest in this RFC,
please consider reviewing the DAMON patchset, either.

After posting DAMON patchset[1], we received a number of comments. Based on
those, we listed and shared future works for DAMON in the kernel summit
2020[2] and had a poll for the priorities of the works. As a result, the user
space interface improvement received a second highest priority[3]. For the
reason, this patchset is came out.

The 1st patch puts more information in the monitoring thread name so that user
space could charge the DAMON's CPU usage on them by themselves, in fine
granularity. The 2nd patch makes multiple monitoring contexts available using
the debugfs interface.

[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://linuxplumbersconf.org/event/7/contributions/659/
[3] https://lore.kernel.org/linux-mm/[email protected]/

Baseline and Complete Git Trees
===============================

The patches are based on the v5.8 plus DAMON v20 patchset[1], RFC v14 of DAMOS
patchset, RFC v8 of physical address space support patchset, and some more
trivial fixes (s/snprintf/scnprintf). You can also clone the complete git
tree:

$ git clone git://github.com/sjp38/linux -b damon-usi/rfc/v1

The web is also available:
https://github.com/sjp38/linux/releases/tag/damon-usi/rfc/v1

[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/
[3] https://lore.kernel.org/linux-mm/[email protected]/

SeongJae Park (2):
mm/damon: Put more information in kdamond thread name
mm/damon/debugfs: Support multiple contexts

include/linux/damon.h | 2 +
mm/damon-test.h | 34 ++--
mm/damon.c | 361 +++++++++++++++++++++++++++++++++---------
3 files changed, 308 insertions(+), 89 deletions(-)

--
2.17.1