lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 2 Feb 2021 13:27:34 +0100
From:   SeongJae Park <sjpark@...zon.com>
To:     SeongJae Park <sjpark@...zon.com>
CC:     <akpm@...ux-foundation.org>, <Jonathan.Cameron@...wei.com>,
        <aarcange@...hat.com>, <acme@...nel.org>,
        <alexander.shishkin@...ux.intel.com>, <amit@...nel.org>,
        <benh@...nel.crashing.org>, <brendan.d.gregg@...il.com>,
        <brendanhiggins@...gle.com>, <cai@....pw>,
        <colin.king@...onical.com>, <corbet@....net>, <david@...hat.com>,
        <dwmw@...zon.com>, <elver@...gle.com>, <fan.du@...el.com>,
        <foersleo@...zon.de>, <gthelen@...gle.com>, <irogers@...gle.com>,
        <jolsa@...hat.com>, <kirill@...temov.name>, <mark.rutland@....com>,
        <mgorman@...e.de>, <minchan@...nel.org>, <mingo@...hat.com>,
        <namhyung@...nel.org>, <peterz@...radead.org>,
        <rdunlap@...radead.org>, <riel@...riel.com>, <rientjes@...gle.com>,
        <rostedt@...dmis.org>, <rppt@...nel.org>, <sblbir@...zon.com>,
        <shakeelb@...gle.com>, <shuah@...nel.org>, <sj38.park@...il.com>,
        <snu@...zon.de>, <vbabka@...e.cz>, <vdavydov.dev@...il.com>,
        <yang.shi@...ux.alibaba.com>, <ying.huang@...el.com>,
        <zgf574564920@...il.com>, <linux-damon@...zon.com>,
        <linux-mm@...ck.org>, <linux-doc@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v23 10/15] mm/damon/dbgfs: Support multiple contexts

On Tue, 15 Dec 2020 12:54:43 +0100 SeongJae Park <sjpark@...zon.com> wrote:

> From: SeongJae Park <sjpark@...zon.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@...zon.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
[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