diff options
author | Daniel Black <daniel@linux.ibm.com> | 2020-04-06 11:05:42 +1000 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2020-04-08 14:51:14 +0400 |
commit | 7b7a9161e2d210355e798aa2000e7ed7578e6d03 (patch) | |
tree | ec728438ebdf1d97cffaec8d05b378cd4ebab1bf | |
parent | ccc06931c3c7be094f6dcddeb45589f06cf0c8af (diff) | |
download | mariadb-git-7b7a9161e2d210355e798aa2000e7ed7578e6d03.tar.gz |
my_large_pages: remove conventional memory(my_malloc_lock) fallback
Both Windows and MMAP capable implementations fell back to a
non-MEM_LARGE_PAGES/HugeTLB allocation with the large page implementaion
failed. These can can be freed by the corresponding function.
Prior to this, if we fell back to a conventional memory, than will
results in deallocation using munmap/VirtualFree on a memory allocated
using my_malloc_lock. At worst this could succeed and the
my_malloc_lock looses its memory without knowing about it.
-rw-r--r-- | mysys/my_largepage.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index 158dd1ed773..de8e0407798 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -380,21 +380,14 @@ uchar* my_large_malloc(size_t *size, myf my_flags) break; /* no more options to try */ } } +#else + DBUG_RETURN(my_malloc_lock(*size, my_flags)); #endif /* defined(HAVE_MMAP) */ if (ptr != NULL) { MEM_MAKE_DEFINED(ptr, *size); - DBUG_RETURN(ptr); } - ptr= my_malloc_lock(*size, my_flags); - -#ifdef HAVE_LARGE_PAGES - if (my_flags & MY_WME) - fprintf(stderr, - "Warning: Using conventional memory pool to allocate %p, size %zu\n", - ptr, *size); -#endif DBUG_RETURN(ptr); } @@ -424,22 +417,13 @@ void my_large_free(void *ptr, size_t size) #if defined(HAVE_MMAP) && !defined(_WIN32) if (munmap(ptr, size)) { - /* - This occurs when the original allocation fell back to conventional - memory so ignore the EINVAL error. - */ - if (errno != EINVAL) - { - fprintf(stderr, - "Warning: Failed to unmap location %p, %zu bytes, errno %d\n", - ptr, size, errno); - DBUG_VOID_RETURN; - } + fprintf(stderr, + "Warning: Failed to unmap location %p, %zu bytes, errno %d\n", + ptr, size, errno); } else { MEM_UNDEFINED(ptr, size); - DBUG_VOID_RETURN; } #elif defined(_WIN32) /* @@ -454,10 +438,10 @@ void my_large_free(void *ptr, size_t size) else { MEM_UNDEFINED(ptr, size); - DBUG_VOID_RETURN; } -#endif +#else my_free_lock(ptr); +#endif DBUG_VOID_RETURN; } |