DPDK patches and discussions
 help / color / mirror / Atom feed
From: Robert Sanford <rsanford2@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 2/2] malloc: fix malloc and free linear complexity
Date: Mon, 23 Jun 2014 17:17:10 -0400	[thread overview]
Message-ID: <1403558230-40042-3-git-send-email-rsanford2@gmail.com> (raw)
In-Reply-To: <1400245141-10938-1-git-send-email-rsanford2@gmail.com>

Fix typos and false assumptions in malloc unit tests.

Without enhancements to lib rte_malloc, malloc autotest fails every
second (2nd) run. With enhancements, malloc autotest fails in
function test_multi_alloc_statistics, because we compare the wrong
sets of statistics.

Signed-off-by: Robert Sanford <rsanford2@gmail.com>

---
 app/test/test_malloc.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index 3c38383..bf27eff 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -66,7 +66,7 @@
  * ======
  *
  * Allocate some dynamic memory from heap (3 areas). Check that areas
- * don't overlap an that alignment constraints match. This test is
+ * don't overlap and that alignment constraints match. This test is
  * done many times on different lcores simultaneously.
  */
 
@@ -313,9 +313,9 @@ test_big_alloc(void)
 	rte_malloc_get_socket_stats(socket,&post_stats);
 
 	/* Check statistics reported are correct */
-	/* Allocation increase, cannot be the same as before big allocation */
-	if (post_stats.heap_totalsz_bytes == pre_stats.heap_totalsz_bytes) {
-		printf("Malloc statistics are incorrect - heap_totalz_bytes\n");
+	/* Allocation may increase, or may be the same as before big allocation */
+	if (post_stats.heap_totalsz_bytes < pre_stats.heap_totalsz_bytes) {
+		printf("Malloc statistics are incorrect - heap_totalsz_bytes\n");
 		return -1;
 	}
 	/* Check that allocated size adds up correctly */
@@ -336,7 +336,8 @@ test_big_alloc(void)
 		return -1;
 	}
 	/* New blocks now available - just allocated 1 but also 1 new free */
-	if(post_stats.free_count != pre_stats.free_count ) {
+	if (post_stats.free_count != pre_stats.free_count &&
+			post_stats.free_count != pre_stats.free_count - 1) {
 		printf("Malloc statistics are incorrect - free_count\n");
 		return -1;
 	}
@@ -425,7 +426,7 @@ test_multi_alloc_statistics(void)
 	}
 
 	/* Make sure that we didn't touch our greatest chunk: 2 * 11M)  */
-	if (second_stats.greatest_free_size != pre_stats.greatest_free_size) {
+	if (post_stats.greatest_free_size != pre_stats.greatest_free_size) {
 		printf("Incorrect heap statistics: Greatest free size \n");
 		return -1;
 	}
@@ -1036,11 +1037,11 @@ test_malloc(void)
 
 	ret = test_multi_alloc_statistics();
 	if (ret < 0) {
-		printf("test_muti_alloc_statistics() failed\n");
+		printf("test_multi_alloc_statistics() failed\n");
 		return ret;
 	}
 	else
-		printf("test_muti_alloc_statistics() passed\n");
+		printf("test_multi_alloc_statistics() passed\n");
 
 	return 0;
 }
-- 
1.7.1

      parent reply	other threads:[~2014-06-23 21:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 12:59 [dpdk-dev] [PATCH v2] " rsanford2
2014-06-17 16:05 ` De Lara Guarch, Pablo
2014-06-17 16:29   ` Robert Sanford
2014-06-23 21:17 ` [dpdk-dev] [PATCH v3 0/2] " Robert Sanford
2014-06-24 14:55   ` De Lara Guarch, Pablo
2014-06-26 12:37     ` Thomas Monjalon
2014-06-23 21:17 ` [dpdk-dev] [PATCH v3 1/2] " Robert Sanford
2014-06-23 21:17 ` Robert Sanford [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403558230-40042-3-git-send-email-rsanford2@gmail.com \
    --to=rsanford2@gmail.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).