Jinoh Kang (@iamahuman) commented about dlls/ntdll/unix/unix_private.h:
PRTL_THREAD_START_ROUTINE start; /* thread entry point */ void *param; /* thread entry point parameter */ void *jmp_buf; /* setjmp buffer for exception handling */
+#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
- char *dontneed_page; /* page used for NtFlushProcessWriteBuffers implementation */
+#endif `#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__))`
Although `madvise(MADV_DONTNEED)` is Linux-specific, we can extend the use of the dummy page to the `mprotect()` approach which should be portable across all Unices.
` char *dontneed_page; /* page used for NtFlushProcessWriteBuffers implementation */`
Allocating a page per thread may incur significant virtual memory overhead if the process is 32-bit and the application spawns too many threads. Unlike ScyllaDB, we don't have much control over them. How about making the page a singleton and guarding it with a mutex?