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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 13 Oct 2021 15:45:35 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     SeongJae Park <sj@...nel.org>
Cc:     Jonathan.Cameron@...wei.com, amit@...nel.org,
        benh@...nel.crashing.org, corbet@....net, david@...hat.com,
        dwmw@...zon.com, elver@...gle.com, foersleo@...zon.de,
        gthelen@...gle.com, markubo@...zon.de, rientjes@...gle.com,
        shakeelb@...gle.com, shuah@...nel.org, linux-damon@...zon.com,
        linux-mm@...ck.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/7] mm/damon/dbgfs: Allow users to set initial
 monitoring target regions

On Tue, 12 Oct 2021 20:57:05 +0000 SeongJae Park <sj@...nel.org> wrote:

> Some 'damon-dbgfs' users would want to monitor only a part of the entire
> virtual memory address space.  The program interface users in the kernel
> space could use '->before_start()' callback or 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 called
> '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 the below form:
> 
>     <pid> <start address> <end address>
> 
> Note that the regions will be updated to cover entire memory mapped
> regions after a 'regions update interval' is passed.  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.
> 
> ...
>
> +static int add_init_region(struct damon_ctx *c,
> +			 unsigned long target_id, struct damon_addr_range *ar)
> +{
> +	struct damon_target *t;
> +	struct damon_region *r, *prev;
> +	unsigned long id;
> +	int rc = -EINVAL;
> +
> +	if (ar->start >= ar->end)
> +		return -EINVAL;
> +
> +	damon_for_each_target(t, c) {
> +		id = t->id;
> +		if (targetid_is_pid(c))
> +			id = (unsigned long)pid_vnr((struct pid *)id);

This is a bit ugly.  Did you consider making damon_target.id a union of
all the possible types it can contain?  This will avoid typecasts, has
documentation value and reflacts what is actually going on.

> +		if (id == target_id) {
> +			r = damon_new_region(ar->start, ar->end);
> +			if (!r)
> +				return -ENOMEM;
> +			damon_add_region(r, t);
> +			if (damon_nr_regions(t) > 1) {
> +				prev = damon_prev_region(r);
> +				if (prev->ar.end > r->ar.start) {
> +					damon_destroy_region(r, t);
> +					return -EINVAL;
> +				}
> +			}
> +			rc = 0;
> +		}
> +	}
> +	return rc;
> +}
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