Repository: trafficserver
Updated Branches:
  refs/heads/master 3b24ea14e -> fe219a131


TS-3417: Add MADV_DONTDUMP capability


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/fe219a13
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/fe219a13
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/fe219a13

Branch: refs/heads/master
Commit: fe219a131af7d9af3c96a9079830141ba03e0378
Parents: 3b24ea1
Author: Phil Sorber <[email protected]>
Authored: Sat Feb 28 12:35:40 2015 -0700
Committer: Phil Sorber <[email protected]>
Committed: Mon Mar 9 19:45:06 2015 -0600

----------------------------------------------------------------------
 CHANGES                        |  2 ++
 iocore/eventsystem/IOBuffer.cc | 14 +++++++++++++-
 lib/ts/Allocator.h             |  5 ++---
 lib/ts/ink_queue.cc            | 18 ++++++++++++++----
 lib/ts/ink_queue.h             |  4 ++--
 mgmt/RecordsConfig.cc          |  2 ++
 6 files changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fe219a13/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2ea6b7f..79b0fa5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.3.0
 
+  *) [TS-3417] Add MADV_DONTDUMP capability
+
   *) [TS-3036] Add a new log tag, 'chm', which shows cache-hit-miss specific
    information. For example, was this a RAM cache hit.
    Co-Author: Ryan Franz.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fe219a13/iocore/eventsystem/IOBuffer.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/IOBuffer.cc b/iocore/eventsystem/IOBuffer.cc
index 879e8ba..9a86895 100644
--- a/iocore/eventsystem/IOBuffer.cc
+++ b/iocore/eventsystem/IOBuffer.cc
@@ -25,7 +25,9 @@
   UIOBuffer.cc
 
 **************************************************************************/
+#include "ink_defs.h"
 #include "P_EventSystem.h"
+#include "I_RecCore.h"
 
 //
 // General Buffer Allocator
