Re: [RFC][PATCH 0/1] Node-based reclaim/migration

Paul Menage
2006-11-30T21:33:18Z

On 11/30/06, Christoph Lameter <clameter@sgi.com> wrote:
>
> Hmmm.. Well talk to Hugh Dickins about that. anon_vmas are very
> performance sensitive things.

>
> > When gathering pages for migration, we use page_lock_anon_vma() to get
> > the anon_vma; if it returns NULL or has an empty vma list we skip the
> > page, else we bump migration count (and mapcount?) by 1 and unlock.
> > That will guarantee that the anon_vma sticks around until the end of
> > the migration.
>
> You cannot use page_lock_anon_vma since the mapcount is of the page is
> zero.

Let me clarify my proposal:

1) When gathering pages we find an anon page

2) We call page_lock_anon_vma(); if it returns NULL we ignore the page

3) If the anon_vma has an empty vma list, we ignore the page

4) We increment page_mapcount(); if this crosses the boundary from
unmapped to mapped, we know that we're racing with someone else;
either ignore the page or start again

5) If page->mapping no longer refers to our anon_vma, we know we're
racing; drop page_mapcount and ignore the page or start again

6) We increment anon_vma->migration_count to pin the anon_vma

At this point we know that the vma isn't going to go away since it's
pinned via the migration count, and any new users of the page will use
the pinned anon_vma since page_mapcount() is positive.

Paul