From e0a98c7d89ae5754d925c12a98cdf2630dc9db57 Mon Sep 17 00:00:00 2001 From: "John J. Rushford" Date: Tue, 11 Oct 2016 21:37:01 +0000 Subject: [PATCH] TS-4957: Make the use of madvise() with MADV_DONTDUMP configurable. --- doc/admin-guide/files/records.config.en.rst | 6 ++++++ iocore/eventsystem/EventSystem.cc | 13 ++++++++++++- iocore/eventsystem/IOBuffer.cc | 9 ++------- iocore/eventsystem/I_IOBuffer.h | 2 +- mgmt/RecordsConfig.cc | 2 ++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index 199ffaad822..2aecc96c13c 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -3545,6 +3545,12 @@ Sockets For more information on the implications of enabling huge pages, see `Wikipedia _`. +.. ts:cv:: CONFIG proxy.config.allocator.dontdump_iobuffers INT 1 + + Enable (1) the exclusion of IO buffers from core files when ATS crashes on supported + platforms. (Currently only linux). IO buffers are allocated with the MADV_DONTDUMP + with madvise() on linux platforms that support MADV_DONTDUMP. Enabled by default. + .. ts:cv:: CONFIG proxy.config.http.enabled INT 1 Turn on or off support for HTTP proxying. This is rarely used, the one diff --git a/iocore/eventsystem/EventSystem.cc b/iocore/eventsystem/EventSystem.cc index d63440bb84b..1cb361397c9 100644 --- a/iocore/eventsystem/EventSystem.cc +++ b/iocore/eventsystem/EventSystem.cc @@ -35,6 +35,7 @@ ink_event_system_init(ModuleVersion v) { ink_release_assert(!checkModuleVersion(v, EVENT_SYSTEM_MODULE_VERSION)); int config_max_iobuffer_size = DEFAULT_MAX_BUFFER_SIZE; + int iobuffer_advice = 0; // For backwards compatability make sure to allow thread_freelist_size // This needs to change in 6.0 @@ -51,5 +52,15 @@ ink_event_system_init(ModuleVersion v) if (default_large_iobuffer_size > max_iobuffer_size) { default_large_iobuffer_size = max_iobuffer_size; } - init_buffer_allocators(); + +#ifdef MADV_DONTDUMP // This should only exist on Linux 3.4 and higher. + RecBool dont_dump_enabled = true; + RecGetRecordBool("proxy.config.allocator.dontdump_iobuffers", &dont_dump_enabled, false); + + if (dont_dump_enabled) { + iobuffer_advice |= MADV_DONTDUMP; + } +#endif + + init_buffer_allocators(iobuffer_advice); } diff --git a/iocore/eventsystem/IOBuffer.cc b/iocore/eventsystem/IOBuffer.cc index 1efb8afc731..c2aa910a350 100644 --- a/iocore/eventsystem/IOBuffer.cc +++ b/iocore/eventsystem/IOBuffer.cc @@ -43,14 +43,9 @@ int64_t max_iobuffer_size = DEFAULT_BUFFER_SIZES - 1; // Initialization // void -init_buffer_allocators() +init_buffer_allocators(int iobuffer_advice) { char *name; - int advice = 0; - -#ifdef MADV_DONTDUMP // This should only exist on Linux 3.4 and higher. - advice = MADV_DONTDUMP; -#endif for (int i = 0; i < DEFAULT_BUFFER_SIZES; i++) { int64_t s = DEFAULT_BUFFER_BASE_SIZE * (((int64_t)1) << i); @@ -61,7 +56,7 @@ init_buffer_allocators() name = new char[64]; snprintf(name, 64, "ioBufAllocator[%d]", i); - ioBufAllocator[i].re_init(name, s, n, a, advice); + ioBufAllocator[i].re_init(name, s, n, a, iobuffer_advice); } } diff --git a/iocore/eventsystem/I_IOBuffer.h b/iocore/eventsystem/I_IOBuffer.h index 26414abe79a..e071775d02a 100644 --- a/iocore/eventsystem/I_IOBuffer.h +++ b/iocore/eventsystem/I_IOBuffer.h @@ -125,7 +125,7 @@ enum AllocType { inkcoreapi extern Allocator ioBufAllocator[DEFAULT_BUFFER_SIZES]; -void init_buffer_allocators(); +void init_buffer_allocators(int iobuffer_advice); /** A reference counted wrapper around fast allocated or malloced memory. diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 23d27ab0886..8b06b443ee1 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -1449,6 +1449,8 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.allocator.hugepages", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_NULL, "[0-1]", RECA_NULL} , + {RECT_CONFIG, "proxy.config.allocator.dontdump_iobuffers", RECD_INT, "1", RECU_RESTART_TS, RR_NULL, RECC_NULL, "[0-1]", RECA_NULL} + , //############ //#