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

Paul Menage
2006-11-30T23:48:34Z

On 11/30/06, Christoph Lameter <clameter@sgi.com> wrote:
> I think you initial suggestion of adding a counter to the anon_vma may
> work. Here is a patch that may allow us to keep the anon_vma around
> without holding mmap_sem. Seems to be simple.

Don't we need to bump the mapcount? If we don't, then the page gets
unmapped by the migration prep, and if we race with anyone trying to
map it they may allocate a new anon_vma and replace it.

> --- linux-2.6.19-rc6-mm2.orig/mm/migrate.c 2006-11-29 18:37:17.797934398 -0600
> +++ linux-2.6.19-rc6-mm2/mm/migrate.c 2006-11-30 17:39:48.429639786 -0600
> @@ -218,6 +218,7 @@ static void remove_anon_migration_ptes(s
> struct anon_vma *anon_vma;
> struct vm_area_struct *vma;
> unsigned long mapping;
> + int empty;
>
> mapping = (unsigned long)new->mapping;
>
> @@ -229,11 +230,15 @@ static void remove_anon_migration_ptes(s
> */
> anon_vma = (struct anon_vma *) (mapping - PAGE_MAPPING_ANON);
> spin_lock(&anon_vma->lock);
> + anon_vma->migration_count--;
>
> list_for_each_entry(vma, &anon_vma->head, anon_vma_node)
> remove_migration_pte(vma, old, new);
>
> + empty = list_empty(&anon_vma->head);

I think we need to check for migration_count being non-zero here, just
in case two processes try to migrate the same page at once. Or maybe
just say that if migration_count is non-zero, the second migrator just
ignores the page?

Paul