summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/dlmalloc.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-06-15 12:46:13 -0400
committerDave Barach <dave@barachs.net>2019-06-16 10:24:43 -0400
commitd67a428b3b2183cd78d7fca82e8afe2f26387810 (patch)
treef5209028aa2cfb222f35bb0c970685b8d2d777d8 /src/vppinfra/dlmalloc.c
parentc898a4f5bae84148ddec462a9510dee99e3da67d (diff)
vlib: add "memory-trace stats-segment"
Type: feature Change-Id: Ie020fd7e2618284a63efbeb9895068f27c0fb9ab Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/dlmalloc.c')
-rw-r--r--src/vppinfra/dlmalloc.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/vppinfra/dlmalloc.c b/src/vppinfra/dlmalloc.c
index 60bd8d55646..524c57b210b 100644
--- a/src/vppinfra/dlmalloc.c
+++ b/src/vppinfra/dlmalloc.c
@@ -4093,7 +4093,7 @@ void mspace_get_address_and_size (mspace msp, char **addrp, size_t *sizep)
{
mstate ms;
msegment *this_seg;
-
+
ms = (mstate)msp;
this_seg = &ms->seg;
@@ -4155,9 +4155,18 @@ int mspace_enable_disable_trace (mspace msp, int enable)
return (was_enabled);
}
-void* mspace_get_aligned (mspace msp,
+int mspace_is_traced (mspace msp)
+{
+ mstate ms = (mstate)msp;
+
+ if (use_trace(ms))
+ return 1;
+ return 0;
+}
+
+void* mspace_get_aligned (mspace msp,
unsigned long n_user_data_bytes,
- unsigned long align,
+ unsigned long align,
unsigned long align_offset) {
char *rv;
unsigned long searchp;
@@ -4165,13 +4174,13 @@ void* mspace_get_aligned (mspace msp,
mstate ms = (mstate)msp;
/*
- * Allocate space for the "Where's Waldo?" pointer
+ * Allocate space for the "Where's Waldo?" pointer
* the base of the dlmalloc object
*/
n_user_data_bytes += sizeof(unsigned);
- /*
- * Alignment requests less than the size of an mmx vector are ignored
+ /*
+ * Alignment requests less than the size of an mmx vector are ignored
*/
if (align < sizeof (uword)) {
rv = mspace_malloc (msp, n_user_data_bytes);
@@ -4181,7 +4190,7 @@ void* mspace_get_aligned (mspace msp,
if (use_trace(ms)) {
mchunkptr p = mem2chunk(rv);
size_t psize = chunksize(p);
-
+
mheap_get_trace ((unsigned long)rv + sizeof (unsigned), psize);
}
@@ -4196,15 +4205,15 @@ void* mspace_get_aligned (mspace msp,
* Alignment requests greater than 4K must be at offset zero,
* and must be freed using mspace_free_no_offset - or never freed -
* since the "Where's Waldo?" pointer would waste too much space.
- *
- * Waldo is the address of the chunk of memory returned by mspace_malloc,
+ *
+ * Waldo is the address of the chunk of memory returned by mspace_malloc,
* which we need later to call mspace_free...
*/
if (align > 4<<10 || align_offset == ~0UL) {
n_user_data_bytes -= sizeof(unsigned);
assert(align_offset == 0);
rv = internal_memalign(ms, (size_t)align, n_user_data_bytes);
-
+
/* Trace the allocation */
if (rv && use_trace(ms)) {
mchunkptr p = mem2chunk(rv);
al.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Copyright (c) 2017 Cisco Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

vppplugins_LTLIBRARIES += memif_plugin.la
vppapitestplugins_LTLIBRARIES += memif_test_plugin.la

memif_plugin_la_SOURCES = memif/memif.c   \
	memif/memif_api.c                 \
	memif/cli.c                       \
	memif/node.c                      \
	memif/device.c                    \
	memif/socket.c                    \
	memif/memif_plugin.api.h

memif_test_plugin_la_SOURCES = \
  memif/memif_test.c memif/memif_plugin.api.h

noinst_HEADERS += memif/memif.h

nobase_apiinclude_HEADERS +=              \
		  memif/memif_all_api_h.h \
		  memif/memif_msg_enum.h  \
		  memif/memif.api.h

API_FILES += memif/memif.api

# vi:syntax=automake