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
a535d4d1
Commit
a535d4d1
authored
Apr 06, 2020
by
Daniel Black
Committed by
Sergey Vojtovich
Apr 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
my_largepage: fprintf -> my_{printf_,}error
parent
11aaf5c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
35 deletions
+52
-35
include/mysys_err.h
include/mysys_err.h
+2
-1
mysys/errors.c
mysys/errors.c
+3
-1
mysys/my_largepage.c
mysys/my_largepage.c
+47
-33
No files found.
include/mysys_err.h
View file @
a535d4d1
...
...
@@ -70,7 +70,8 @@ extern const char *globerrs[]; /* my_error_messages is here */
#define EE_CANT_CHMOD 34
#define EE_CANT_COPY_OWNERSHIP 35
#define EE_BADMEMORYRELEASE 36
#define EE_ERROR_LAST 36
/* Copy last error nr */
#define EE_PERM_LOCK_MEMORY 37
#define EE_ERROR_LAST 37
/* Copy last error nr */
/* Add error numbers before EE_ERROR_LAST and change it accordingly. */
...
...
mysys/errors.c
View file @
a535d4d1
...
...
@@ -56,7 +56,8 @@ const char *globerrs[GLOBERRS]=
"Can't seek in file '%s' (Errcode: %M)"
,
"Can't change mode for file '%s' to 0x%lx (Errcode: %M)"
,
"Warning: Can't copy ownership for file '%s' (Errcode: %M)"
,
"Failed to release memory pointer %p, %zu bytes (Errcode: %M)"
"Failed to release memory pointer %p, %zu bytes (Errcode: %M)"
,
"Lock Pages in memory access rights required"
};
void
init_glob_errs
(
void
)
...
...
@@ -103,6 +104,7 @@ void init_glob_errs()
EE
(
EE_CANT_CHMOD
)
=
"Can't change mode for file '%s' to 0x%lx (Errcode: %M)"
;
EE
(
EE_CANT_COPY_OWNERSHIP
)
=
"Warning: Can't copy ownership for file '%s' (Errcode: %M)"
;
EE
(
EE_BADMEMORYRELEASE
)
=
"Failed to release memory pointer %p, %zu bytes (Errcode: %M)"
;
EE
(
EE_PERM_LOCK_MEMORY
)
=
"Lock Pages in memory access rights required"
;
}
#endif
...
...
mysys/my_largepage.c
View file @
a535d4d1
...
...
@@ -15,6 +15,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include "mysys_priv.h"
#include <mysys_err.h>
#ifdef __linux__
#include <dirent.h>
...
...
@@ -85,7 +86,7 @@ static void my_get_large_page_sizes(size_t sizes[my_large_page_sizes_length])
dirp
=
opendir
(
"/sys/kernel/mm/hugepages"
);
if
(
dirp
==
NULL
)
{
perror
(
"Warning: failed to open /sys/kernel/mm/hugepages"
);
my_error
(
EE_DIR
,
MYF
(
ME_BELL
),
"/sys/kernel/mm/hugepages"
,
errno
);
}
else
{
...
...
@@ -96,8 +97,10 @@ static void my_get_large_page_sizes(size_t sizes[my_large_page_sizes_length])
sizes
[
i
]
=
strtoull
(
r
->
d_name
+
10
,
NULL
,
10
)
*
1024ULL
;
if
(
!
my_is_2pow
(
sizes
[
i
]))
{
fprintf
(
stderr
,
"Warning: non-power of 2 large page size (%zu) found,"
" skipping
\n
"
,
sizes
[
i
]);
my_printf_error
(
0
,
"non-power of 2 large page size (%zu) found,"
" skipping"
,
MYF
(
ME_NOTE
|
ME_ERROR_LOG_ONLY
),
sizes
[
i
]);
sizes
[
i
]
=
0
;
continue
;
}
...
...
@@ -106,7 +109,7 @@ static void my_get_large_page_sizes(size_t sizes[my_large_page_sizes_length])
}
if
(
closedir
(
dirp
))
{
perror
(
"Warning: failed to close /sys/kernel/mm/hugepages"
);
my_error
(
EE_BADCLOSE
,
MYF
(
ME_BELL
),
"/sys/kernel/mm/hugepages"
,
errno
);
}
qsort
(
sizes
,
i
,
sizeof
(
size_t
),
size_t_cmp
);
}
...
...
@@ -190,9 +193,10 @@ int my_init_large_pages(my_bool super_large_pages)
#ifdef _WIN32
if
(
!
my_obtain_privilege
(
SE_LOCK_MEMORY_NAME
))
{
fprintf
(
stderr
,
"mysqld: Lock Pages in memory access rights required for "
"use with large-pages, see https://mariadb.com/kb/en/library/"
"mariadb-memory-allocation/#huge-pages
\n
"
);
my_printf_error
(
EE_PERM_LOCK_MEMORY
,
"Lock Pages in memory access rights required for use with"
" large-pages, see https://mariadb.com/kb/en/library/"
"mariadb-memory-allocation/#huge-pages"
,
MYF
(
MY_WME
));
return
1
;
}
my_large_page_size
=
GetLargePageMinimum
();
...
...
@@ -202,7 +206,8 @@ int my_init_large_pages(my_bool super_large_pages)
my_get_large_page_sizes
(
my_large_page_sizes
);
#ifndef HAVE_LARGE_PAGES
fprintf
(
stderr
,
"Warning: no large page support on this platform
\n
"
);
my_printf_error
(
EE_OUTOFMEMORY
,
"No large page support on this platform"
,
MYF
(
MY_WME
));
#endif
#ifdef HAVE_SOLARIS_LARGE_PAGES
...
...
@@ -280,19 +285,28 @@ uchar *my_large_malloc(size_t *size, myf my_flags)
{
if
(
my_flags
&
MY_WME
)
{
fprintf
(
stderr
,
"Warning: VirtualAlloc(%zu bytes%s) failed; Windows error %lu
\n
"
,
*
size
,
my_use_large_pages
?
", MEM_LARGE_PAGES"
:
""
,
GetLastError
());
if
(
my_use_large_pages
)
{
my_printf_error
(
EE_OUTOFMEMORY
,
"Couldn't allocate %zu bytes (MEM_LARGE_PAGES page "
"size %zu); Windows error %lu; fallback to "
"conventional pages failed"
,
MYF
(
ME_WARNING
|
ME_ERROR_LOG_ONLY
),
*
size
,
my_large_page_size
,
GetLastError
());
}
else
{
my_error
(
EE_OUTOFMEMORY
,
MYF
(
ME_BELL
+
ME_ERROR_LOG
),
*
size
);
}
}
*
size
=
orig_size
;
ptr
=
VirtualAlloc
(
NULL
,
*
size
,
MEM_COMMIT
|
MEM_RESERVE
,
PAGE_READWRITE
);
if
(
!
ptr
&&
my_flags
&
MY_WME
)
if
(
my_use_large_pages
)
{
fprintf
(
stderr
,
"Warning: VirtualAlloc(%zu bytes) failed; Windows error %lu
\n
"
,
*
size
,
GetLastError
());
*
size
=
orig_size
;
ptr
=
VirtualAlloc
(
NULL
,
*
size
,
MEM_COMMIT
|
MEM_RESERVE
,
PAGE_READWRITE
);
if
(
!
ptr
&&
my_flags
&
MY_WME
)
{
my_error
(
EE_OUTOFMEMORY
,
MYF
(
ME_BELL
+
ME_ERROR_LOG
),
*
size
);
}
}
}
#elif defined(HAVE_MMAP)
...
...
@@ -308,12 +322,15 @@ uchar *my_large_malloc(size_t *size, myf my_flags)
if
(
my_use_large_pages
)
{
large_page_size
=
my_next_large_page_size
(
*
size
,
&
page_i
);
/* this might be 0, in which case we do a standard mmap */
if
(
large_page_size
)
{
#ifdef __linux__
mapflag
|=
MAP_HUGETLB
|
my_bit_log2_size_t
(
large_page_size
)
<<
MAP_HUGE_SHIFT
;
mapflag
|=
MAP_HUGETLB
|
my_bit_log2_size_t
(
large_page_size
)
<<
MAP_HUGE_SHIFT
;
#elif defined(MAP_ALIGNED)
mapflag
|=
MAP_ALIGNED_SUPER
|
MAP_ALIGNED
(
my_bit_log2_size_t
(
large_page_size
));
mapflag
|=
MAP_ALIGNED_SUPER
|
MAP_ALIGNED
(
my_bit_log2_size_t
(
large_page_size
));
#endif
aligned_size
=
MY_ALIGN
(
*
size
,
(
size_t
)
large_page_size
);
}
...
...
@@ -330,16 +347,15 @@ uchar *my_large_malloc(size_t *size, myf my_flags)
{
if
(
large_page_size
)
{
fprintf
(
stderr
,
"Warning: Failed to allocate %zu bytes from HugeTLB memory"
"(page size %zu). errno %d
\n
"
,
aligned_size
,
large_page_size
,
errno
);
my_printf_error
(
EE_OUTOFMEMORY
,
"Couldn't allocate %zu bytes (Large/HugeTLB memory "
"page size %zu); errno %u; continuing to smaller size"
,
MYF
(
ME_WARNING
|
ME_ERROR_LOG_ONLY
),
aligned_size
,
large_page_size
,
errno
);
}
else
{
fprintf
(
stderr
,
"Warning: Failed to allocate %zu bytes from memory."
" errno %d
\n
"
,
aligned_size
,
errno
);
my_error
(
EE_OUTOFMEMORY
,
MYF
(
ME_BELL
+
ME_ERROR_LOG
),
aligned_size
);
}
}
/* try next smaller memory size */
...
...
@@ -403,9 +419,7 @@ void my_large_free(void *ptr, size_t size)
#if defined(HAVE_MMAP) && !defined(_WIN32)
if
(
munmap
(
ptr
,
size
))
{
fprintf
(
stderr
,
"Warning: Failed to unmap location %p, %zu bytes, errno %d
\n
"
,
ptr
,
size
,
errno
);
my_error
(
EE_BADMEMORYRELEASE
,
MYF
(
ME_ERROR_LOG_ONLY
),
ptr
,
size
,
errno
);
}
else
{
...
...
@@ -418,8 +432,8 @@ void my_large_free(void *ptr, size_t size)
*/
if
(
ptr
&&
!
VirtualFree
(
ptr
,
0
,
MEM_RELEASE
))
{
fprintf
(
stderr
,
"Error: VirtualFree(%p, %zu) failed; Windows error %lu
\n
"
,
ptr
,
size
,
GetLastError
());
my_error
(
EE_BADMEMORYRELEASE
,
MYF
(
ME_ERROR_LOG_ONLY
),
ptr
,
size
,
GetLastError
());
}
else
{
...
...
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