Re: OpenSSI x86_64 port - missing code.

John Hughes <[email protected]> Mon, 26 Apr 2010 20:57:53 +0200
Newsgroups gmane.linux.cluster.ssic.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============3654039899984981936==
Content-Type: multipart/alternative;
	boundary="------------050709060607010501000509"

This is a multi-part message in MIME format.
--------------050709060607010501000509
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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&&





--------------050709060607010501000509
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 25/04/10 18:07, John Hughes wrote:
<blockquote cite="mid:[email protected]" type="cite">
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
Here is the list of code that has been possibly incorrectly dropped in
the x86_64 port.<br>
  <br>
arch/x86_64/kernel/sys_x86_64.c<br>
  <blockquote>code in mmap to check the MAP_MIGRATE flag.&nbsp; The base
code
is rather different so I'm not sure how to deal with this yet.<br>
  </blockquote>
</blockquote>
So what does this do?<br>
<br>
Normally mmap and it's subroutines use address 0 to mean "map wherever
you want".&nbsp; When we migrate mappings across to a new node if there is a
mapping at address 0 we want it to&nbsp; be at the same address on the
destination node.<br>
<br>
So, in mmap we make sure the MAP_MIGRATE flag&nbsp; is off:<br>
<br>
e.g. in arch/i386/kernel/sys_i386.c:<br>
<pre>#ifdef CONFIG_SSI
        flags &amp;= ~MAP_MIGRATE;
#endif
</pre>
When moving mappings we put it on in cluster/ssi/vproc/as_xscribe.c, <br>
<br>
<pre>static int
as_do_vma(as_vma_info *avip, as_info *asip)
...
        flags |= MAP_MIGRATE;
</pre>
And when we do the work, for i386 in ./include/linux/mm.h<br>
<br>
<pre>#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 &amp; MAP_MIGRATE))
#else
        if (addr)
#endif
        {
                addr = PAGE_ALIGN(addr);
                vma = find_vma(mm, addr);
                if (TASK_SIZE - len &gt;= addr &amp;&amp;
                    (!vma || addr + len &lt;= vma-&gt;vm_start))
                        return addr;
        }
</pre>
Problem for x86_64 is that it has HAVE_ARCH_UNMAPPED_AREA so we need to
do some more work.<br>
<br>
Which turns out to be not so much really:<br>
<pre>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 &amp;= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+#ifdef CONFIG_SSI
+	flags &amp;= ~MAP_MIGRATE;
+#endif
 	if (!(flags &amp; MAP_ANONYMOUS)) {
 		file = fget(fd);
 		if (!file)
@@ -105,7 +108,11 @@ arch_get_unmapped_area(struct file *filp
 	if (len &gt; end)
 		return -ENOMEM;
 
+#ifdef CONFIG_SSI
+	if (addr || (flags &amp; MAP_MIGRATE)) {
+#else
 	if (addr) {
+#endif
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma(mm, addr);
 		if (end - len &gt;= addr &amp;&amp;

</pre>
<br>
<br>
<br>
</body>
</html>

--------------050709060607010501000509--


--===============3654039899984981936==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------

--===============3654039899984981936==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel

--===============3654039899984981936==--