From 1d6207529170c9f7c41e13a161370fb9e3c03ce3 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 23 Mar 2019 22:29:04 -0400 Subject: [PATCH] label allocate_aligned_pages mappings --- h_malloc.c | 2 +- pages.c | 11 ++++++----- pages.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index 7e36e1b..e7f25c5 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -1304,7 +1304,7 @@ static int alloc_aligned(void **memptr, size_t alignment, size_t size, size_t mi size_t guard_size = get_guard_size(&ra->rng, size); mutex_unlock(&ra->lock); - void *p = allocate_pages_aligned(size, alignment, guard_size); + void *p = allocate_pages_aligned(size, alignment, guard_size, "malloc large"); if (p == NULL) { return ENOMEM; } diff --git a/pages.c b/pages.c index 4cd6ba8..07a41e1 100644 --- a/pages.c +++ b/pages.c @@ -27,11 +27,7 @@ void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, cons return usable; } -void deallocate_pages(void *usable, size_t usable_size, size_t guard_size) { - memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2); -} - -void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size) { +void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size, const char *name) { usable_size = PAGE_CEILING(usable_size); if (unlikely(!usable_size)) { errno = ENOMEM; @@ -54,6 +50,7 @@ void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_ if (unlikely(real == NULL)) { return NULL; } + memory_set_name(real, real_alloc_size, name); void *usable = (char *)real + guard_size; @@ -82,3 +79,7 @@ void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_ return base; } + +void deallocate_pages(void *usable, size_t usable_size, size_t guard_size) { + memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2); +} diff --git a/pages.h b/pages.h index 124afe7..d91b58d 100644 --- a/pages.h +++ b/pages.h @@ -11,7 +11,7 @@ #define PAGE_CEILING(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, const char *name); +void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size, const char *name); void deallocate_pages(void *usable, size_t usable_size, size_t guard_size); -void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size); #endif