From patchwork Wed Oct 23 18:54:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 61790 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ABE631D415; Wed, 23 Oct 2019 20:55:16 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id CB3381D40C for ; Wed, 23 Oct 2019 20:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571856911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1wPcidAhtRIC13CYsfRReaLfwRDSJAbR5jTManN0dLk=; b=Im8zqGVNK5NwO1xI7zZbFa3UsFIKgdy3Ex9htynotVcEnrlEJ5jpe8SePT/To2X4dVJ2FP 8z7GH0DNDas6fvAUULYUHmwg0Hyb2c5hXZ0OK+S/Qy+9gvHWG35NCuKLYQ0VFYtGnzzNI2 etgPB2hnT2pSaX1mltNafCqBnyVSWN0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-rFCcsthOObimLXYK8zsIuQ-1; Wed, 23 Oct 2019 14:55:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C6EA80183E; Wed, 23 Oct 2019 18:55:06 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-129.brq.redhat.com [10.40.204.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id B917E60872; Wed, 23 Oct 2019 18:55:04 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stephen@networkplumber.org, anatoly.burakov@intel.com, thomas@monjalon.net Date: Wed, 23 Oct 2019 20:54:21 +0200 Message-Id: <1571856864-8779-10-git-send-email-david.marchand@redhat.com> In-Reply-To: <1571856864-8779-1-git-send-email-david.marchand@redhat.com> References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> <1571856864-8779-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: rFCcsthOObimLXYK8zsIuQ-1 X-Mimecast-Spam-Score: 0 Subject: [dpdk-dev] [PATCH v2 09/12] test/mem: remove dependency on EAL internals X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Rather than dereference the mem_config internal structure, we can rely on the rte_memzone_walk API and count memzones. Signed-off-by: David Marchand --- app/test/test_memzone.c | 50 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c index 7edfd06..4d87444 100644 --- a/app/test/test_memzone.c +++ b/app/test/test_memzone.c @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include #include "../../lib/librte_eal/common/malloc_elem.h" -#include "../../lib/librte_eal/common/eal_memcfg.h" #include "test.h" @@ -927,6 +927,16 @@ test_memzone_free(void) return 0; } +static int test_memzones_left; +static int memzone_walk_cnt; +static void memzone_walk_clb(const struct rte_memzone *mz, + void *arg __rte_unused) +{ + memzone_walk_cnt++; + if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE)) + test_memzones_left++; +} + static int test_memzone_basic(void) { @@ -936,8 +946,12 @@ test_memzone_basic(void) const struct rte_memzone *memzone4; const struct rte_memzone *mz; int memzone_cnt_after, memzone_cnt_expected; - int memzone_cnt_before = - rte_eal_get_configuration()->mem_config->memzones.count; + int memzone_cnt_before; + + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt_before = memzone_walk_cnt; memzone1 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100, SOCKET_ID_ANY, 0); @@ -960,8 +974,10 @@ test_memzone_basic(void) (memzone1 != NULL) + (memzone2 != NULL) + (memzone3 != NULL) + (memzone4 != NULL); - memzone_cnt_after = - rte_eal_get_configuration()->mem_config->memzones.count; + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt_after = memzone_walk_cnt; if (memzone_cnt_after != memzone_cnt_expected) return -1; @@ -1039,30 +1055,26 @@ test_memzone_basic(void) return -1; } - memzone_cnt_after = - rte_eal_get_configuration()->mem_config->memzones.count; + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt_after = memzone_walk_cnt; if (memzone_cnt_after != memzone_cnt_before) return -1; return 0; } -static int test_memzones_left; -static int memzone_walk_cnt; -static void memzone_walk_clb(const struct rte_memzone *mz, - void *arg __rte_unused) -{ - memzone_walk_cnt++; - if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE)) - test_memzones_left++; -} - static int test_memzone(void) { /* take note of how many memzones were allocated before running */ - int memzone_cnt = - rte_eal_get_configuration()->mem_config->memzones.count; + int memzone_cnt; + + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt = memzone_walk_cnt; printf("test basic memzone API\n"); if (test_memzone_basic() < 0)