From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 2EE4B7E74 for ; Fri, 17 Oct 2014 15:10:17 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 17 Oct 2014 06:08:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,739,1406617200"; d="scan'208";a="607002618" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 17 Oct 2014 06:18:14 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s9HDIDPk017958; Fri, 17 Oct 2014 14:18:13 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s9HDIDxg012609; Fri, 17 Oct 2014 14:18:13 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s9HDIC4j012605; Fri, 17 Oct 2014 14:18:12 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Fri, 17 Oct 2014 14:18:12 +0100 Message-Id: <1413551892-12573-1-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] test: fbk hash - fix errors with large nb entries X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2014 13:10:18 -0000 The four-byte-key (fbk) autotest was allocating the keys to be used for the test on the stack. When the number of entries in the table was increased significantly, for example, to test larger hashes by increase the value of ENTRIES, this array of keys was greater than that allowed on the stack, and so caused problems, i.e. crashes and core dumps. The solution is to have the keys dynamically allocated on the heap using malloc. Now if ENTRIES is increased and we run out of memory we get an error message instead of a crash. Signed-off-by: Bruce Richardson --- app/test/test_hash_perf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index 7bb7016..be34957 100644 --- a/app/test/test_hash_perf.c +++ b/app/test/test_hash_perf.c @@ -397,6 +397,7 @@ struct tbl_perf_test_params tbl_perf_params[] = if (cond) { \ printf("ERROR line %d: " str "\n", __LINE__, ##__VA_ARGS__); \ if (handle) rte_fbk_hash_free(handle); \ + if (keys) rte_free(keys); \ return -1; \ } \ } while(0) @@ -697,8 +698,8 @@ fbk_hash_perf_test(void) .entries_per_bucket = 4, .socket_id = rte_socket_id(), }; - struct rte_fbk_hash_table *handle; - uint32_t keys[ENTRIES] = {0}; + struct rte_fbk_hash_table *handle = NULL; + uint32_t *keys = NULL; unsigned indexes[TEST_SIZE]; uint64_t lookup_time = 0; unsigned added = 0; @@ -708,6 +709,10 @@ fbk_hash_perf_test(void) handle = rte_fbk_hash_create(¶ms); RETURN_IF_ERROR_FBK(handle == NULL, "fbk hash creation failed"); + keys = rte_zmalloc(NULL, ENTRIES * sizeof(*keys), 0); + RETURN_IF_ERROR_FBK(keys == NULL, + "fbk hash: memory allocation for key store failed"); + /* Generate random keys and values. */ for (i = 0; i < ENTRIES; i++) { uint32_t key = (uint32_t)rte_rand(); -- 1.9.3