Re: Re: Re: [PATCH v6 00/14] Introduce Data Access MONitor (DAMON)

From: Shakeel Butt
Date: Wed Mar 18 2020 - 15:53:03 EST


On Thu, Mar 12, 2020 at 3:44 AM SeongJae Park <sjpark@xxxxxxxxxx> wrote:
>
> On Thu, 12 Mar 2020 11:07:59 +0100 SeongJae Park <sjpark@xxxxxxxxxx> wrote:
>
> > On Tue, 10 Mar 2020 10:21:34 -0700 Shakeel Butt <shakeelb@xxxxxxxxxx> wrote:
> >
> > > On Mon, Feb 24, 2020 at 4:31 AM SeongJae Park <sjpark@xxxxxxxxxx> wrote:
> > > >
> > > > From: SeongJae Park <sjpark@xxxxxxxxx>
> > > >
> > > > Introduction
> > > > ============
> > > >
> [...]
> > >
> > > I do want to question the actual motivation of the design followed by this work.
> > >
> > > With the already present Page Idle Tracking feature in the kernel, I
> > > can envision that the region sampling and adaptive region adjustments
> > > can be done in the user space. Due to sampling, the additional
> > > overhead will be very small and configurable.
> > >
> > > Additionally the proposed mechanism has inherent assumption of the
> > > presence of spatial locality (for virtual memory) in the monitored
> > > processes which is very workload dependent.
> > >
> > > Given that the the same mechanism can be implemented in the user space
> > > within tolerable overhead and is workload dependent, why it should be
> > > done in the kernel? What exactly is the advantage of implementing this
> > > in kernel?
> >
> > First of all, DAMON is not for only user space processes, but also for kernel
> > space core mechanisms. Many of the core mechanisms will be able to use DAMON
> > for access pattern based optimizations, with light overhead and reasonable
> > accuracy.

Which kernel space core mechanisms? I can see memory reclaim, do you
envision some other component as well.

Let's discuss how this can interact with memory reclaim and we can see
if there is any benefit to do this in kernel.

> >
> > Implementing DAMON in user space is of course possible, but it will be
> > inefficient. Using it from kernel space would make no sense, and it would
> > incur unnecessarily frequent kernel-user context switches, which is very
> > expensive nowadays.
>
> Forgot mentioning about the spatial locality. Yes, it is workload dependant,
> but still pervasive in many case. Also, many core mechanisms in kernel such as
> read-ahead or LRU are already using some similar assumptions.
>

Not sure about the LRU but yes read-ahead in several places does
assume spatial locality. However most of those are configurable and
the userspace can enable/disable the read-ahead based on the workload.

>
> If it is so problematic, you could set the maximum number of regions to the
> number of pages in the system so that each region monitors each page.
>

How will this work in the process context? Number of regions equal to
the number of mapped pages?

Basically I am trying to envision the comparison of physical memory
based monitoring (using idle page tracking) vs pid+VA based
monitoring.

Anyways I am not against your proposal. I am trying to see how to make
it more general to be applicable to more use-cases and one such
use-case which I am interested in is monitoring all the user pages on
the system for proactive reclaim purpose.

Shakeel