Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow kernel with pagesize other than 4k on ARM #898

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6517,17 +6517,18 @@ int linuxMadvFreeForkBugCheck(void) {
int ret, pipefd[2];
pid_t pid;
char *p, *q, bug_found = 0;
const long map_size = 3 * 4096;
unsigned long page_size = sysconf(_SC_PAGESIZE);
const long map_size = 3 * page_size

/* Create a memory map that's in our full control (not one used by the allocator). */
p = (char*)mmap(NULL, map_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
serverAssert(p != MAP_FAILED);

q = p + 4096;
q = p + page_size;

/* Split the memory map in 3 pages by setting their protection as RO|RW|RO to prevent
* Linux from merging this memory map with adjacent VMAs. */
ret = mprotect(q, 4096, PROT_READ | PROT_WRITE);
ret = mprotect(q, page_size, PROT_READ | PROT_WRITE);
serverAssert(!ret);

/* Write to the page once to make it resident */
Expand All @@ -6537,7 +6538,7 @@ int linuxMadvFreeForkBugCheck(void) {
#ifndef MADV_FREE
#define MADV_FREE 8
#endif
ret = madvise(q, 4096, MADV_FREE);
ret = madvise(q, page_size, MADV_FREE);
serverAssert(!ret);

/* Write to the page after being marked for freeing, this is supposed to take
Expand Down