riscv64: WASM Huge Memory quickly exhausts address space on Sv39 memory scheme
Categories
(Core :: JavaScript: WebAssembly, defect, P5)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox142 | --- | fixed |
People
(Reporter: csmantle, Assigned: csmantle)
References
Details
Attachments
(2 files)
On native riscv64 platforms with Sv39 memory schemes, the current default Huge Memory allocation strategy quickly exhausts all address space, leading to failed mmap calls and abort. This has been frequently observed in jit-test failures due to "out of memory" on Spacemit M1, the platform involved in bug 1933206. See the attached file for an excerpt of the log.
Huge Memory is on by default thanks to the current strategy of checking whether we have more than 38 effective bits of virtual address, see https://searchfox.org/mozilla-central/rev/584b344830aa2558985675b99aaadbb915402caa/js/src/wasm/WasmProcess.cpp#141-160.
I am requesting comments on whether we should add a special case for riscv64 on the Huge Memory enabling condition, or modify the condition itself to raise the lower limit of valid bits count.
A sample strace output is provided below (4328591360 is wasm::HugeMappedSize, which is numerically 0x102010000):
$ strace -e trace=memory -i /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/bin/js -p /home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/lib/prologue.js --wasm-compiler=optimizing -e 'const platform="linux"' -e 'const libdir="/home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/lib/"' -e 'const scriptdir="/home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/tests/wasm/"' -f /home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/lib/wasm.js --module-load-path /home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/modules/ -f /home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/tests/wasm/bce.js
... unrelated lines ...
[0000003f99f66d9a] mmap(0x3f18d1f000, 65536, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18d1f000
[0000003f99f66d9a] mmap(0x3f18d2f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18d2f000
[0000003f99f66d9a] mmap(0x3f18d3f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18d3f000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3e14fef000
[0000003f18d3f194] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x3e15000029} ---
[0000003f18d3f1a4] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x3e15000029} ---
[0000003f99f66d9a] mmap(0x3f18d5f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18d5f000
[0000003f99f66d9a] mmap(0x3f18d7f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18d7f000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3d12fde000
[0000003f18d7f228] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x3d12fef000} ---
[0000003f99f66d9a] mmap(0x3f18d9f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18d9f000
[0000003f99f68814] mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3d12ede000
[0000003f99f68814] mmap(NULL, 2093056, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3d12ddf000
[0000003f99f68814] mmap(0x3d12e02000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3d12e02000
[0000003f99f68814] mmap(0x3d12eff000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3d12eff000
[0000003f99f66d9a] mmap(0x3f18dbf000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18dbf000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3c10def000
[0000003f18dbf2a8] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x3c10e00000} ---
[0000003f99f66d9a] mmap(0x3f18dcf000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18dcf000
[0000003f99f66d9a] mmap(0x3f18def000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18def000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3b0edde000
[0000003f18def330] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x3b0edef000} ---
[0000003f99f66d9a] mmap(0x3f18e0f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18e0f000
[0000003f99f66d9a] mmap(0x3f18e2f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18e2f000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x3a0cdcd000
[0000003f18e2f3a8] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x3a0cdde000} ---
[0000003f99f66d9a] mmap(0x3f18e4f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18e4f000
[0000003f99f66d9a] mmap(0x3f18e6f000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f18e6f000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x390adbc000
... 239 more lines ...
[0000003f1989f0e0] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x17fbe0028} ---
[0000003f1989f0fc] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x17fbe0028} ---
[0000003f99f66d9a] mmap(0x3f198af000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f198af000
[0000003f99f66d9a] mmap(0x3f198bf000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f198bf000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7dbbe000
[0000003f198bf9c0] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x7dbcf000} ---
[0000003f99f66d9a] mmap(0x3f198df000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f198df000
[0000003f99f66d9a] mmap(0x3f198ef000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3f198ef000
[0000003f99f66d9a] mmap(NULL, 4328591360, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
/home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/tests/wasm/bce.js:176:12 uncaught exception: out of memory
Stack:
@/home/csmantle/workspace/mozilla-firefox-dev/js/src/jit-test/tests/wasm/bce.js:176:12
| Assignee | ||
Updated•4 months ago
|
| Assignee | ||
Comment 1•4 months ago
|
||
@rhunt, would it be possible for you to provide me with some guidance on the preferred approach to handling this issue?
| Assignee | ||
Comment 2•4 months ago
|
||
Updated•4 months ago
|
Updated•4 months ago
|
Comment 5•4 months ago
|
||
| bugherder | ||
Updated•4 months ago
|
Description
•