On Tue, 15 Dec 2020 12:54:36 +0100 SeongJae Park <[email protected]> wrote:

> From: SeongJae Park <[email protected]>
> 
> Even somehow the initial monitoring target regions are well constructed
> to fulfill the assumption (pages in same region have similar access
> frequencies), the data access pattern can be dynamically changed.  This
> will result in low monitoring quality.  To keep the assumption as much
> as possible, DAMON adaptively merges and splits each region based on
> their access frequency.
> 
> For each ``aggregation interval``, it compares the access frequencies of
> adjacent regions and merges those if the frequency difference is small.
> Then, after it reports and clears the aggregated access frequency of
> each region, it splits each region into two or three regions if the
> total number of regions will not exceed the user-specified maximum
> number of regions after the split.
> 
> In this way, DAMON provides its best-effort quality and minimal overhead
> while keeping the upper-bound overhead that users set.
> 
> Signed-off-by: SeongJae Park <[email protected]>
> Reviewed-by: Leonard Foerster <[email protected]>
> ---
>  include/linux/damon.h |  41 +++++---
>  mm/damon/core.c       | 220 ++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 240 insertions(+), 21 deletions(-)
> 
[...]
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 167487e75737..0f9beb60d9dd 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[...]
> +
> +/*
> + * Split a region in two
> + *
> + * r         the region to be split
> + * sz_r              size of the first sub-region that will be made
> + */
> +static void damon_split_region_at(struct damon_ctx *ctx,
> +                               struct damon_region *r, unsigned long sz_r)
> +{
> +     struct damon_region *new;
> +
> +     new = damon_new_region(r->ar.start + sz_r, r->ar.end);

Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. found that
'damon_new_region()' could return NULL in case of memory allocation failure,
but NULL check for 'new' is missed here.  I will add the check in the next
version.

> +     r->ar.end = new->ar.start;
> +
> +     damon_insert_region(new, r, damon_next_region(r));
> +}
[...]


Thanks,
SeongJae Park

Reply via email to