From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8414FA0561; Sun, 19 Apr 2020 04:31:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C59731D418; Sun, 19 Apr 2020 04:31:03 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by dpdk.org (Postfix) with ESMTP id 14D321D154 for ; Sun, 19 Apr 2020 04:31:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1BiEjd+ZGbJ4ARIBXMbp2EKqW1KerfjM8N6excGgnP4=; b=p65sPlg68aGOGZ73AVsQWAPs+kqYx1FJIAZ+YHRcwB2dQPVnc3pT5OJrqrmO8mdSNADnlPw3w5CdGgBi9SIlIUmWe3fJPtrXnRR2DANGUSSiOIrtZdsvB10OMFcsnOk3ahmdo5MrR1LnJl8cX1LeQI10HG7VpzVH3m/7dzcexIY= Received: from DB6PR07CA0103.eurprd07.prod.outlook.com (2603:10a6:6:2c::17) by DB7PR08MB4587.eurprd08.prod.outlook.com (2603:10a6:10:30::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Sun, 19 Apr 2020 02:31:01 +0000 Received: from DB5EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::d9) by DB6PR07CA0103.outlook.office365.com (2603:10a6:6:2c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.6 via Frontend Transport; Sun, 19 Apr 2020 02:31:01 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT064.mail.protection.outlook.com (10.152.21.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.18 via Frontend Transport; Sun, 19 Apr 2020 02:31:01 +0000 Received: ("Tessian outbound ecb846ece464:v53"); Sun, 19 Apr 2020 02:31:01 +0000 X-CR-MTA-TID: 64aa7808 Received: from f53175870bc8.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D28FB1CC-A740-4C6F-B4EF-476DFBC92F25.1; Sun, 19 Apr 2020 02:30:56 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f53175870bc8.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 19 Apr 2020 02:30:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hIT2/oGSCvCZcDKQsvU6AxMLeHTuBiNda5to9obAxtV0M+/IBlJm32L/btOhhk8iQQbfEz3BrzIlN8MmqWLQB9ZP6AoJbyLY8hSihI+M6FjIMWqf9JQSV1kaRMLsZAfz0XxiccG+Id5yqY8JQkvCS2A1BJ2GlzMMCa9wyVJ5S7zrn2FRFUgJUg2VtjLA0YXkcNy4fbUFlxuXdLBglc26hRqBXub8LqYUDSnpU/7ZgbT07fS4rmrfXJqYxThdYU3JJ5WTQpMa4Ev5W78g4V2fPmE1ON9icPKdlHB720SKqVAZpRGsjOpI0JhfU/v+zhY46fZxUjKaHHkP0aMCSWxBJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1BiEjd+ZGbJ4ARIBXMbp2EKqW1KerfjM8N6excGgnP4=; b=Bdu9rC0BddIHb/fAJAHZG092oSV3kzq6WHMf9E4psJu5HjvWaAXNkT4KQTQ4UZxQpyniZkvqPDNSnQMcPW02L130sewPD+v17DzZfQpXrAFnu2L8Y1Hgaban2VP72/nNSUQrzIRJ/ge7WSjGK69ViqD94cVdmmLKMq0NvMVVduv52XjZOEvMacmXF6eeqjq6JpmkIfJYJgHorWecs5Uab9KpzzZIMGiUdmL8Vm7mlQ92wX0CxUdF1bqxFjjmn28Kf+0cgjLZimb/dKAFgx/zJgoSnkM8vkbQrwCj4xfPKBoOepfx0RnKjXqPzVEpGa3Szk5z8Jd23TW5sCVGLMKUUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1BiEjd+ZGbJ4ARIBXMbp2EKqW1KerfjM8N6excGgnP4=; b=p65sPlg68aGOGZ73AVsQWAPs+kqYx1FJIAZ+YHRcwB2dQPVnc3pT5OJrqrmO8mdSNADnlPw3w5CdGgBi9SIlIUmWe3fJPtrXnRR2DANGUSSiOIrtZdsvB10OMFcsnOk3ahmdo5MrR1LnJl8cX1LeQI10HG7VpzVH3m/7dzcexIY= Received: from DBBPR08MB4646.eurprd08.prod.outlook.com (2603:10a6:10:f5::16) by DBBPR08MB4902.eurprd08.prod.outlook.com (2603:10a6:10:db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Sun, 19 Apr 2020 02:30:54 +0000 Received: from DBBPR08MB4646.eurprd08.prod.outlook.com ([fe80::1870:afc4:b90f:609d]) by DBBPR08MB4646.eurprd08.prod.outlook.com ([fe80::1870:afc4:b90f:609d%5]) with mapi id 15.20.2921.027; Sun, 19 Apr 2020 02:30:54 +0000 From: Honnappa Nagarahalli To: Konstantin Ananyev , "dev@dpdk.org" CC: "david.marchand@redhat.com" , "jielong.zjl@antfin.com" , nd , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v5 1/9] test/ring: add contention stress test Thread-Index: AQHWFZ7/sjGw8YP/QUWhJRSnP48lMah/QSnA Date: Sun, 19 Apr 2020 02:30:54 +0000 Message-ID: References: <20200417133639.14019-1-konstantin.ananyev@intel.com> <20200418163225.17635-1-konstantin.ananyev@intel.com> <20200418163225.17635-2-konstantin.ananyev@intel.com> In-Reply-To: <20200418163225.17635-2-konstantin.ananyev@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 750045c8-1840-4496-af7f-dde65a2cf6b2.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [70.113.25.165] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ca62a0f9-2ffe-4316-cf88-08d7e409b3a2 x-ms-traffictypediagnostic: DBBPR08MB4902:|DBBPR08MB4902:|DB7PR08MB4587: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:480;OLM:480; x-forefront-prvs: 0378F1E47A X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB4646.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(136003)(376002)(396003)(366004)(346002)(39850400004)(316002)(9686003)(66556008)(66446008)(64756008)(66476007)(66946007)(76116006)(26005)(186003)(52536014)(478600001)(966005)(6506007)(7696005)(54906003)(110136005)(81156014)(8676002)(33656002)(8936002)(5660300002)(30864003)(71200400001)(55016002)(4326008)(2906002)(86362001); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: YT4+Yc/u/pn43SUZy97zHALihm/LKH++TKdLjlg/0kHemp5TazeF92rTaRyri9Q5aANgtie0UPv0fxtnql92d1LLmFCpentZRYHmHsWD4URNlLVV5awT9XelHFZellrjfO8Vcn6Yl0JRRzRSk9wYiz3kkIyLZAV4m8YW5nqAtrWLy9zRPQ52hdpcuxt+0jlAG2ET3I8i+bhSix85GMaLJnjR4K/1pmxIw63+DAnm6HVw8q7d8zKxVQLOdAuZEc6wfxk/u9gBEbhMjGDFNtVLjF+O8weUzwBuY3lM3+KY4KiB48BNO0IS03SKuqIYIO3wA+sLIB76rYbp3FSP76nsKsSwjKDaZsRwTo1Mflp3IFS3O3GVUvqyT09SpA3ifOMBcU6zrJoGMHQU3eCZ4Q/JtPaEbPnb7YymW08IUpzzkFRZrKH9nkQCQG9R40zC4YWYO9MQep0fuNItkg+YMA9G0jHZcAUu79ZUFZ1kWHPNRyuMiJbOXN4hXKs1Shw2N/+sN3FZxak+84pi9T2NijHU1A== x-ms-exchange-antispam-messagedata: x5ptmuWHJxwqKP5LfEBmCCUxhMvZeXY0PAp5VlVp2js1ulwFZOF0jATSSRk8LHRStBkkyg1QFs42mdOjHenmi5GWQD/GO+IAchEyBIJ4aGGEBxmayzHhnaQinO/Py/5SCEjlAgVFXeSpAu4Mo1Lm2Q== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4902 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(346002)(376002)(136003)(39850400004)(396003)(46966005)(52536014)(966005)(8676002)(81156014)(8936002)(33656002)(7696005)(2906002)(5660300002)(70206006)(81166007)(6506007)(356005)(70586007)(26005)(110136005)(336012)(55016002)(9686003)(86362001)(82740400003)(478600001)(186003)(30864003)(54906003)(316002)(47076004)(4326008); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: aee075b2-67ba-48fa-d5ce-08d7e409af89 X-Forefront-PRVS: 0378F1E47A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RmYZCM3+Cdm0A2ZhAJyxxS0upcl1NI5Qi/Yy4Bnc1A+rRT3U/5J8DeHOBLREitlkzcNGO9I/lGytDvLYnGH8U89QGSeznP8u39nmEqDEppegJlajOOBMIe9zX5hwurL6JRPlUvhnMSRCjoEv4Aw1B+BmN8xKYWhKYM1b5w8dh7aeMNBBwZ0hLnfQXtveuMiYdehhZw6oL/O3SQWzADdDsOJjhXaV2stWaKd7q8dwwrRbki4gnKT6JSuufY6nQP40jyWc08AEWNpPI9akM/QTYIxXoEsHVdCvHO5Bx3DNaHkwjnUG/3/Z3c+DkZojXc5ZgOkgSdYJ7smJa6bQSH2GmJiwRebBw8hM5HgMYGQOs9t1GZWK/O4CdJzC4UiYKs2uGWIeajzF1cO/32SLit+KadRiINub2Rabbdo3uPdlIi/kFOS8x5tRRa5jk3TiXKMJqe0B678uEeKgTVNvQ7rSoyZpfPsHECC6YyLS2sC50NXsDGtatvzzuvRwHVkJE0DuK4hHm4DI7bWQYWhe1Pnc7b3ULpFf7MEDz9azY+mG+zfqv5psSojK/RRckNU2MXWz25i/3jGiaHhhLb2Tjamg6P9OmaXCxH8FoSwJbiX4hmg= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2020 02:31:01.5774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca62a0f9-2ffe-4316-cf88-08d7e409b3a2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB4587 Subject: Re: [dpdk-dev] [PATCH v5 1/9] test/ring: add contention stress test 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" >=20 > Introduce stress test for ring enqueue/dequeue operations. > Performs the following pattern on each slave worker: > dequeue/read-write data from the dequeued objects/enqueue. > Serves as both functional and performance test of ring enqueue/dequeue > operations under high contention (for both over committed and non-over > committed scenarios). >=20 > Signed-off-by: Konstantin Ananyev ci/intel-compilation fails for meson due to clang+32b. I believe it is solv= ed by [1] (as you indicated). Can you make this patch dependent on [1]? Otherwise, Acked-by: Honnappa Nagarahalli [1] http://patches.dpdk.org/patch/68280/ > --- > app/test/Makefile | 2 + > app/test/meson.build | 2 + > app/test/test_ring_mpmc_stress.c | 31 +++ > app/test/test_ring_stress.c | 48 ++++ > app/test/test_ring_stress.h | 35 +++ > app/test/test_ring_stress_impl.h | 396 +++++++++++++++++++++++++++++++ > 6 files changed, 514 insertions(+) > create mode 100644 app/test/test_ring_mpmc_stress.c create mode 100644 > app/test/test_ring_stress.c create mode 100644 app/test/test_ring_stress= .h > create mode 100644 app/test/test_ring_stress_impl.h >=20 > diff --git a/app/test/Makefile b/app/test/Makefile index > be53d33c3..a23a011df 100644 > --- a/app/test/Makefile > +++ b/app/test/Makefile > @@ -77,7 +77,9 @@ SRCS-y +=3D test_external_mem.c SRCS-y +=3D > test_rand_perf.c >=20 > SRCS-y +=3D test_ring.c > +SRCS-y +=3D test_ring_mpmc_stress.c > SRCS-y +=3D test_ring_perf.c > +SRCS-y +=3D test_ring_stress.c > SRCS-y +=3D test_pmd_perf.c >=20 > ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y) > diff --git a/app/test/meson.build b/app/test/meson.build index > 04b59cffa..8824f366c 100644 > --- a/app/test/meson.build > +++ b/app/test/meson.build > @@ -100,7 +100,9 @@ test_sources =3D files('commands.c', > 'test_rib.c', > 'test_rib6.c', > 'test_ring.c', > + 'test_ring_mpmc_stress.c', > 'test_ring_perf.c', > + 'test_ring_stress.c', > 'test_rwlock.c', > 'test_sched.c', > 'test_service_cores.c', > diff --git a/app/test/test_ring_mpmc_stress.c > b/app/test/test_ring_mpmc_stress.c > new file mode 100644 > index 000000000..1524b0248 > --- /dev/null > +++ b/app/test/test_ring_mpmc_stress.c > @@ -0,0 +1,31 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > +#include "test_ring_stress_impl.h" > + > +static inline uint32_t > +_st_ring_dequeue_bulk(struct rte_ring *r, void **obj, uint32_t n, > + uint32_t *avail) > +{ > + return rte_ring_mc_dequeue_bulk(r, obj, n, avail); } > + > +static inline uint32_t > +_st_ring_enqueue_bulk(struct rte_ring *r, void * const *obj, uint32_t n, > + uint32_t *free) > +{ > + return rte_ring_mp_enqueue_bulk(r, obj, n, free); } > + > +static int > +_st_ring_init(struct rte_ring *r, const char *name, uint32_t num) { > + return rte_ring_init(r, name, num, 0); } > + > +const struct test test_ring_mpmc_stress =3D { > + .name =3D "MP/MC", > + .nb_case =3D RTE_DIM(tests), > + .cases =3D tests, > +}; > diff --git a/app/test/test_ring_stress.c b/app/test/test_ring_stress.c ne= w file > mode 100644 index 000000000..60706f799 > --- /dev/null > +++ b/app/test/test_ring_stress.c > @@ -0,0 +1,48 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > +#include "test_ring_stress.h" > + > +static int > +run_test(const struct test *test) > +{ > + int32_t rc; > + uint32_t i, k; > + > + for (i =3D 0, k =3D 0; i !=3D test->nb_case; i++) { > + > + printf("TEST-CASE %s %s START\n", > + test->name, test->cases[i].name); > + > + rc =3D test->cases[i].func(test->cases[i].wfunc); > + k +=3D (rc =3D=3D 0); > + > + if (rc !=3D 0) > + printf("TEST-CASE %s %s FAILED\n", > + test->name, test->cases[i].name); > + else > + printf("TEST-CASE %s %s OK\n", > + test->name, test->cases[i].name); > + } > + > + return k; > +} > + > +static int > +test_ring_stress(void) > +{ > + uint32_t n, k; > + > + n =3D 0; > + k =3D 0; > + > + n +=3D test_ring_mpmc_stress.nb_case; > + k +=3D run_test(&test_ring_mpmc_stress); > + > + printf("Number of tests:\t%u\nSuccess:\t%u\nFailed:\t%u\n", > + n, k, n - k); > + return (k !=3D n); > +} > + > +REGISTER_TEST_COMMAND(ring_stress_autotest, test_ring_stress); > diff --git a/app/test/test_ring_stress.h b/app/test/test_ring_stress.h ne= w file > mode 100644 index 000000000..60eac6216 > --- /dev/null > +++ b/app/test/test_ring_stress.h > @@ -0,0 +1,35 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "test.h" > + > +struct test_case { > + const char *name; > + int (*func)(int (*)(void *)); > + int (*wfunc)(void *arg); > +}; > + > +struct test { > + const char *name; > + uint32_t nb_case; > + const struct test_case *cases; > +}; > + > +extern const struct test test_ring_mpmc_stress; > diff --git a/app/test/test_ring_stress_impl.h > b/app/test/test_ring_stress_impl.h > new file mode 100644 > index 000000000..222d62bc4 > --- /dev/null > +++ b/app/test/test_ring_stress_impl.h > @@ -0,0 +1,396 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > +#include "test_ring_stress.h" > + > +/** > + * Stress test for ring enqueue/dequeue operations. > + * Performs the following pattern on each slave worker: > + * dequeue/read-write data from the dequeued objects/enqueue. > + * Serves as both functional and performance test of ring > + * enqueue/dequeue operations under high contention > + * (for both over committed and non-over committed scenarios). > + */ > + > +#define RING_NAME "RING_STRESS" > +#define BULK_NUM 32 > +#define RING_SIZE (2 * BULK_NUM * RTE_MAX_LCORE) > + > +enum { > + WRK_CMD_STOP, > + WRK_CMD_RUN, > +}; > + > +static volatile uint32_t wrk_cmd __rte_cache_aligned; > + > +/* test run-time in seconds */ > +static const uint32_t run_time =3D 60; > +static const uint32_t verbose; > + > +struct lcore_stat { > + uint64_t nb_cycle; > + struct { > + uint64_t nb_call; > + uint64_t nb_obj; > + uint64_t nb_cycle; > + uint64_t max_cycle; > + uint64_t min_cycle; > + } op; > +}; > + > +struct lcore_arg { > + struct rte_ring *rng; > + struct lcore_stat stats; > +} __rte_cache_aligned; > + > +struct ring_elem { > + uint32_t cnt[RTE_CACHE_LINE_SIZE / sizeof(uint32_t)]; } > +__rte_cache_aligned; > + > +/* > + * redefinable functions > + */ > +static uint32_t > +_st_ring_dequeue_bulk(struct rte_ring *r, void **obj, uint32_t n, > + uint32_t *avail); > + > +static uint32_t > +_st_ring_enqueue_bulk(struct rte_ring *r, void * const *obj, uint32_t n, > + uint32_t *free); > + > +static int > +_st_ring_init(struct rte_ring *r, const char *name, uint32_t num); > + > + > +static void > +lcore_stat_update(struct lcore_stat *ls, uint64_t call, uint64_t obj, > + uint64_t tm, int32_t prcs) > +{ > + ls->op.nb_call +=3D call; > + ls->op.nb_obj +=3D obj; > + ls->op.nb_cycle +=3D tm; > + if (prcs) { > + ls->op.max_cycle =3D RTE_MAX(ls->op.max_cycle, tm); > + ls->op.min_cycle =3D RTE_MIN(ls->op.min_cycle, tm); > + } > +} > + > +static void > +lcore_op_stat_aggr(struct lcore_stat *ms, const struct lcore_stat *ls) > +{ > + > + ms->op.nb_call +=3D ls->op.nb_call; > + ms->op.nb_obj +=3D ls->op.nb_obj; > + ms->op.nb_cycle +=3D ls->op.nb_cycle; > + ms->op.max_cycle =3D RTE_MAX(ms->op.max_cycle, ls->op.max_cycle); > + ms->op.min_cycle =3D RTE_MIN(ms->op.min_cycle, ls->op.min_cycle); } > + > +static void > +lcore_stat_aggr(struct lcore_stat *ms, const struct lcore_stat *ls) { > + ms->nb_cycle =3D RTE_MAX(ms->nb_cycle, ls->nb_cycle); > + lcore_op_stat_aggr(ms, ls); > +} > + > +static void > +lcore_stat_dump(FILE *f, uint32_t lc, const struct lcore_stat *ls) { > + long double st; > + > + st =3D (long double)rte_get_timer_hz() / US_PER_S; > + > + if (lc =3D=3D UINT32_MAX) > + fprintf(f, "%s(AGGREGATE)=3D{\n", __func__); > + else > + fprintf(f, "%s(lcore=3D%u)=3D{\n", __func__, lc); > + > + fprintf(f, "\tnb_cycle=3D%" PRIu64 "(%.2Lf usec),\n", > + ls->nb_cycle, (long double)ls->nb_cycle / st); > + > + fprintf(f, "\tDEQ+ENQ=3D{\n"); > + > + fprintf(f, "\t\tnb_call=3D%" PRIu64 ",\n", ls->op.nb_call); > + fprintf(f, "\t\tnb_obj=3D%" PRIu64 ",\n", ls->op.nb_obj); > + fprintf(f, "\t\tnb_cycle=3D%" PRIu64 ",\n", ls->op.nb_cycle); > + fprintf(f, "\t\tobj/call(avg): %.2Lf\n", > + (long double)ls->op.nb_obj / ls->op.nb_call); > + fprintf(f, "\t\tcycles/obj(avg): %.2Lf\n", > + (long double)ls->op.nb_cycle / ls->op.nb_obj); > + fprintf(f, "\t\tcycles/call(avg): %.2Lf\n", > + (long double)ls->op.nb_cycle / ls->op.nb_call); > + > + /* if min/max cycles per call stats was collected */ > + if (ls->op.min_cycle !=3D UINT64_MAX) { > + fprintf(f, "\t\tmax cycles/call=3D%" PRIu64 "(%.2Lf usec),\n", > + ls->op.max_cycle, > + (long double)ls->op.max_cycle / st); > + fprintf(f, "\t\tmin cycles/call=3D%" PRIu64 "(%.2Lf usec),\n", > + ls->op.min_cycle, > + (long double)ls->op.min_cycle / st); > + } > + > + fprintf(f, "\t},\n"); > + fprintf(f, "};\n"); > +} > + > +static void > +fill_ring_elm(struct ring_elem *elm, uint32_t fill) { > + uint32_t i; > + > + for (i =3D 0; i !=3D RTE_DIM(elm->cnt); i++) > + elm->cnt[i] =3D fill; > +} > + > +static int32_t > +check_updt_elem(struct ring_elem *elm[], uint32_t num, > + const struct ring_elem *check, const struct ring_elem *fill) { > + uint32_t i; > + > + static rte_spinlock_t dump_lock; > + > + for (i =3D 0; i !=3D num; i++) { > + if (memcmp(check, elm[i], sizeof(*check)) !=3D 0) { > + rte_spinlock_lock(&dump_lock); > + printf("%s(lc=3D%u, num=3D%u) failed at %u-th iter, " > + "offending object: %p\n", > + __func__, rte_lcore_id(), num, i, elm[i]); > + rte_memdump(stdout, "expected", check, > sizeof(*check)); > + rte_memdump(stdout, "result", elm[i], sizeof(elm[i])); > + rte_spinlock_unlock(&dump_lock); > + return -EINVAL; > + } > + memcpy(elm[i], fill, sizeof(*elm[i])); > + } > + > + return 0; > +} > + > +static int > +check_ring_op(uint32_t exp, uint32_t res, uint32_t lc, > + const char *fname, const char *opname) { > + if (exp !=3D res) { > + printf("%s(lc=3D%u) failure: %s expected: %u, returned %u\n", > + fname, lc, opname, exp, res); > + return -ENOSPC; > + } > + return 0; > +} > + > +static int > +test_worker(void *arg, const char *fname, int32_t prcs) { > + int32_t rc; > + uint32_t lc, n, num; > + uint64_t cl, tm0, tm1; > + struct lcore_arg *la; > + struct ring_elem def_elm, loc_elm; > + struct ring_elem *obj[2 * BULK_NUM]; > + > + la =3D arg; > + lc =3D rte_lcore_id(); > + > + fill_ring_elm(&def_elm, UINT32_MAX); > + fill_ring_elm(&loc_elm, lc); > + > + while (wrk_cmd !=3D WRK_CMD_RUN) { > + rte_smp_rmb(); > + rte_pause(); > + } > + > + cl =3D rte_rdtsc_precise(); > + > + do { > + /* num in interval [7/8, 11/8] of BULK_NUM */ > + num =3D 7 * BULK_NUM / 8 + rte_rand() % (BULK_NUM / 2); > + > + /* reset all pointer values */ > + memset(obj, 0, sizeof(obj)); > + > + /* dequeue num elems */ > + tm0 =3D (prcs !=3D 0) ? rte_rdtsc_precise() : 0; > + n =3D _st_ring_dequeue_bulk(la->rng, (void **)obj, num, NULL); > + tm0 =3D (prcs !=3D 0) ? rte_rdtsc_precise() - tm0 : 0; > + > + /* check return value and objects */ > + rc =3D check_ring_op(num, n, lc, fname, > + RTE_STR(_st_ring_dequeue_bulk)); > + if (rc =3D=3D 0) > + rc =3D check_updt_elem(obj, num, &def_elm, &loc_elm); > + if (rc !=3D 0) > + break; > + > + /* enqueue num elems */ > + rte_compiler_barrier(); > + rc =3D check_updt_elem(obj, num, &loc_elm, &def_elm); > + if (rc !=3D 0) > + break; > + > + tm1 =3D (prcs !=3D 0) ? rte_rdtsc_precise() : 0; > + n =3D _st_ring_enqueue_bulk(la->rng, (void **)obj, num, NULL); > + tm1 =3D (prcs !=3D 0) ? rte_rdtsc_precise() - tm1 : 0; > + > + /* check return value */ > + rc =3D check_ring_op(num, n, lc, fname, > + RTE_STR(_st_ring_enqueue_bulk)); > + if (rc !=3D 0) > + break; > + > + lcore_stat_update(&la->stats, 1, num, tm0 + tm1, prcs); > + > + } while (wrk_cmd =3D=3D WRK_CMD_RUN); > + > + cl =3D rte_rdtsc_precise() - cl; > + if (prcs =3D=3D 0) > + lcore_stat_update(&la->stats, 0, 0, cl, 0); > + la->stats.nb_cycle =3D cl; > + return rc; > +} > +static int > +test_worker_prcs(void *arg) > +{ > + return test_worker(arg, __func__, 1); > +} > + > +static int > +test_worker_avg(void *arg) > +{ > + return test_worker(arg, __func__, 0); > +} > + > +static void > +mt1_fini(struct rte_ring *rng, void *data) { > + rte_free(rng); > + rte_free(data); > +} > + > +static int > +mt1_init(struct rte_ring **rng, void **data, uint32_t num) { > + int32_t rc; > + size_t sz; > + uint32_t i, nr; > + struct rte_ring *r; > + struct ring_elem *elm; > + void *p; > + > + *rng =3D NULL; > + *data =3D NULL; > + > + sz =3D num * sizeof(*elm); > + elm =3D rte_zmalloc(NULL, sz, __alignof__(*elm)); > + if (elm =3D=3D NULL) { > + printf("%s: alloc(%zu) for %u elems data failed", > + __func__, sz, num); > + return -ENOMEM; > + } > + > + *data =3D elm; > + > + /* alloc ring */ > + nr =3D 2 * num; > + sz =3D rte_ring_get_memsize(nr); > + r =3D rte_zmalloc(NULL, sz, __alignof__(*r)); > + if (r =3D=3D NULL) { > + printf("%s: alloc(%zu) for FIFO with %u elems failed", > + __func__, sz, nr); > + return -ENOMEM; > + } > + > + *rng =3D r; > + > + rc =3D _st_ring_init(r, RING_NAME, nr); > + if (rc !=3D 0) { > + printf("%s: _st_ring_init(%p, %u) failed, error: %d(%s)\n", > + __func__, r, nr, rc, strerror(-rc)); > + return rc; > + } > + > + for (i =3D 0; i !=3D num; i++) { > + fill_ring_elm(elm + i, UINT32_MAX); > + p =3D elm + i; > + if (_st_ring_enqueue_bulk(r, &p, 1, NULL) !=3D 1) > + break; > + } > + > + if (i !=3D num) { > + printf("%s: _st_ring_enqueue(%p, %u) returned %u\n", > + __func__, r, num, i); > + return -ENOSPC; > + } > + > + return 0; > +} > + > +static int > +test_mt1(int (*test)(void *)) > +{ > + int32_t rc; > + uint32_t lc, mc; > + struct rte_ring *r; > + void *data; > + struct lcore_arg arg[RTE_MAX_LCORE]; > + > + static const struct lcore_stat init_stat =3D { > + .op.min_cycle =3D UINT64_MAX, > + }; > + > + rc =3D mt1_init(&r, &data, RING_SIZE); > + if (rc !=3D 0) { > + mt1_fini(r, data); > + return rc; > + } > + > + memset(arg, 0, sizeof(arg)); > + > + /* launch on all slaves */ > + RTE_LCORE_FOREACH_SLAVE(lc) { > + arg[lc].rng =3D r; > + arg[lc].stats =3D init_stat; > + rte_eal_remote_launch(test, &arg[lc], lc); > + } > + > + /* signal worker to start test */ > + wrk_cmd =3D WRK_CMD_RUN; > + rte_smp_wmb(); > + > + usleep(run_time * US_PER_S); > + > + /* signal worker to start test */ > + wrk_cmd =3D WRK_CMD_STOP; > + rte_smp_wmb(); > + > + /* wait for slaves and collect stats. */ > + mc =3D rte_lcore_id(); > + arg[mc].stats =3D init_stat; > + > + rc =3D 0; > + RTE_LCORE_FOREACH_SLAVE(lc) { > + rc |=3D rte_eal_wait_lcore(lc); > + lcore_stat_aggr(&arg[mc].stats, &arg[lc].stats); > + if (verbose !=3D 0) > + lcore_stat_dump(stdout, lc, &arg[lc].stats); > + } > + > + lcore_stat_dump(stdout, UINT32_MAX, &arg[mc].stats); > + mt1_fini(r, data); > + return rc; > +} > + > +static const struct test_case tests[] =3D { > + { > + .name =3D "MT-WRK_ENQ_DEQ-MST_NONE-PRCS", > + .func =3D test_mt1, > + .wfunc =3D test_worker_prcs, > + }, > + { > + .name =3D "MT-WRK_ENQ_DEQ-MST_NONE-AVG", > + .func =3D test_mt1, > + .wfunc =3D test_worker_avg, > + }, > +}; > -- > 2.17.1