Re: [PATCH v22 01/18] mm: Introduce Data Access MONitor (DAMON)

From: Shakeel Butt
Date: Wed Nov 25 2020 - 10:30:17 EST


On Tue, Oct 20, 2020 at 2:01 AM SeongJae Park <sjpark@xxxxxxxxxx> wrote:
>
> From: SeongJae Park <sjpark@xxxxxxxxx>
>
> DAMON is a data access monitoring framework for the Linux kernel. The
> core mechanisms of DAMON make it
>
> - accurate (the monitoring output is useful enough for DRAM level
> performance-centric memory management; It might be inappropriate for
> CPU Cache levels, though),
> - light-weight (the monitoring overhead is normally low enough to be
> applied online), and
> - scalable (the upper-bound of the overhead is in constant range
> regardless of the size of target workloads).
>
> Using this framework, hence, we can easily write efficient kernel space
> data access monitoring applications. For example, the kernel's memory
> management mechanisms can make advanced decisions using this.
> Experimental data access aware optimization works that incurring high
> access monitoring overhead could implemented again on top of this.
>
> Due to its simple and flexible interface, providing user space interface
> would be also easy. Then, user space users who have some special
> workloads can write personalized applications for better understanding
> and optimizations of their workloads and systems.
>
> That said, this commit is implementing only basic data structures and
> simple manipulation functions of the structures. The core mechanisms of
> DAMON will be implemented by following commits.
>
> Signed-off-by: SeongJae Park <sjpark@xxxxxxxxx>
> Reviewed-by: Leonard Foerster <foersleo@xxxxxxxxx>
> Reviewed-by: Varad Gautam <vrd@xxxxxxxxx>

I don't see any benefit of this patch on its own. Some of this should
be part of the main damon context patch. I would suggest to separate
the core (damon context) from the target related structs (target,
region, addr range).

Also I would prefer the code be added with the actual usage otherwise
it is hard to review.

> ---
[snip]
> +unsigned int damon_nr_regions(struct damon_target *t)
> +{
> + struct damon_region *r;
> + unsigned int nr_regions = 0;
> +
> + damon_for_each_region(r, t)
> + nr_regions++;
> +
> + return nr_regions;
> +}

Why not keep a count instead of traversing to get the size?