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)
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;
}
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