1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Coding style fixes

This commit is contained in:
Sergey Vojtovich
2020-04-03 20:53:53 +04:00
parent e4a960780f
commit 4338bb8a75
6 changed files with 28 additions and 22 deletions

View File

@@ -74,8 +74,9 @@ static inline CONSTEXPR uint my_bit_log2_size_t(size_t value)
{ {
#ifdef __cplusplus #ifdef __cplusplus
static_assert(sizeof(size_t) <= sizeof(ulonglong), static_assert(sizeof(size_t) <= sizeof(ulonglong),
"size_t <= ulonglong is an assumption that needs to be fixed for this architecture. " "size_t <= ulonglong is an assumption that needs to be fixed "
"Please create an issue on https://jira.mariadb.org"); "for this architecture. Please create an issue on "
"https://jira.mariadb.org");
#endif #endif
return my_bit_log2_uint64((ulonglong) value); return my_bit_log2_uint64((ulonglong) value);
} }

View File

@@ -185,11 +185,11 @@ extern void my_get_large_page_size(void);
#ifdef HAVE_LARGE_PAGE_OPTION #ifdef HAVE_LARGE_PAGE_OPTION
int my_init_large_pages(my_bool super_large_pages); int my_init_large_pages(my_bool super_large_pages);
uchar * my_large_malloc(size_t *size, myf my_flags); uchar *my_large_malloc(size_t *size, myf my_flags);
void my_large_free(void *ptr, size_t size); void my_large_free(void *ptr, size_t size);
#else #else
#define my_large_malloc(A,B) my_malloc_lock(*(A),(B)) #define my_large_malloc(A, B) my_malloc_lock(*(A), (B))
#define my_large_free(A,B) my_free_lock((A)) #define my_large_free(A, B) my_free_lock((A))
#endif /* HAVE_LARGE_PAGE_OPTION */ #endif /* HAVE_LARGE_PAGE_OPTION */
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -547,7 +547,8 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
((size_t) blocks * keycache->key_cache_block_size) > use_mem && blocks > 8) ((size_t) blocks * keycache->key_cache_block_size) > use_mem && blocks > 8)
blocks--; blocks--;
keycache->allocated_mem_size= blocks * keycache->key_cache_block_size; keycache->allocated_mem_size= blocks * keycache->key_cache_block_size;
if ((keycache->block_mem=my_large_malloc(&keycache->allocated_mem_size, MYF(0)))) if ((keycache->block_mem= my_large_malloc(&keycache->allocated_mem_size,
MYF(0))))
{ {
/* /*
Allocate memory for blocks, hash_links and hash entries; Allocate memory for blocks, hash_links and hash entries;

View File

@@ -125,8 +125,9 @@ int my_init_large_pages(my_bool super_large_pages)
my_get_large_page_sizes(my_large_page_sizes); my_get_large_page_sizes(my_large_page_sizes);
if (!my_obtain_privilege(SE_LOCK_MEMORY_NAME)) if (!my_obtain_privilege(SE_LOCK_MEMORY_NAME))
{ {
fprintf(stderr, "mysqld: Lock Pages in memory access rights required for use with large-pages, " fprintf(stderr, "mysqld: Lock Pages in memory access rights required for "
"see https://mariadb.com/kb/en/library/mariadb-memory-allocation/#huge-pages"); "use with large-pages, see https://mariadb.com/kb/en/library/"
"mariadb-memory-allocation/#huge-pages");
return 1; return 1;
} }
#ifdef HAVE_SOLARIS_LARGE_PAGES #ifdef HAVE_SOLARIS_LARGE_PAGES
@@ -158,12 +159,12 @@ int my_init_large_pages(my_bool super_large_pages)
mpss.mha_cmd= MHA_MAPSIZE_BSSBRK; mpss.mha_cmd= MHA_MAPSIZE_BSSBRK;
mpss.mha_pagesize= max_page_size; mpss.mha_pagesize= max_page_size;
mpss.mha_flags= 0; mpss.mha_flags= 0;
if (memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mpss, 0, 0)) if (memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t) &mpss, 0, 0))
{ {
perror("memcntl MC_HAT_ADVISE cmd MHA_MAPSIZE_BSSBRK error (continuing)"); perror("memcntl MC_HAT_ADVISE cmd MHA_MAPSIZE_BSSBRK error (continuing)");
} }
mpss.mha_cmd= MHA_MAPSIZE_STACK; mpss.mha_cmd= MHA_MAPSIZE_STACK;
if (memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mpss, 0, 0)) if (memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t) &mpss, 0, 0))
{ {
perror("memcntl MC_HAT_ADVISE cmd MHA_MAPSIZE_STACK error (continuing)"); perror("memcntl MC_HAT_ADVISE cmd MHA_MAPSIZE_STACK error (continuing)");
} }
@@ -245,15 +246,15 @@ static void my_get_large_page_sizes(size_t sizes[my_large_page_sizes_length])
} }
else else
{ {
while (i < my_large_page_sizes_length && while (i < my_large_page_sizes_length && (r= readdir(dirp)))
(r= readdir(dirp)))
{ {
if (strncmp("hugepages-", r->d_name, 10) == 0) if (strncmp("hugepages-", r->d_name, 10) == 0)
{ {
sizes[i]= strtoull(r->d_name + 10, NULL, 10) * 1024ULL; sizes[i]= strtoull(r->d_name + 10, NULL, 10) * 1024ULL;
if (!my_is_2pow(sizes[i])) if (!my_is_2pow(sizes[i]))
{ {
fprintf(stderr, "Warning: non-power of 2 large page size (%zu) found, skipping\n", sizes[i]); fprintf(stderr, "Warning: non-power of 2 large page size (%zu) found,"
" skipping\n", sizes[i]);
sizes[i]= 0; sizes[i]= 0;
continue; continue;
} }
@@ -312,7 +313,8 @@ uchar* my_large_malloc_int(size_t *size, myf my_flags)
{ {
fprintf(stderr, fprintf(stderr,
"Warning: Failed to allocate %zu bytes from HugeTLB memory" "Warning: Failed to allocate %zu bytes from HugeTLB memory"
"(page size %zu). errno %d\n", aligned_size, large_page_size, errno); "(page size %zu). errno %d\n", aligned_size, large_page_size,
errno);
} }
else else
{ {
@@ -332,11 +334,11 @@ uchar* my_large_malloc_int(size_t *size, myf my_flags)
{ {
if (large_page_size) if (large_page_size)
{ {
/* /*
we do need to record the adjustment so that munmap gets called with we do need to record the adjustment so that munmap gets called with
the right size. This is only the case for HUGETLB pages. the right size. This is only the case for HUGETLB pages.
*/ */
*size= aligned_size; *size= aligned_size;
} }
DBUG_RETURN(ptr); DBUG_RETURN(ptr);
} }

