Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
472d2d04
Commit
472d2d04
authored
Apr 05, 2020
by
Daniel Black
Committed by
Sergey Vojtovich
Apr 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
my_large_free_int merge into my_large_free
parent
4ac76936
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
42 deletions
+30
-42
mysys/my_largepage.c
mysys/my_largepage.c
+30
-42
No files found.
mysys/my_largepage.c
View file @
472d2d04
...
...
@@ -60,7 +60,6 @@ static void my_get_large_page_sizes(size_t sizes[]);
static
inline
my_bool
my_is_2pow
(
size_t
n
)
{
return
!
((
n
)
&
((
n
)
-
1
));
}
static
uchar
*
my_large_malloc_int
(
size_t
*
size
,
myf
my_flags
);
static
my_bool
my_large_free_int
(
void
*
ptr
,
size_t
size
);
#ifdef HAVE_LARGE_PAGES
...
...
@@ -222,12 +221,40 @@ void my_large_free(void *ptr, size_t size)
DBUG_ENTER
(
"my_large_free"
);
/*
my_large_free_int()
can only fail if ptr was not allocated with
The following implementations
can only fail if ptr was not allocated with
my_large_malloc_int(), i.e. my_malloc_lock() was used so we should free it
with my_free_lock()
*/
if
(
!
my_large_free_int
(
ptr
,
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
)
{
my_free_lock
(
ptr
);
}
else
{
fprintf
(
stderr
,
"Warning: Failed to unmap %zu bytes, errno %d
\n
"
,
size
,
errno
);
}
}
#elif defined(_WIN32)
/*
When RELEASE memory, the size parameter must be 0.
Do not use MEM_RELEASE with MEM_DECOMMIT.
*/
if
(
ptr
&&
!
VirtualFree
(
ptr
,
0
,
MEM_RELEASE
))
{
fprintf
(
stderr
,
"Error: VirtualFree(%p, %zu) failed; Windows error %lu
\n
"
,
ptr
,
size
,
GetLastError
());
my_free_lock
(
ptr
);
}
#else
#error No my_large_free implementation for this OS
#endif
/*
For ASAN, we need to explicitly unpoison this memory region because the OS
may reuse that memory for some TLS or stack variable. It will remain
...
...
@@ -384,27 +411,6 @@ static void my_get_large_page_sizes(size_t sizes[my_large_page_sizes_length])
}
#endif
#if defined(HAVE_MMAP) && !defined(_WIN32)
/* mmap and Linux-specific large pages deallocator */
my_bool
my_large_free_int
(
void
*
ptr
,
size_t
size
)
{
DBUG_ENTER
(
"my_large_free_int"
);
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 %zu bytes, errno %d
\n
"
,
size
,
errno
);
}
DBUG_RETURN
(
0
);
}
DBUG_RETURN
(
1
);
}
#endif
/* HAVE_MMAP */
#if defined(HAVE_MMAP) && !defined(__linux__) && !defined(MAP_ALIGNED) \
&& !defined(_WIN32)
...
...
@@ -490,23 +496,5 @@ uchar* my_large_malloc_int(size_t *size, myf my_flags)
DBUG_RETURN
(
ptr
);
}
/* Windows-specific large pages deallocator */
my_bool
my_large_free_int
(
void
*
ptr
,
size_t
size
)
{
DBUG_ENTER
(
"my_large_free_int"
);
/*
When RELEASE memory, the size parameter must be 0.
Do not use MEM_RELEASE with MEM_DECOMMIT.
*/
if
(
ptr
&&
!
VirtualFree
(
ptr
,
0
,
MEM_RELEASE
))
{
fprintf
(
stderr
,
"Error: VirtualFree(%p, %zu) failed; Windows error %lu
\n
"
,
ptr
,
size
,
GetLastError
());
DBUG_RETURN
(
0
);
}
DBUG_RETURN
(
1
);
}
#endif
/* _WIN32 */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment