On 25/04/10 18:07, John Hughes wrote:
Here is the list of code that has been possibly incorrectly dropped in the x86_64 port.

arch/x86_64/kernel/sys_x86_64.c
code in mmap to check the MAP_MIGRATE flag.  The base code is rather different so I'm not sure how to deal with this yet.
So what does this do?

Normally mmap and it's subroutines use address 0 to mean "map wherever you want".  When we migrate mappings across to a new node if there is a mapping at address 0 we want it to  be at the same address on the destination node.

So, in mmap we make sure the MAP_MIGRATE flag  is off:

e.g. in arch/i386/kernel/sys_i386.c:
#ifdef CONFIG_SSI
        flags &= ~MAP_MIGRATE;
#endif
When moving mappings we put it on in cluster/ssi/vproc/as_xscribe.c,

static int
as_do_vma(as_vma_info *avip, as_info *asip)
...
        flags |= MAP_MIGRATE;
And when we do the work, for i386 in ./include/linux/mm.h

#ifndef HAVE_ARCH_UNMAPPED_AREA
unsigned long
arch_get_unmapped_area(struct file *filp, unsigned long addr,
                unsigned long len, unsigned long pgoff, unsigned long flags)
{
...
#ifdef CONFIG_SSI
        if (addr || (flags & MAP_MIGRATE))
#else
        if (addr)
#endif
        {
                addr = PAGE_ALIGN(addr);
                vma = find_vma(mm, addr);
                if (TASK_SIZE - len >= addr &&
                    (!vma || addr + len <= vma->vm_start))
                        return addr;
        }
Problem for x86_64 is that it has HAVE_ARCH_UNMAPPED_AREA so we need to do some more work.

Which turns out to be not so much really:
Index: sys_x86_64.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/arch/x86_64/kernel/sys_x86_64.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -p -r1.1.1.1 -r1.3
--- sys_x86_64.c	26 Apr 2010 18:44:42 -0000	1.1.1.1
+++ sys_x86_64.c	26 Apr 2010 18:56:01 -0000	1.3
@@ -51,6 +51,9 @@ long sys_mmap(unsigned long addr, unsign
 	error = -EBADF;
 	file = NULL;
 	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+#ifdef CONFIG_SSI
+	flags &= ~MAP_MIGRATE;
+#endif
 	if (!(flags & MAP_ANONYMOUS)) {
 		file = fget(fd);
 		if (!file)
@@ -105,7 +108,11 @@ arch_get_unmapped_area(struct file *filp
 	if (len > end)
 		return -ENOMEM;
 
+#ifdef CONFIG_SSI
+	if (addr || (flags & MAP_MIGRATE)) {
+#else
 	if (addr) {
+#endif
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma(mm, addr);
 		if (end - len >= addr &&