Commit 4404ee29 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-17441 - InnoDB transition to C++11 atomics

os_total_large_mem_allocated transition to Atomic_counter.
parent dab38ce0
...@@ -40,7 +40,7 @@ typedef unsigned long int os_process_id_t; ...@@ -40,7 +40,7 @@ typedef unsigned long int os_process_id_t;
/** 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 os_mem_alloc_large(). */
extern ulint os_total_large_mem_allocated; extern Atomic_counter<ulint> os_total_large_mem_allocated;
/** Whether to use large pages in the buffer pool */ /** Whether to use large pages in the buffer pool */
extern my_bool os_use_large_pages; extern my_bool os_use_large_pages;
......
...@@ -36,7 +36,7 @@ MAP_ANON but MAP_ANON is marked as deprecated */ ...@@ -36,7 +36,7 @@ MAP_ANON but MAP_ANON is marked as deprecated */
/** 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 os_mem_alloc_large(). */
ulint os_total_large_mem_allocated = 0; Atomic_counter<ulint> os_total_large_mem_allocated;
/** Whether to use large pages in the buffer pool */ /** Whether to use large pages in the buffer pool */
my_bool os_use_large_pages; my_bool os_use_large_pages;
...@@ -100,9 +100,7 @@ os_mem_alloc_large( ...@@ -100,9 +100,7 @@ os_mem_alloc_large(
if (ptr) { if (ptr) {
*n = size; *n = size;
my_atomic_addlint( os_total_large_mem_allocated += size;
&os_total_large_mem_allocated, size);
UNIV_MEM_ALLOC(ptr, size); UNIV_MEM_ALLOC(ptr, size);
return(ptr); return(ptr);
} }
...@@ -127,8 +125,7 @@ os_mem_alloc_large( ...@@ -127,8 +125,7 @@ os_mem_alloc_large(
ib::info() << "VirtualAlloc(" << size << " bytes) failed;" ib::info() << "VirtualAlloc(" << size << " bytes) failed;"
" Windows error " << GetLastError(); " Windows error " << GetLastError();
} else { } else {
my_atomic_addlint( os_total_large_mem_allocated += size;
&os_total_large_mem_allocated, size);
UNIV_MEM_ALLOC(ptr, size); UNIV_MEM_ALLOC(ptr, size);
} }
#else #else
...@@ -143,8 +140,7 @@ os_mem_alloc_large( ...@@ -143,8 +140,7 @@ os_mem_alloc_large(
" errno " << errno; " errno " << errno;
ptr = NULL; ptr = NULL;
} else { } else {
my_atomic_addlint( os_total_large_mem_allocated += size;
&os_total_large_mem_allocated, size);
UNIV_MEM_ALLOC(ptr, size); UNIV_MEM_ALLOC(ptr, size);
} }
#endif #endif
...@@ -163,8 +159,7 @@ os_mem_free_large( ...@@ -163,8 +159,7 @@ os_mem_free_large(
#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX #if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) { if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) {
my_atomic_addlint( os_total_large_mem_allocated -= size;
&os_total_large_mem_allocated, -size);
UNIV_MEM_FREE(ptr, size); UNIV_MEM_FREE(ptr, size);
return; return;
} }
...@@ -176,8 +171,7 @@ os_mem_free_large( ...@@ -176,8 +171,7 @@ os_mem_free_large(
ib::error() << "VirtualFree(" << ptr << ", " << size ib::error() << "VirtualFree(" << ptr << ", " << size
<< ") failed; Windows error " << GetLastError(); << ") failed; Windows error " << GetLastError();
} else { } else {
my_atomic_addlint( os_total_large_mem_allocated -= size;
&os_total_large_mem_allocated, -lint(size));
UNIV_MEM_FREE(ptr, size); UNIV_MEM_FREE(ptr, size);
} }
#elif !defined OS_MAP_ANON #elif !defined OS_MAP_ANON
...@@ -191,8 +185,7 @@ os_mem_free_large( ...@@ -191,8 +185,7 @@ os_mem_free_large(
ib::error() << "munmap(" << ptr << ", " << size << ") failed;" ib::error() << "munmap(" << ptr << ", " << size << ") failed;"
" errno " << errno; " errno " << errno;
} else { } else {
my_atomic_addlint( os_total_large_mem_allocated -= size;
&os_total_large_mem_allocated, -size);
UNIV_MEM_FREE(ptr, size); UNIV_MEM_FREE(ptr, size);
} }
#endif #endif
......
...@@ -1329,7 +1329,7 @@ srv_printf_innodb_monitor( ...@@ -1329,7 +1329,7 @@ srv_printf_innodb_monitor(
fprintf(file, fprintf(file,
"Total large memory allocated " ULINTPF "\n" "Total large memory allocated " ULINTPF "\n"
"Dictionary memory allocated " ULINTPF "\n", "Dictionary memory allocated " ULINTPF "\n",
os_total_large_mem_allocated, ulint{os_total_large_mem_allocated},
dict_sys_get_size()); dict_sys_get_size());
buf_print_io(file); buf_print_io(file);
......
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