Re: [PATCH v21 10/18] mm/damon: Implement a debugfs-based user space interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 5 Oct 2020 12:55:14 +0200 SeongJae Park <sjpark@xxxxxxxxxx> wrote:

> From: SeongJae Park <sjpark@xxxxxxxxx>
> 
> DAMON is designed to be used by kernel space code such as the memory
> management subsystems, and therefore it provides only kernel space API.
> That said, letting the user space control DAMON could provide some
> benefits to them.  For example, it will allow user space to analyze
> their specific workloads and make their own special optimizations.
> 
> For such cases, this commit implements a simple DAMON application kernel
> module, namely 'damon-dbgfs', which merely wraps the DAMON api and
> exports those to the user space via the debugfs.
[...]
> +
> +static ssize_t dbgfs_monitor_on_write(struct file *file,
> +		const char __user *buf, size_t count, loff_t *ppos)
> +{
> +	ssize_t ret = count;
> +	char *kbuf;
> +	int err;
> +
> +	kbuf = user_input_str(buf, count, ppos);
> +	if (IS_ERR(kbuf))
> +		return PTR_ERR(kbuf);
> +
> +	/* Remove white space */
> +	if (sscanf(kbuf, "%s", kbuf) != 1)
> +		return -EINVAL;
> +	if (!strncmp(kbuf, "on", count))
> +		err = dbgfs_start_ctxs(dbgfs_ctxs, dbgfs_nr_ctxs);
> +	else if (!strncmp(kbuf, "off", count))
> +		err = damon_stop(dbgfs_ctxs, dbgfs_nr_ctxs);
> +	else
> +		return -EINVAL;
> +
> +	if (err)
> +		ret = err;
> +	return ret;

'kbuf' should be freed before returning from this function.  I will fix it in
the next version.  To find more potential memory leaks, I ran 'kmemleak' after
a set of correctness tests[1], but it didn't find more leaks.

[1] https://github.com/awslabs/damon-tests/tree/master/corr


Thanks,
SeongJae Park




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux