Skip to content

Commit

Permalink
Use sysconf() to get PAGE_SIZE
Browse files Browse the repository at this point in the history
Some systems use not 4096 page size (64KB for example).
  • Loading branch information
ko1 committed Oct 12, 2023
1 parent b2e1ddf commit dd881ab
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion thread_pthread_mn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd881ab

Please sign in to comment.