lkml.org 
[lkml]   [2020]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 1/2] mm/damon: Put more information in kdamond thread name
Date
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 --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
\
 
 \ /
  Last update: 2020-09-15 20:07    [W:0.162 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site