View File

@@ -5042,8 +5042,10 @@ static int init_server_components()
{"timed-mutexes", OPT_DEPRECATED_OPTION, "", {"timed-mutexes", OPT_DEPRECATED_OPTION, "",
0, 0, 0, GET_NO_ARG, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, OPT_ARG, 0, 0, 0, 0, 0, 0},
#if defined(__linux__) #if defined(__linux__)
/* Linux was the only large page OS that we've now removed the (always) /*
unused super-large-pages (because its Solaris only). */ Linux was the only large page OS that we've now removed the (always)
unused super-large-pages (because its Solaris only).
*/
{"super-large-pages", OPT_DEPRECATED_OPTION, "", {"super-large-pages", OPT_DEPRECATED_OPTION, "",
0, 0, 0, GET_NO_ARG, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif

View File

@@ -28,7 +28,7 @@ Created 9/30/1995 Heikki Tuuri
#include "univ.i" #include "univ.i"
/** The total amount of memory currently allocated from the operating /** The total amount of memory currently allocated from the operating
system with os_mem_alloc_large(). */ system with allocacte_large(). */
Atomic_counter<ulint> os_total_large_mem_allocated; Atomic_counter<ulint> os_total_large_mem_allocated;
/** Converts the current process id to a number. /** Converts the current process id to a number.