1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

bug fix: handle failed allocation of huge pages correctly (returns MAP_FAILED instead of NULL)

This commit is contained in:
Steffen Vogel 2016-10-30 16:54:39 -04:00
parent e2d47698ed
commit c8d6c63d95
2 changed files with 13 additions and 1 deletions

View file

@ -41,6 +41,11 @@ struct memzone {
size_t len;
};
/** Allocate \p len bytes memory of type \p m.
*
* @retval NULL If allocation failed.
* @retval <>0 If allocation was successful.
*/
void * memory_alloc(const struct memtype *m, size_t len);
void * memory_alloc_aligned(const struct memtype *m, size_t len, size_t alignment);

View file

@ -60,7 +60,14 @@ static void * memory_hugepage_alloc(size_t len)
flags |= MAP_HUGETLB | MAP_LOCKED;
#endif
return mmap(NULL, len, prot, flags, -1, 0);
void *ret = mmap(NULL, len, prot, flags, -1, 0);
if (ret == MAP_FAILED) {
info("Failed to allocate huge pages: Check https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt");
return NULL;
}
return ret;
}
static int memory_hugepage_free(void *ptr, size_t len)