Re: [RFC v7 06/10] mm/damon: Implement callbacks for physical memory monitoring

From: SeongJae Park
Date: Thu Aug 20 2020 - 03:17:36 EST


On Wed, 19 Aug 2020 17:26:15 -0700 Shakeel Butt <shakeelb@xxxxxxxxxx> wrote:

> On Tue, Aug 18, 2020 at 12:27 AM SeongJae Park <sjpark@xxxxxxxxxx> wrote:
> >
> > From: SeongJae Park <sjpark@xxxxxxxxx>
> >
> > This commit implements the four callbacks (->init_target_regions,
> > ->update_target_regions, ->prepare_access_check, and ->check_accesses)
> > for the basic access monitoring of the physical memory address space.
> > By setting the callback pointers to point those, users can easily
> > monitor the accesses to the physical memory.
> >
> > Internally, it uses the PTE Accessed bit, as similar to that of the
> > virtual memory support. Also, it supports only user memory pages, as
> > idle page tracking also does, for the same reason. If the monitoring
> > target physical memory address range contains non-user memory pages,
> > access check of the pages will do nothing but simply treat the pages as
> > not accessed.
> >
> > Users who want to use other access check primitives and/or monitor the
> > non-user memory regions could implement and use their own callbacks.
> >
> > Signed-off-by: SeongJae Park <sjpark@xxxxxxxxx>
> [snip]
> > +static void damon_phys_mkold(unsigned long paddr)
> > +{
> > + struct page *page = damon_phys_get_page(PHYS_PFN(paddr));
> > + struct rmap_walk_control rwc = {
> > + .rmap_one = damon_page_mkold,
> > + .anon_lock = page_lock_anon_vma_read,
> > + };
> > + bool need_lock;
> > +
> > + if (!page)
> > + return;
> > +
> > + if (!page_mapped(page) || !page_rmapping(page))
> > + return;
>
> I don't think you want to skip the unmapped pages. The point of
> physical address space monitoring was to include the monitoring of
> unmapped pages, so, skipping them invalidates the underlying
> motivation.

I think my answer to your other mail[1] could be an answer to this. Let me
quote some from it:

```
Technically speaking, this patchset introduces an implementation of DAMON's low
level primitives for physical address space of LRU-listed pages. In other
words, it is not designed for cgroups case. Also, please note that this
patchset is only RFC, because it aims to only show the future plan of DAMON and
get opinions about the concept before being serious. It will be serious only
after the DAMON patchset is merged. Maybe I didn' made this point clear in the
CV, sorry. I will state this clearly in the next spin.
```

```
So, DAMON is a framework rather than a tool. Though it comes with basic
applications using DAMON as a framework (e.g., the virtual address space low
primitives implementation, DAMON debugfs interface, and the DAMON user space
tool) that could be useful in simple use cases, you need to code your
application on it if your use cases are out of the simple cases. I will also
develop more of such applications for more use-cases, but it will be only after
the framework is complete enough to be merged in the mainline.
```

Of course, we could prioritize the cgroup support if strongly required, though
I still prefer focusing on the framework itself for now.

[1] https://lore.kernel.org/linux-mm/20200820071052.24271-1-sjpark@xxxxxxxxxx/


Thanks,
SeongJae Park