@@ -45,6 +47,16 @@ void
 init_buffer_allocators()
 {
   char *name;
+  int advice = 0;
+
+#ifdef MADV_DONTDUMP // This should only exist on Linux 3.4 and higher.
+    bool dont_dump_enabled;
+    RecGetRecordBool("proxy.config.allocator.dontdump_iobuffers", 
&dont_dump_enabled, false);
+
+    if (dont_dump_enabled) {
+      advice = MADV_DONTDUMP;
+    }
+#endif
 
   for (int i = 0; i < DEFAULT_BUFFER_SIZES; i++) {
     int64_t s = DEFAULT_BUFFER_BASE_SIZE * (((int64_t)1) << i);
@@ -55,7 +67,7 @@ init_buffer_allocators()
 
     name = new char[64];
     snprintf(name, 64, "ioBufAllocator[%d]", i);
-    ioBufAllocator[i].re_init(name, s, n, a);
+    ioBufAllocator[i].re_init(name, s, n, a, advice);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fe219a13/lib/ts/Allocator.h
----------------------------------------------------------------------
diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h
index 1e8bba6..9f4edde 100644
--- a/lib/ts/Allocator.h
+++ b/lib/ts/Allocator.h
@@ -96,10 +96,9 @@ public:
 
   /** Re-initialize the parameters of the allocator. */
   void
-  re_init(const char *name, unsigned int element_size,
-          unsigned int chunk_size, unsigned int alignment)
+  re_init(const char *name, unsigned int element_size, unsigned int 
chunk_size, unsigned int alignment, int advice)
   {
-    ink_freelist_init(&this->fl, name, element_size, chunk_size, alignment);
+    ink_freelist_madvise_init(&this->fl, name, element_size, chunk_size, 
alignment, advice);
   }
 
 protected:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fe219a13/lib/ts/ink_queue.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.cc b/lib/ts/ink_queue.cc
index 49207a9..9e0b7dc 100644
--- a/lib/ts/ink_queue.cc
+++ b/lib/ts/ink_queue.cc
@@ -111,10 +111,18 @@ ink_freelist_init(InkFreeList **fl, const char *name, 
uint32_t type_size,
   f->allocated = 0;
   f->allocated_base = 0;
   f->used_base = 0;
+  f->advice = 0;
   *fl = f;
 #endif
 }
 
+void
+ink_freelist_madvise_init(InkFreeList **fl, const char *name, uint32_t 
type_size, uint32_t chunk_size, uint32_t alignment, int advice)
+{
+  ink_freelist_init(fl, name, type_size, chunk_size, alignment);
+  (*fl)->advice = advice;
+}
+
 InkFreeList *
 ink_freelist_create(const char *name, uint32_t type_size, uint32_t chunk_size,
                     uint32_t alignment)
@@ -165,6 +173,8 @@ ink_freelist_new(InkFreeList * f)
         newp = ats_memalign(f->alignment, f->chunk_size * type_size);
       else
         newp = ats_malloc(f->chunk_size * type_size);
+      ats_madvise((caddr_t)newp, f->chunk_size * type_size, f->advice);
+
       fl_memadd(f->chunk_size * type_size);
 #ifdef DEBUG
       newsbrk = (char *) sbrk(0);
@@ -235,10 +245,10 @@ ink_freelist_new(InkFreeList * f)
     newp = ats_memalign(f->alignment, f->type_size);
   else
     newp = ats_malloc(f->type_size);
+  ats_madvise((caddr_t)newp, f->type_size, f->advice);
   return newp;
 #endif
 }
-typedef volatile void *volatile_void_p;
 
 void
 ink_freelist_free(InkFreeList * f, void *item)
@@ -247,7 +257,7 @@ ink_freelist_free(InkFreeList * f, void *item)
 #if TS_USE_RECLAIMABLE_FREELIST
   return reclaimable_freelist_free(f, item);
 #else
-  volatile_void_p *adr_of_next = (volatile_void_p *) ADDRESS_OF_NEXT(item, 0);
+  volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(item, 0);
   head_p h;
   head_p item_pair;
   int result = 0;
@@ -300,7 +310,7 @@ ink_freelist_free_bulk(InkFreeList *f, void *head, void 
*tail, size_t num_item)
 {
 #if TS_USE_FREELIST
 #if !TS_USE_RECLAIMABLE_FREELIST
-  volatile_void_p *adr_of_next = (volatile_void_p *) ADDRESS_OF_NEXT(tail, 0);
+  volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(tail, 0);
   head_p h;
   head_p item_pair;
   int result = 0;
@@ -505,7 +515,7 @@ ink_atomiclist_popall(InkAtomicList * l)
 void *
 ink_atomiclist_push(InkAtomicList * l, void *item)
 {
-  volatile_void_p *adr_of_next = (volatile_void_p *) ADDRESS_OF_NEXT(item, 
l->offset);
+  volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(item, 
l->offset);
   head_p head;
   head_p item_pair;
   int result = 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fe219a13/lib/ts/ink_queue.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.h b/lib/ts/ink_queue.h
index 6c1b1c2..37e0953 100644
--- a/lib/ts/ink_queue.h
+++ b/lib/ts/ink_queue.h
@@ -146,8 +146,6 @@ extern "C"
 #error "unsupported processor"
 #endif
 
-  typedef void *void_p;
-
 #if TS_USE_RECLAIMABLE_FREELIST
   extern float cfg_reclaim_factor;
   extern int64_t cfg_max_overage;
@@ -160,6 +158,7 @@ extern "C"
     const char *name;
     uint32_t type_size, chunk_size, used, allocated, alignment;
     uint32_t allocated_base, used_base;
+    int advice;
   };
 
   inkcoreapi extern volatile int64_t fastalloc_mem_in_use;
@@ -184,6 +183,7 @@ extern "C"
   inkcoreapi void ink_freelist_init(InkFreeList **fl, const char *name,
                                     uint32_t type_size, uint32_t chunk_size,
                                     uint32_t alignment);
+  inkcoreapi void ink_freelist_madvise_init(InkFreeList **fl, const char 
*name, uint32_t type_size, uint32_t chunk_size, uint32_t alignment, int advice);
   inkcoreapi void *ink_freelist_new(InkFreeList * f);
   inkcoreapi void ink_freelist_free(InkFreeList * f, void *item);
   inkcoreapi void ink_freelist_free_bulk(InkFreeList * f, void *head, void 
*tail, size_t num_item);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fe219a13/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 03a32ec..b360aa0 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -2062,6 +2062,8 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.allocator.thread_freelist_low_watermark", 
RECD_INT, "32", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
+  {RECT_CONFIG, "proxy.config.allocator.dontdump_iobuffers", RECD_INT, "0", 
RECU_NULL, RR_NULL, RECC_NULL, "[0-1]", RECA_NULL}
+  ,
 
   //############
   //#

Reply via email to