From raybry@sgi.com Fri Jul 1 15:41:18 2005 Date: Fri, 1 Jul 2005 15:41:17 -0700 (PDT) From: Ray Bryant To: Hirokazu Takahashi , Andi Kleen , Dave Hansen , Marcelo Tosatti Cc: Christoph Hellwig , linux-mm , Nathan Scott , Ray Bryant , lhms-devel@lists.sourceforge.net, Ray Bryant , Paul Jackson , clameter@sgi.com Subject: [PATCH 2.6.13-rc1 6/11] mm: manual page migration-rc4 -- sys_migrate_pages-mempolicy-migration-shared-policy-fixup-rc4.patch This code fixes a problem with migrating mempolicies for shared objects (System V shared memory, tmpfs, etc) that Andi Kleen pointed out in his review of the -rc3 version of the page migration code. As currently implemented, this only really matters for System V shared memory, since AFAIK that is the only shared object that has its own vma->vm_policy->policy code. As code is added for the other cases, the code below will work with the other shared objects. One can argue that since the shared object exists outside of the application, that one shouldn't migrate it at all. The approach taken here is that if a shared object is mapped into the address space of a process that is being migrated, then the mapped pages of the shared object should be migrated with the process. (Pages in the shared object that are not mapped will not be migrated. This is not perfect, but so it goes.) Signed-off-by: Ray Bryant mempolicy.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: linux-2.6.13/mm/mempolicy.c =================================================================== --- linux-2.6.13.orig/mm/mempolicy.c 2005-08-30 13:20:42.000000000 -0700 +++ linux-2.6.13/mm/mempolicy.c 2005-08-30 13:21:02.000000000 -0700 @@ -1357,12 +1357,13 @@ int migrate_process_policy(struct task_s int migrate_vma_policy(struct vm_area_struct *vma, int *node_map) { + struct mempolicy *old = get_vma_policy(vma, vma->vm_start); struct mempolicy *new; - if (!vma->vm_policy || vma->vm_policy->policy == MPOL_DEFAULT) + if (old->policy == MPOL_DEFAULT) return 0; - new = migrate_policy(vma->vm_policy, node_map); + new = migrate_policy(old, node_map); if (IS_ERR(new)) return (PTR_ERR(new));