Commit f120a15b authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19212 4GB Limit on large_pages - integer overflow

os_mem_alloc_large(): Invoke the macro ut_2pow_round() with the
correct argument type.

innobase_large_page_size, innobase_use_large_pages,
os_use_large_pages, os_large_page_size: Remove.
Simply refer to opt_large_page_size, my_use_large_pages.
parent caa8c20a
...@@ -221,8 +221,6 @@ const char *defaults_group = "mysqld"; ...@@ -221,8 +221,6 @@ const char *defaults_group = "mysqld";
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_INNOBASE_RANGE_COUNT 100 #define HA_INNOBASE_RANGE_COUNT 100
ulong innobase_large_page_size = 0;
/* The default values for the following, type long or longlong, start-up /* The default values for the following, type long or longlong, start-up
parameters are declared in mysqld.cc: */ parameters are declared in mysqld.cc: */
...@@ -247,7 +245,6 @@ affects Windows: */ ...@@ -247,7 +245,6 @@ affects Windows: */
char* innobase_unix_file_flush_method; char* innobase_unix_file_flush_method;
my_bool innobase_use_doublewrite; my_bool innobase_use_doublewrite;
my_bool innobase_use_large_pages;
my_bool innobase_file_per_table; my_bool innobase_file_per_table;
my_bool innobase_locks_unsafe_for_binlog; my_bool innobase_locks_unsafe_for_binlog;
my_bool innobase_rollback_on_timeout; my_bool innobase_rollback_on_timeout;
...@@ -1919,8 +1916,6 @@ innodb_init_param(void) ...@@ -1919,8 +1916,6 @@ innodb_init_param(void)
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
os_use_large_pages = (ibool) innobase_use_large_pages;
os_large_page_size = (ulint) innobase_large_page_size;
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
srv_file_per_table = (my_bool) innobase_file_per_table; srv_file_per_table = (my_bool) innobase_file_per_table;
......
...@@ -1566,7 +1566,7 @@ buf_chunk_init( ...@@ -1566,7 +1566,7 @@ buf_chunk_init(
chunk->blocks = (buf_block_t*) chunk->mem; chunk->blocks = (buf_block_t*) chunk->mem;
/* Align a pointer to the first frame. Note that when /* Align a pointer to the first frame. Note that when
os_large_page_size is smaller than UNIV_PAGE_SIZE, opt_large_page_size is smaller than UNIV_PAGE_SIZE,
we may allocate one fewer block than requested. When we may allocate one fewer block than requested. When
it is bigger, we may allocate more blocks than requested. */ it is bigger, we may allocate more blocks than requested. */
......
...@@ -4265,12 +4265,6 @@ innobase_init( ...@@ -4265,12 +4265,6 @@ innobase_init(
innodb_log_checksums = innodb_log_checksums_func_update( innodb_log_checksums = innodb_log_checksums_func_update(
NULL, innodb_log_checksums); NULL, innodb_log_checksums);
#ifdef HAVE_LINUX_LARGE_PAGES
if ((os_use_large_pages = my_use_large_pages)) {
os_large_page_size = opt_large_page_size;
}
#endif
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -42,12 +42,6 @@ typedef unsigned long int os_process_id_t; ...@@ -42,12 +42,6 @@ typedef unsigned long int os_process_id_t;
system with os_mem_alloc_large(). */ system with os_mem_alloc_large(). */
extern ulint os_total_large_mem_allocated; extern ulint os_total_large_mem_allocated;
/** Whether to use large pages in the buffer pool */
extern my_bool os_use_large_pages;
/** Large page size. This may be a boot-time option on some platforms */
extern uint os_large_page_size;
/** Converts the current process id to a number. /** Converts the current process id to a number.
@return process id as a number */ @return process id as a number */
ulint ulint
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -25,6 +26,9 @@ Created 9/30/1995 Heikki Tuuri ...@@ -25,6 +26,9 @@ Created 9/30/1995 Heikki Tuuri
*******************************************************/ *******************************************************/
#include "univ.i" #include "univ.i"
#ifdef HAVE_LINUX_LARGE_PAGES
# include "mysqld.h"
#endif
/* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and /* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and
MAP_ANON but MAP_ANON is marked as deprecated */ MAP_ANON but MAP_ANON is marked as deprecated */
...@@ -38,12 +42,6 @@ MAP_ANON but MAP_ANON is marked as deprecated */ ...@@ -38,12 +42,6 @@ MAP_ANON but MAP_ANON is marked as deprecated */
system with os_mem_alloc_large(). */ system with os_mem_alloc_large(). */
ulint os_total_large_mem_allocated = 0; ulint os_total_large_mem_allocated = 0;
/** Whether to use large pages in the buffer pool */
my_bool os_use_large_pages;
/** Large page size. This may be a boot-time option on some platforms */
uint os_large_page_size;
/** Converts the current process id to a number. /** Converts the current process id to a number.
@return process id as a number */ @return process id as a number */
ulint ulint
...@@ -66,18 +64,18 @@ os_mem_alloc_large( ...@@ -66,18 +64,18 @@ os_mem_alloc_large(
{ {
void* ptr; void* ptr;
ulint size; ulint size;
#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX #ifdef HAVE_LINUX_LARGE_PAGES
int shmid; int shmid;
struct shmid_ds buf; struct shmid_ds buf;
if (!os_use_large_pages || !os_large_page_size) { if (!my_use_large_pages || !opt_large_page_size) {
goto skip; goto skip;
} }
/* Align block size to os_large_page_size */ /* Align block size to opt_large_page_size */
ut_ad(ut_is_2pow(os_large_page_size)); ut_ad(ut_is_2pow(opt_large_page_size));
size = ut_2pow_round(*n + (os_large_page_size - 1), size = ut_2pow_round(*n + opt_large_page_size - 1,
os_large_page_size); ulint(opt_large_page_size));
shmid = shmget(IPC_PRIVATE, (size_t) size, SHM_HUGETLB | SHM_R | SHM_W); shmid = shmget(IPC_PRIVATE, (size_t) size, SHM_HUGETLB | SHM_R | SHM_W);
if (shmid < 0) { if (shmid < 0) {
...@@ -109,7 +107,7 @@ os_mem_alloc_large( ...@@ -109,7 +107,7 @@ os_mem_alloc_large(
ib::warn() << "Using conventional memory pool"; ib::warn() << "Using conventional memory pool";
skip: skip:
#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */ #endif /* HAVE_LINUX_LARGE_PAGES */
#ifdef _WIN32 #ifdef _WIN32
SYSTEM_INFO system_info; SYSTEM_INFO system_info;
...@@ -161,13 +159,13 @@ os_mem_free_large( ...@@ -161,13 +159,13 @@ os_mem_free_large(
{ {
ut_a(os_total_large_mem_allocated >= size); ut_a(os_total_large_mem_allocated >= size);
#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX #ifdef HAVE_LINUX_LARGE_PAGES
if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) { if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) {
my_atomic_addlint( my_atomic_addlint(
&os_total_large_mem_allocated, -size); &os_total_large_mem_allocated, -size);
return; return;
} }
#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */ #endif /* HAVE_LINUX_LARGE_PAGES */
#ifdef _WIN32 #ifdef _WIN32
/* When RELEASE memory, the size parameter must be 0. /* When RELEASE memory, the size parameter must be 0.
Do not use MEM_RELEASE with MEM_DECOMMIT. */ Do not use MEM_RELEASE with MEM_DECOMMIT. */
......
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