From: SeongJae Park <sjpark@amazon.com>
To: SeongJae Park <sjpark@amazon.com>
Cc: <akpm@linux-foundation.org>, <Jonathan.Cameron@Huawei.com>,
<aarcange@redhat.com>, <acme@kernel.org>,
<alexander.shishkin@linux.intel.com>, <amit@kernel.org>,
<benh@kernel.crashing.org>, <brendan.d.gregg@gmail.com>,
<brendanhiggins@google.com>, <cai@lca.pw>,
<colin.king@canonical.com>, <corbet@lwn.net>, <david@redhat.com>,
<dwmw@amazon.com>, <elver@google.com>, <fan.du@intel.com>,
<foersleo@amazon.de>, <gthelen@google.com>, <irogers@google.com>,
<jolsa@redhat.com>, <kirill@shutemov.name>,
<mark.rutland@arm.com>, <mgorman@suse.de>, <minchan@kernel.org>,
<mingo@redhat.com>, <namhyung@kernel.org>, <peterz@infradead.org>,
<rdunlap@infradead.org>, <riel@surriel.com>,
<rientjes@google.com>, <rostedt@goodmis.org>, <rppt@kernel.org>,
<sblbir@amazon.com>, <shakeelb@google.com>, <shuah@kernel.org>,
<sj38.park@gmail.com>, <snu@amazon.de>, <vbabka@suse.cz>,
<vdavydov.dev@gmail.com>, <yang.shi@linux.alibaba.com>,
<ying.huang@intel.com>, <zgf574564920@gmail.com>,
<linux-damon@amazon.com>, <linux-mm@kvack.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v23 10/15] mm/damon/dbgfs: Support multiple contexts
Date: Tue, 2 Feb 2021 13:27:34 +0100 [thread overview]
Message-ID: <20210202122734.15627-1-sjpark@amazon.com> (raw)
In-Reply-To: <20201215115448.25633-11-sjpark@amazon.com>
On Tue, 15 Dec 2020 12:54:43 +0100 SeongJae Park <sjpark@amazon.com> wrote:
> From: SeongJae Park <sjpark@amazon.de>
>
> In some use cases, users would want to run multiple monitoring context.
> For example, if a user wants a high precision monitoring and dedicating
> multiple CPUs for the job is ok, because DAMON creates one monitoring
> thread per one context, the user can split the monitoring target regions
> into multiple small regions and create one context for each region. Or,
> someone might want to simultaneously monitor different address spaces,
> e.g., both virtual address space and physical address space.
>
> The DAMON's API allows such usage, but 'damon-dbgfs' does not.
> Therefore, only kernel space DAMON users can do multiple contexts
> monitoring.
>
> This commit allows the user space DAMON users to use multiple contexts
> monitoring by introducing two new 'damon-dbgfs' debugfs files,
> 'mk_context' and 'rm_context'. Users can create a new monitoring
> context by writing the desired name of the new context to 'mk_context'.
> Then, a new directory with the name and having the files for setting of
> the context ('attrs', 'target_ids' and 'record') will be created under
> the debugfs directory. Writing the name of the context to remove to
> 'rm_context' will remove the related context and directory.
>
> Signed-off-by: SeongJae Park <sjpark@amazon.de>
> ---
> mm/damon/dbgfs.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 211 insertions(+), 2 deletions(-)
>
> diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
> index a1512d3e5afe..46186b057e1a 100644
> --- a/mm/damon/dbgfs.c
> +++ b/mm/damon/dbgfs.c
[...]
> +/*
> + * Remove a context of @name and its debugfs directory.
> + *
> + * This function should be called while holding damon_dbgfs_lock.
> + *
> + * Return 0 on success, negative error code otherwise.
> + */
> +static int dbgfs_rm_context(char *name)
> +{
> + struct dentry *root, *dir, **new_dirs;
> + struct damon_ctx **new_ctxs;
> + int i, j;
> +
> + if (damon_nr_running_ctxs())
> + return -EBUSY;
> +
> + root = dbgfs_dirs[0];
> + if (!root)
> + return -ENOENT;
> +
> + dir = debugfs_lookup(name, root);
> + if (!dir)
> + return -ENOENT;
> +
> + new_dirs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_dirs),
> + GFP_KERNEL);
> + if (!new_dirs)
> + return -ENOMEM;
> +
> + new_ctxs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_ctxs),
> + GFP_KERNEL);
> + if (!new_ctxs) {
> + kfree(new_dirs);
> + return -ENOMEM;
> + }
> +
> + for (i = 0, j = 0; i < dbgfs_nr_ctxs; i++) {
> + if (dbgfs_dirs[i] == dir) {
> + debugfs_remove(dbgfs_dirs[i]);
> + dbgfs_destroy_ctx(dbgfs_ctxs[i]);
In case of virtual address monitoring, dbgfs_destroy_ctx() calls
damon_destroy_ctx() and damon_destroy_ctx() doesn't put the target pids. I
will fix this in the next version.
> + continue;
> + }
> + new_dirs[j] = dbgfs_dirs[i];
> + new_ctxs[j++] = dbgfs_ctxs[i];
> + }
> +
> + kfree(dbgfs_dirs);
> + kfree(dbgfs_ctxs);
> +
> + dbgfs_dirs = new_dirs;
> + dbgfs_ctxs = new_ctxs;
> + dbgfs_nr_ctxs--;
> +
> + return 0;
> +}
Thanks,
SeongJae Park
[...]
next prev parent reply other threads:[~2021-02-02 12:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 11:54 [PATCH v23 00/15] Introduce Data Access MONitor (DAMON) SeongJae Park
2020-12-15 11:54 ` [PATCH v23 01/15] mm: " SeongJae Park
2020-12-23 15:11 ` Shakeel Butt
2020-12-23 16:33 ` SeongJae Park
2020-12-23 22:49 ` Shakeel Butt
2020-12-24 7:02 ` SeongJae Park
2020-12-15 11:54 ` [PATCH v23 02/15] mm/damon/core: Implement region-based sampling SeongJae Park
2021-02-01 17:37 ` Shakeel Butt
2021-02-02 9:17 ` SeongJae Park
2020-12-15 11:54 ` [PATCH v23 03/15] mm/damon: Adaptively adjust regions SeongJae Park
2021-01-19 18:36 ` SeongJae Park
2021-02-01 17:37 ` Shakeel Butt
2021-02-02 9:39 ` SeongJae Park
2020-12-15 11:54 ` [PATCH v23 04/15] mm/idle_page_tracking: Make PG_idle reusable SeongJae Park
2020-12-23 15:11 ` Shakeel Butt
2020-12-15 11:54 ` [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces SeongJae Park
2020-12-23 15:31 ` Shakeel Butt
2020-12-23 16:47 ` SeongJae Park
2020-12-23 22:54 ` Shakeel Butt
2020-12-24 7:11 ` SeongJae Park
2021-01-27 16:56 ` SeongJae Park
2021-01-27 17:02 ` Shakeel Butt
2020-12-15 11:54 ` [PATCH v23 06/15] mm/damon: Add a tracepoint SeongJae Park
2020-12-15 11:54 ` [PATCH v23 07/15] mm/damon: Implement a debugfs-based user space interface SeongJae Park
2021-02-01 17:37 ` Shakeel Butt
2021-02-02 10:00 ` SeongJae Park
2020-12-15 11:54 ` [PATCH v23 08/15] mm/damon/dbgfs: Implement recording feature SeongJae Park
2020-12-15 11:54 ` [PATCH v23 09/15] mm/damon/dbgfs: Export kdamond pid to the user space SeongJae Park
2020-12-15 11:54 ` [PATCH v23 10/15] mm/damon/dbgfs: Support multiple contexts SeongJae Park
2021-02-02 12:27 ` SeongJae Park [this message]
2020-12-15 11:54 ` [PATCH v23 11/15] tools: Introduce a minimal user-space tool for DAMON SeongJae Park
2020-12-23 18:37 ` SeongJae Park
2020-12-23 22:56 ` Shakeel Butt
2020-12-24 7:13 ` SeongJae Park
2020-12-15 11:54 ` [PATCH v23 12/15] Documentation: Add documents " SeongJae Park
2020-12-15 11:54 ` [PATCH v23 13/15] mm/damon: Add kunit tests SeongJae Park
2020-12-15 11:54 ` [PATCH v23 14/15] mm/damon: Add user space selftests SeongJae Park
2020-12-15 11:54 ` [PATCH v23 15/15] MAINTAINERS: Update for DAMON 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=20210202122734.15627-1-sjpark@amazon.com \
--to=sjpark@amazon.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=aarcange@redhat.com \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=amit@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=brendan.d.gregg@gmail.com \
--cc=brendanhiggins@google.com \
--cc=cai@lca.pw \
--cc=colin.king@canonical.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=dwmw@amazon.com \
--cc=elver@google.com \
--cc=fan.du@intel.com \
--cc=foersleo@amazon.de \
--cc=gthelen@google.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=kirill@shutemov.name \
--cc=linux-damon@amazon.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=riel@surriel.com \
--cc=rientjes@google.com \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=sblbir@amazon.com \
--cc=shakeelb@google.com \
--cc=shuah@kernel.org \
--cc=sj38.park@gmail.com \
--cc=snu@amazon.de \
--cc=vbabka@suse.cz \
--cc=vdavydov.dev@gmail.com \
--cc=yang.shi@linux.alibaba.com \
--cc=ying.huang@intel.com \
--cc=zgf574564920@gmail.com \
/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