snmalloc
snmalloc copied to clipboard
Loongarch Support
QEMU 7.1 will begin loongarch support: https://wiki.qemu.org/ChangeLog/7.1#LoongArch.
Currently, everything works but all check variants:
qemu-loongarch64 -strace /home/schrodinger/Downloads/loongarch64-clfs-6.0-cross-tools-gcc_and_clang-full/cross-tools/target/usr/lib64/ld-linux-loongarch-lp64d.so.1 --library-path /home/schrodinger/Downloads/loongarch64-clfs-6.0-cross-tools-gcc_and_clang-full/cross-tools/target/usr/lib64 ./func-thread_alloc_external-check

So I tried
diff --git a/src/snmalloc/pal/pal_posix.h b/src/snmalloc/pal/pal_posix.h
index 8ad7995..22314db 100644
--- a/src/snmalloc/pal/pal_posix.h
+++ b/src/snmalloc/pal/pal_posix.h
@@ -233,7 +233,10 @@ namespace snmalloc
is_aligned_block<OS::page_size>(p, size) || (zero_mem == NoZero));
if constexpr (PalEnforceAccess)
- mprotect(p, size, PROT_READ | PROT_WRITE);
+ {
+ int val = mprotect(p, size, PROT_READ | PROT_WRITE);
+ SNMALLOC_ASSERT_MSG(val == 0, "mprotect is expected to succeed, address: {}, page size: {}", p, ::sysconf(_SC_PAGESIZE));
+ }
else
{
UNUSED(p, size);
And it reported
assert fail: val == 0 in /home/schrodinger/Downloads/snmalloc/src/snmalloc/backend_helpers/../mem/../ds/../pal/pal_posix.h on 238 mprotect is expected to succeed, address: 0x5c24cdd000, page size: 16384
Seems that it is a problem of page size detection.
On PowerPC, qemu user mode defaults to 4 KiB pages, which confuses snmalloc, which expects 64 KiB pages. We have some ugly hacks to work around this in CI. You might need to explicitly tell qemu to use 16 KiB pages for LoongArch.
any specific guide on adding qemu pipelines?

@mjp41 Is 7.1.0 available in our pipeline?
@mjp41 Is 7.1.0 available in our pipeline?
Not convinced. You can try, maybe we can build a docker image with it in?
Last time we used Docker, it added a lot to our end-to-end test times. Is there an unofficial apt repo that has newer builds of qemu that we can use?
help wanted