Search code examples
clinuxmemorylinux-kernelpowerpc

How many memorys can a process have under PPC64 on linux


I watched a testcase for linux. it test for mmap like follows:

#define HIGH_ADDR       (void *)(0x1000000000000)
addr = mmap(HIGH_ADDR, map_sz, PROT_READ,
                MAP_SHARED | MAP_FIXED, fildes, 0);

In that case under PPC64, the Expected results is get an errno ENOMEM.
But Actual results under PPC64 is get an errno Invalid argument.
Anyway, it works well on X86_64 arch. I think maybe the PPC64 haven't assigned enough memory. So, I try to modify the HIGH_ADDR's define to:
#define HIGH_ADDR (void *)(0x7FFFFFFFFFF)
But it still get Invalid argument.
I just want to konw, How the linux for PPC64 manage his memory. I mean, I want to know the userspace program's memory geography. Or what's the MAX address Should I use.


Solution

  • From man 2 mmap:

           EINVAL We don't like addr, length, or offset (e.g., they are too large,
                  or not aligned on a page boundary).
    
           EINVAL (since Linux 2.6.12) length was 0.
    
           EINVAL flags  contained neither MAP_PRIVATE or MAP_SHARED, or contained
                  both of these values.
    

    So mmap will signal an error with EINVAL if addr is too large. This is therefore expected behavior.

    Recommendation: Don't use MAP_FIXED, unless you have a really good reason.

    Footnote: Not all 64-bit architectures support 64-bit addresses.