diff mbox series

[RFC,1/2] mm/damon: Put more information in kdamond thread name

Message ID 20200915180225.17439-2-sjpark@amazon.com (mailing list archive)
State New, archived
Headers show
Series DAMON: Improve User Space Interface | expand

Commit Message

SeongJae Park Sept. 15, 2020, 6:02 p.m. UTC
From: SeongJae Park <sjpark@amazon.de>

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 <sjpark@amazon.de>
 mm/damon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series


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);