Commit 7b7a9161 authored by Daniel Black's avatar Daniel Black Committed by Sergey Vojtovich

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.
parent ccc06931
...@@ -380,21 +380,14 @@ uchar* my_large_malloc(size_t *size, myf my_flags) ...@@ -380,21 +380,14 @@ uchar* my_large_malloc(size_t *size, myf my_flags)
break; /* no more options to try */ break; /* no more options to try */
} }
} }
#else
DBUG_RETURN(my_malloc_lock(*size, my_flags));
#endif /* defined(HAVE_MMAP) */ #endif /* defined(HAVE_MMAP) */
if (ptr != NULL) if (ptr != NULL)
{ {
MEM_MAKE_DEFINED(ptr, *size); 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); DBUG_RETURN(ptr);
} }
...@@ -424,22 +417,13 @@ void my_large_free(void *ptr, size_t size) ...@@ -424,22 +417,13 @@ void my_large_free(void *ptr, size_t size)
#if defined(HAVE_MMAP) && !defined(_WIN32) #if defined(HAVE_MMAP) && !defined(_WIN32)
if (munmap(ptr, size)) if (munmap(ptr, size))
{ {
/* fprintf(stderr,
This occurs when the original allocation fell back to conventional "Warning: Failed to unmap location %p, %zu bytes, errno %d\n",
memory so ignore the EINVAL error. ptr, size, errno);
*/
if (errno != EINVAL)
{
fprintf(stderr,
"Warning: Failed to unmap location %p, %zu bytes, errno %d\n",
ptr, size, errno);
DBUG_VOID_RETURN;
}
} }
else else
{ {
MEM_UNDEFINED(ptr, size); MEM_UNDEFINED(ptr, size);
DBUG_VOID_RETURN;
} }
#elif defined(_WIN32) #elif defined(_WIN32)
/* /*
...@@ -454,10 +438,10 @@ void my_large_free(void *ptr, size_t size) ...@@ -454,10 +438,10 @@ void my_large_free(void *ptr, size_t size)
else else
{ {
MEM_UNDEFINED(ptr, size); MEM_UNDEFINED(ptr, size);
DBUG_VOID_RETURN;
} }
#endif #else
my_free_lock(ptr); my_free_lock(ptr);
#endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment