[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210119184107.1865-1-sjpark@amazon.com>
Date: Tue, 19 Jan 2021 19:41:07 +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: [RFC v10 01/13] damon/dbgfs: Allow users to set initial monitoring target regions
On Wed, 16 Dec 2020 10:42:09 +0100 SeongJae Park <sjpark@...zon.com> wrote:
> From: SeongJae Park <sjpark@...zon.de>
>
> Some 'damon-dbgfs' users would want to monitor only a part of the entire
> virtual memory address space. The framework users in the kernel space
> could use '->init_target_regions' callback or even set the regions
> inside the context struct as they want, but 'damon-dbgfs' users cannot.
>
> For the reason, this commit introduces a new debugfs file,
> 'init_region'. 'damon-dbgfs' users can specify which initial monitoring
> target address regions they want by writing special input to the file.
> The input should describe each region in each line in below form:
>
> <pid> <start address> <end address>
>
> Note that the regions will be updated to cover entire memory mapped
> regions after 'regions update interval'. If you want the regions to not
> be updated after the initial setting, you could set the interval as a
> very long time, say, a few decades.
>
> Signed-off-by: SeongJae Park <sjpark@...zon.de>
> ---
> mm/damon/dbgfs.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 151 insertions(+), 3 deletions(-)
>
> diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
> index 06295c986dc3..2f1ec6ebd9f0 100644
> --- a/mm/damon/dbgfs.c
> +++ b/mm/damon/dbgfs.c
[...]
> +
> +static ssize_t dbgfs_init_regions_read(struct file *file, char __user *buf,
> + size_t count, loff_t *ppos)
> +{
> + struct damon_ctx *ctx = file->private_data;
> + char *kbuf;
> + ssize_t len;
> +
> + kbuf = kmalloc(count, GFP_KERNEL);
> + if (!kbuf)
> + return -ENOMEM;
> +
> + mutex_lock(&ctx->kdamond_lock);
> + if (ctx->kdamond) {
> + mutex_unlock(&ctx->kdamond_lock);
> + return -EBUSY;
Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. found that
above return is missing deallocation of 'kbuf'. I will fix this in the next
version.
> + }
> +
> + len = sprint_init_regions(ctx, kbuf, count);
> + mutex_unlock(&ctx->kdamond_lock);
> + if (len < 0)
> + goto out;
> + len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
> +
> +out:
> + kfree(kbuf);
> + return len;
> +}
Thanks,
SeongJae Park
[...]
Powered by blists - more mailing lists