mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
kernel: support kernel_get_page_size() on OS X
This commit is contained in:
parent
71296da232
commit
68a794681e
2 changed files with 10 additions and 9 deletions
|
@ -44,6 +44,13 @@ int kernel_get_cacheline_size()
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
int kernel_get_page_size()
|
||||
{
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
int kernel_module_set_param(const char *module, const char *param, const char *value)
|
||||
|
@ -164,11 +171,6 @@ out:
|
|||
return -1; /* not found or error */
|
||||
}
|
||||
|
||||
int kernel_get_page_size()
|
||||
{
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
/* There is no sysconf interface to get the hugepage size */
|
||||
int kernel_get_hugepage_size()
|
||||
{
|
||||
|
|
|
@ -33,10 +33,9 @@
|
|||
/* Required to allocate hugepages on Apple OS X */
|
||||
#ifdef __MACH__
|
||||
#include <mach/vm_statistics.h>
|
||||
#elif defined(__linux__)
|
||||
#include <villas/kernel/kernel.h>
|
||||
#endif
|
||||
|
||||
#include <villas/kernel/kernel.h>
|
||||
#include <villas/log.h>
|
||||
#include <villas/memory.h>
|
||||
#include <villas/utils.h>
|
||||
|
@ -73,7 +72,7 @@ static struct memory_allocation * memory_hugepage_alloc(struct memory_type *m, s
|
|||
ma->address = mmap(NULL, ma->length, prot, flags, -1, 0);
|
||||
if (ma->address == MAP_FAILED) {
|
||||
//try again without hugepages as fallback solution, warn the user
|
||||
|
||||
|
||||
prot= PROT_READ | PROT_WRITE;
|
||||
//same flags as above without hugepages
|
||||
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||
|
@ -83,7 +82,7 @@ static struct memory_allocation * memory_hugepage_alloc(struct memory_type *m, s
|
|||
}
|
||||
#endif
|
||||
//length has to be aligned with pagesize
|
||||
ma->length = ALIGN(len, getpagesize());
|
||||
ma->length = ALIGN(len, kernel_get_page_size());
|
||||
//try mmap again
|
||||
ma->address = mmap(NULL, ma->length, prot, flags, -1, 0);
|
||||
if(ma->address == MAP_FAILED){
|
||||
|
|
Loading…
Add table
Reference in a new issue