Skip to content
Permalink
Browse files
MDEV-17441 - InnoDB transition to C++11 atomics
os_total_large_mem_allocated transition to Atomic_counter.
  • Loading branch information
Sergey Vojtovich committed Dec 27, 2018
1 parent dab38ce commit 4404ee2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
@@ -40,7 +40,7 @@ typedef unsigned long int os_process_id_t;

/** The total amount of memory currently allocated from the operating
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 */
extern my_bool os_use_large_pages;
@@ -36,7 +36,7 @@ MAP_ANON but MAP_ANON is marked as deprecated */

/** The total amount of memory currently allocated from the operating
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 */
my_bool os_use_large_pages;
@@ -100,9 +100,7 @@ os_mem_alloc_large(

if (ptr) {
*n = size;
my_atomic_addlint(
&os_total_large_mem_allocated, size);

os_total_large_mem_allocated += size;
UNIV_MEM_ALLOC(ptr, size);
return(ptr);
}
@@ -127,8 +125,7 @@ os_mem_alloc_large(
ib::info() << "VirtualAlloc(" << size << " bytes) failed;"
" Windows error " << GetLastError();
} else {
my_atomic_addlint(
&os_total_large_mem_allocated, size);
os_total_large_mem_allocated += size;
UNIV_MEM_ALLOC(ptr, size);
}
#else
@@ -143,8 +140,7 @@ os_mem_alloc_large(
" errno " << errno;
ptr = NULL;
} else {
my_atomic_addlint(
&os_total_large_mem_allocated, size);
os_total_large_mem_allocated += size;
UNIV_MEM_ALLOC(ptr, size);
}
#endif
@@ -163,8 +159,7 @@ os_mem_free_large(

#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
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);
return;
}
@@ -176,8 +171,7 @@ os_mem_free_large(
ib::error() << "VirtualFree(" << ptr << ", " << size
<< ") failed; Windows error " << GetLastError();
} else {
my_atomic_addlint(
&os_total_large_mem_allocated, -lint(size));
os_total_large_mem_allocated -= size;
UNIV_MEM_FREE(ptr, size);
}
#elif !defined OS_MAP_ANON
@@ -191,8 +185,7 @@ os_mem_free_large(
ib::error() << "munmap(" << ptr << ", " << size << ") failed;"
" errno " << errno;
} else {
my_atomic_addlint(
&os_total_large_mem_allocated, -size);
os_total_large_mem_allocated -= size;
UNIV_MEM_FREE(ptr, size);
}
#endif
@@ -1329,7 +1329,7 @@ srv_printf_innodb_monitor(
fprintf(file,
"Total large memory allocated " ULINTPF "\n"
"Dictionary memory allocated " ULINTPF "\n",
os_total_large_mem_allocated,
ulint{os_total_large_mem_allocated},
dict_sys_get_size());

buf_print_io(file);

0 comments on commit 4404ee2

Please sign in to comment.