aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread_mn.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2023-10-12 23:35:12 +0900
committerKoichi Sasada <ko1@atdot.net>2023-10-13 01:09:41 +0900
commit10ba3fc302d68f977ce958b27a46ce0dab537f0c (patch)
treebd109a004fd881593a6609f0618419900fb20f33 /thread_pthread_mn.c
parent4387af1b4a16fbd181a7c42424ffb8cf92d55110 (diff)
downloadruby-10ba3fc302d68f977ce958b27a46ce0dab537f0c.tar.gz
Use `sysconf()` to get PAGE_SIZE
Some systems use not 4096 page size (64KB for example).
Diffstat (limited to 'thread_pthread_mn.c')
-rw-r--r--thread_pthread_mn.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/thread_pthread_mn.c b/thread_pthread_mn.c
index 64266683cd..8aaa1b8337 100644
--- a/thread_pthread_mn.c
+++ b/thread_pthread_mn.c
@@ -116,8 +116,20 @@ thread_sched_wait_events(struct rb_thread_sched *sched, rb_thread_t *th, int fd,
/// stack management
+static int
+get_sysconf_page_size(void)
+{
+ static long page_size = 0;
+
+ if (UNLIKELY(page_size == 0)) {
+ page_size = sysconf(_SC_PAGESIZE);
+ VM_ASSERT(page_size < INT_MAX);
+ }
+ return (int)page_size;
+}
+
#define MSTACK_CHUNK_SIZE (512 * 1024 * 1024) // 512MB
-#define MSTACK_PAGE_SIZE 4096
+#define MSTACK_PAGE_SIZE get_sysconf_page_size()
#define MSTACK_CHUNK_PAGE_NUM (MSTACK_CHUNK_SIZE / MSTACK_PAGE_SIZE - 1) // 1 is start redzone
// 512MB chunk