• SeongJae Park's avatar
    mm/damon/core: implement a pseudo-moving sum function · d2c062ad
    SeongJae Park authored
    For values that continuously change, moving average or sum are good ways
    to provide fast updates while handling temporal and errorneous variability
    of the value.  For example, the access rate counter (nr_accesses) is
    calculated as a sum of the number of positive sampled access check results
    that collected during a discrete time window (aggregation interval), and
    hence it handles temporal and errorneous access check results, but
    provides the update only for every aggregation interval.  Using a moving
    sum method for that could allow providing the value for every sampling
    interval.  That could be useful for getting monitoring results snapshot or
    running DAMOS in fine-grained timing.
    
    However, supporting the moving sum for cases that number of samples in the
    time window is arbirary could impose high overhead, since the number of
    past values that it needs to keep could be too high.  The nr_accesses
    would also be one of the cases.  To mitigate the overhead, implement a
    pseudo-moving sum function that only provides an estimated pseudo-moving
    sum.  It assumes there was no error in last discrete time window and
    subtract constant portion of last discrete time window sum.
    
    Note that the function is not strictly implementing the moving sum, but it
    keeps a property of moving sum, which makes the value same to the
    dsicrete-window based sum for each time window-aligned timing.  Hence,
    people collecting the value in the old timings would show no difference.
    
    Link: https://lkml.kernel.org/r/20230915025251.72816-4-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
    Cc: Brendan Higgins <brendanhiggins@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    d2c062ad
core.c 41.4 KB