Re: DAMON VA regions don't split on an large Android APP

From: SeongJae Park
Date: Sun May 29 2022 - 15:54:31 EST


On Wed, 27 Apr 2022 17:50:49 +0000 sj@xxxxxxxxxx wrote:

> Hello Rongwei and Barry,
>
> On Wed, 27 Apr 2022 19:44:23 +1200 Barry Song <21cnbao@xxxxxxxxx> wrote:
>
> > On Wed, Apr 27, 2022 at 6:56 PM Rongwei Wang
> > <rongwei.wang@xxxxxxxxxxxxxxxxx> wrote:
> > >
> > >
> > >
> > > On 4/27/22 7:19 AM, Barry Song wrote:
[...]
> >
> > I guess the cause might be:
> > in case a region is very big like 10GiB, we have only 1MiB hot pages
> > in this large region.
> > damon will randomly pick one page to sample, but the page has only
> > 1MiB/10GiB, thus
> > less than 1/10000 chance to hit the hot 1MiB. so probably we need
> > 10000 sample periods
> > to hit the hot 1MiB in order to split this large region?
> >
> > @SeongJae, please correct me if I am wrong.
>
> I think your theory makes sense. There was a similar concern, so we made DAMON
> to split regions into 3 sub-regions when we don't see advance[1]. My current
> rough idea for improving DAMON accuracy is making it more aggressive while
> keeping the monitoring overhead low.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git/tree/mm/damon/core.c?h=damon/next-2022-04-21-08-31-on-v5.18-rc3-mmots-2022-04-20-17-37#n1053
>
> >
> > >
> > > I'm not sure whether sets init_regions can deal with the above problem,
> > > or dynamic choose one or limited number VMA to monitor.
> > >
> >
> > I won't set a limited number of VMA as this will make the damon too hard to use
> > as nobody wants to make such complex operations, especially an Android
> > app might have more than 8000 VMAs.
> >
> > I agree init_regions might be the right place to enhance the situation.
>
> 'init_regions' has developed for the purpose, where user space knows some good
> information for starting point of the regions adjustment, and thus want to hint
> DAMON. Nevertheless, it might not work as expected, because DAMON
> automatically updates the target regions to cover all VMAs as much as it can.
> I have posted a patchset for the use case yesterday[1].
>
> [1] https://lore.kernel.org/linux-mm/20220426231750.48822-1-sj@xxxxxxxxxx/

FWIW, the patchset for the fixed virtual address space ranges monitoring has
merged in the mainline[1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=98931dd95fd489fcbfa97da563505a6f071d7c77


Thanks,
SJ

[...]