aboutsummaryrefslogtreecommitdiff
path: root/tests/malloc_manysmall.c
diff options
context:
space:
mode:
authorJan Stancek <jstancek@redhat.com>2012-09-06 13:12:22 +0200
committerEric B Munson <emunson@mgebm.net>2012-09-06 21:39:54 -0400
commitcdd2fa336d9980eb268a775b7cf9c49e3b698cd7 (patch)
tree8f69b8e28775f59644fd7e6083c735fc4f563358 /tests/malloc_manysmall.c
parent97a6efd9d0c660d4bdabdb579635c46c3f20e156 (diff)
downloadlibhugetlbfs-cdd2fa336d9980eb268a775b7cf9c49e3b698cd7.tar.gz
exhaust malloc arenas before malloc tests
First allocation in malloc tests is just 1024 bytes. If there is enough free mem in malloc arenas, this first allocation can be satisfied without call to MORECORE() and testcase will fail. LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes malloc (2M: 64): FAIL Address is not hugepage When looking at output from HUGETLB_DEBUG=1 it appears that hook to __morecore doesn't work as there is no trace from hugetlbfs_morecore. This patch will keep malloc-ing 1-byte chunks of memory as long as it comes from '[heap]' or maximum is reached. This will force glibc to call MORECORE() before actual malloc/malloc_manysmall test begins. Signed-off-by: Jan Stancek <jstancek@redhat.com> Signed-off-by: Eric B Munson <emunson@mgebm.net>
Diffstat (limited to 'tests/malloc_manysmall.c')
-rw-r--r--tests/malloc_manysmall.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/malloc_manysmall.c b/tests/malloc_manysmall.c
index 25086a8..15cf4f0 100644
--- a/tests/malloc_manysmall.c
+++ b/tests/malloc_manysmall.c
@@ -50,6 +50,9 @@ int main(int argc, char *argv[])
if (env)
expect_hugepage = 1;
+ if (expect_hugepage)
+ consume_heap(1024*1024);
+
for (i = 0; i < NUM_ALLOCS; i++) {
p = malloc(ALLOC_SIZE);
if (! p)