Re: [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces

From: Shakeel Butt
Date: Wed Dec 23 2020 - 17:54:57 EST


On Wed, Dec 23, 2020 at 8:47 AM SeongJae Park <sjpark@xxxxxxxxxx> wrote:
>
[snip]
> > [snip]
> > > +
> > > +static bool damon_va_young(struct mm_struct *mm, unsigned long addr,
> > > + unsigned long *page_sz)
> > > +{
> > > + pte_t *pte = NULL;
> > > + pmd_t *pmd = NULL;
> > > + spinlock_t *ptl;
> > > + bool young = false;
> > > +
> > > + if (follow_pte_pmd(mm, addr, NULL, &pte, &pmd, &ptl))
> > > + return false;
> > > +
> > > + *page_sz = PAGE_SIZE;
> > > + if (pte) {
> > > + young = pte_young(*pte);
> > > + if (!young)
> > > + young = !page_is_idle(pte_page(*pte));
> > > + pte_unmap_unlock(pte, ptl);
> > > + return young;
> > > + }
> > > +
> > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> > > + young = pmd_young(*pmd);
> > > + if (!young)
> > > + young = !page_is_idle(pmd_page(*pmd));
> > > + spin_unlock(ptl);
> > > + *page_sz = ((1UL) << HPAGE_PMD_SHIFT);
> > > +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
> > > +
> > > + return young;
> >
> > You need mmu_notifier_test_young() here. Hmm I remember mentioning
> > this in some previous version as well.
>
> Your question and my answer was as below:
>
> > Don't you need mmu_notifier_clear_young() here?
>
> I think we don't need it here because we only read the Accessed bit and PG_Idle
> if Accessed bit was not set.
>
> I should notice that you mean 'test_young()' but didn't, sorry. I will add it
> in the next version.
>

I should have said mmu_notifier_test_young() instead of
mmu_notifier_clear_young().

> >
> > BTW have you tested this on a VM?
>
> Yes. Indeed, I'm testing this on a QEMU/KVM environment. You can get more
> detail at: https://damonitor.github.io/doc/html/latest/vm/damon/eval.html#setup
>

Hmm without mmu_notifier_test_young() you should be missing the kvm
mmu access updates. Can you please recheck if your eval is correctly
seeing the memory accesses from the VM?