Re: Extending LuaJIT's memory limit to 4Gbytes.

  • From: Dmitri Shubin <sbn@xxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 22 Aug 2012 11:07:13 +0400

Hello Florian!

On 21.08.2012 23:05, Florian Weimer wrote:
* Dmitri Shubin:

To support LuaJIT on Solaris 64-bit I had to do the similar thing --
use custom page allocator for low 2GiB of address space.
(mmap() on Solaris doesn't have MAP_32BIT flag and doesn't honor
address hint)
According to various sources, it's fixed in Solaris 11.

Thank you for pointing this out.
I tested it and it indeed works.
However we're currently use Solaris 10.

But it looks like that it doesn't use 'naive first-fit linear search' as comment in lj_alloc.c says about OSX and FreeBSD.

$ uname -a
SunOS slab 5.11 11.0 i86pc i386 i86pc
$ cat mmap-hint.c
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>

int
main()
{
    int i;

    for (i = 0; i < 3; ++i) {
void *p = mmap((void *) 0x10000, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
        printf("p = %p\n", p);
    }

    return 0;
}
$ cc -m64 mmap-hint.c
$ ./a.out
p = 10000
p = fffffd7fff130000
p = fffffd7fff120000

I.e. when the kernel is unable to use hint it's completely ignored.
AFAIU this won't work well with current implementation of CALL_MMAP() (in lj_alloc.c) for 64-bit non-Linux systems.

Other related posts: