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 1E648A0597; Wed, 8 Apr 2020 06:59:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 898F53195; Wed, 8 Apr 2020 06:59:43 +0200 (CEST) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30060.outbound.protection.outlook.com [40.107.3.60]) by dpdk.org (Postfix) with ESMTP id 4B0A52BE2 for ; Wed, 8 Apr 2020 06:59:42 +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=XlMiJcrV4XIG8H5AvxNhD3KvvjpTETP++B5dcN/gNTg=; b=4Pd+T8eq1uPa8g6rZy3WM+mogIwc3ONlP2RgF6zOY67Qqs0PoiM3x/yq+H83GKY0c51uJTYwChjBiGxnjX58ZRkn3pcz9wb399grVAbpILDJj1L6So2uE4QSjxbW7FbojWianvNprIHogflLEh6Je3k/oEtHt480tu8MRTVyDyM= Received: from DB6PR0801CA0062.eurprd08.prod.outlook.com (2603:10a6:4:2b::30) by DB8PR08MB4058.eurprd08.prod.outlook.com (2603:10a6:10:aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.16; Wed, 8 Apr 2020 04:59:40 +0000 Received: from DB5EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:2b:cafe::2c) by DB6PR0801CA0062.outlook.office365.com (2603:10a6:4:2b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.21 via Frontend Transport; Wed, 8 Apr 2020 04:59:40 +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 DB5EUR03FT006.mail.protection.outlook.com (10.152.20.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17 via Frontend Transport; Wed, 8 Apr 2020 04:59:40 +0000 Received: ("Tessian outbound 55454527ea3b:v50"); Wed, 08 Apr 2020 04:59:40 +0000 X-CR-MTA-TID: 64aa7808 Received: from f54830720c72.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 59C900FF-D17C-4D99-A99C-A55FD075AF48.1; Wed, 08 Apr 2020 04:59:35 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f54830720c72.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Apr 2020 04:59:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V5rlWbbNdeq9Y2UCfkiNCjMgqcgW0DrsY/zkHRQZBTE4ndZWaOKZDaBrGRsUSIYVPOIZIHSrGofW/0ZZnrV1TD1yUGerP3UYZ1vOO6i616dwhxrni/5IVgIR/XTga3aUKz10opZJ5WX9PeeYj83gtpytNR5d7pwn7MZ1uN6wKMO4/OgeHn/BxHp+RC4zZKhm4k6gvdlzXoaSkTAvdgZvl0+It0vnF50ycBJsxtb5VD0lQCTDuMfMP2E04QYv6hm26/XKA8VVLEQFG1gXEajIlTXHpOzzphHOd+pTnPmQ6dD5j+VZFR/1xX3vIW51mBzFhbJtFQozWqoaHiRY/PXHbQ== 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=XlMiJcrV4XIG8H5AvxNhD3KvvjpTETP++B5dcN/gNTg=; b=CVU3MmsyEkgi7mB5QCOfp8viAJnIiEaNMtWLOQ1zAVAnToWLKMa2JJ4jgrBp0oKJaXcIz7krpxtX4use7WNxSGhU0TtK4IuL6kTxT+IT/X7U6X8/6EVUuNQZTV6AyyW1cVRVd2UdPdKvJTjOT3sMCNDT795yHE3tiXGjSnCGEPHD9pY9V+x/lp+nxckYZpyrKjNeGdW9WHo9RMkM29LBCRymdvdCT8PaYr1wnG22AXULDbx7qjXpbDZEqUDBqCaNqmeyDX8lMJzdTD+/JjjP4g9hT7bQZ0XfCKOY2BO2z4LzOEPZCNlIO3f8pZhue0RPnZm2n7dJTyeH4M65hPe30w== 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=XlMiJcrV4XIG8H5AvxNhD3KvvjpTETP++B5dcN/gNTg=; b=4Pd+T8eq1uPa8g6rZy3WM+mogIwc3ONlP2RgF6zOY67Qqs0PoiM3x/yq+H83GKY0c51uJTYwChjBiGxnjX58ZRkn3pcz9wb399grVAbpILDJj1L6So2uE4QSjxbW7FbojWianvNprIHogflLEh6Je3k/oEtHt480tu8MRTVyDyM= Received: from DBBPR08MB4646.eurprd08.prod.outlook.com (10.255.79.144) by DBBPR08MB4838.eurprd08.prod.outlook.com (10.255.79.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.16; Wed, 8 Apr 2020 04:59:33 +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.2878.021; Wed, 8 Apr 2020 04:59:33 +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 v3 1/9] test/ring: add contention stress test Thread-Index: AQHWCd9R1w3FUy2800GE5i4fCZDVVqhsxRDQ Date: Wed, 8 Apr 2020 04:59:33 +0000 Message-ID: References: <20200402220959.29885-1-konstantin.ananyev@intel.com> <20200403174235.23308-1-konstantin.ananyev@intel.com> <20200403174235.23308-2-konstantin.ananyev@intel.com> In-Reply-To: <20200403174235.23308-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: 123b7e51-5211-4c88-8ba6-53e0c61da9b0.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: 4ba0e136-3bb3-4744-c347-08d7db79a56a x-ms-traffictypediagnostic: DBBPR08MB4838:|DBBPR08MB4838:|DB8PR08MB4058: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:800;OLM:800; x-forefront-prvs: 0367A50BB1 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)(346002)(39860400002)(136003)(376002)(366004)(396003)(86362001)(66476007)(66946007)(478600001)(8676002)(316002)(64756008)(66446008)(30864003)(7696005)(76116006)(186003)(66556008)(5660300002)(52536014)(9686003)(55016002)(71200400001)(4326008)(33656002)(81156014)(110136005)(8936002)(2906002)(54906003)(6506007)(26005)(81166007); 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: m4lNm+B0i+5O0JSGJFJOY7wZCmoy8JXCoF0XoC5SbGzES3mEHV+TDD9DFGFHPOq5NQn20/ZFCPTwgAGnpwocOZxw3/4oxw4YupnVEZuVKdSUs06F7Ua0/uRayt93AEykUVAwBDz+yR+UAumP+KNBzMHatE6AC+sWnpcSEfW4nLL2qG1286NpRk6U2I3xCOetjzq2rg9U2HoYkwgEx/sZOFhW3U7AmdivlGMmyVAVRYsqZ8QMHf/2XbIoLxkViJiJ8KUI+5cl5O7MiSbE4OTKdXRNdIokO8QOmV3j0QS29nPg0PHcKOgMPHJjWNLGNbnyE067QcRPtNC9/s9wZPFP6qK4s4lLd7asUpf0O2dgS6LO8T59qRh7jbsuqe2dGPY9lb44pVmaab1WGutFzSieQQCrpsruWEssrxSiu1PVHSBpHXcSxUAGD1G50L5s32iS x-ms-exchange-antispam-messagedata: FsZFXC235qNandC2oyB2cZapzykxNmudlM6VYyxCpWG2Kg9eCbh3H42yD+CuNgQiiLRgPQ0gNe2QnSZaVB7lO+dwJIj3Pr/R0Z7hfM14yWfl8KF1AUAqBiU9rNL8/lyVjELhSj0EYu4YyVuRzzN6GQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4838 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT006.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)(136003)(376002)(396003)(39850400004)(46966005)(33656002)(54906003)(6506007)(26826003)(7696005)(70206006)(8676002)(316002)(52536014)(82740400003)(81166007)(70586007)(47076004)(5660300002)(110136005)(81156014)(55016002)(4326008)(86362001)(9686003)(8936002)(26005)(186003)(478600001)(2906002)(356004)(30864003)(336012); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: f5e3914a-1204-4c9b-94c4-08d7db79a11c X-Forefront-PRVS: 0367A50BB1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 66/pVdD8GZZlzlZufsxS/DF3dP7iUW/9VY/WAY6Eg9XH2o2HaCmo2qUNpOYOscuoZKfWlU1OTSv7YEli0DmwgStG5bP0MjYxjqcvNYKeeuCqVt6XjSvsuexgH5o+zTwOpE+o3XSAmWtsBsTuo4LKzVHV9F/1bHEe8Ba9mXlS2pD28THnvL5tgEdi41RIkNvfI8++jaWcMU3U6AxCV3PSawt2XZVbn6e1bofYYXQjL8r3NsmLm+1aR6AcM8ycHlvAxiF8vB5h1/++wNrtl4pKm1G+d3K1MijfnoLbBNx8engJpvRcoqgArYqnDOuuwJZQgpYqi/N63o1/UZ2+C3GrWPNkeqXJ0O7WMnNUE07CrGyHrDr8C4dIozDmQ3RI8tVzIF+prnXWnCioNxqqyDqZUXctpTsUekLgaK1N25q3vCiidv6C2uXEJ3/JYKZk3UdJylcOEuteO+1SII3ObKk975zYGQAqZpGollZUHvl9UfhOoT03+LUDSBVM2ZLm9/o0DyJFPnesFG9hpRmIjn+IFw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2020 04:59:40.8907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ba0e136-3bb3-4744-c347-08d7db79a56a 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: DB8PR08MB4058 Subject: Re: [dpdk-dev] [PATCH v3 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" > Subject: [PATCH v3 1/9] test/ring: add contention stress test Minor, would 'add stress test for overcommitted use case' sound better? >=20 > Introduce new test-case to measure ring perfomance under contention Minor, 'over committed' seems to the word commonly used from the references= you provided. Does it make sense to use that? > (miltiple producers/consumers). ^^^^^^^ multiple > Starts dequeue/enqueue loop on all available slave lcores. >=20 > Signed-off-by: Konstantin Ananyev > --- > 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 | 444 +++++++++++++++++++++++++++++++ Would be good to change the file names to indicate that these tests are for= over-committed usecase/configuration. These are performance tests, better to have 'perf' or 'performance' in thei= r names. > 6 files changed, 562 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 > 1f080d162..4eefaa887 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 > 351d29cb6..827b04886 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..11476d28c > --- /dev/null > +++ b/app/test/test_ring_stress_impl.h > @@ -0,0 +1,444 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > +#include "test_ring_stress.h" > + > +/* > + * Measures performance of ring enqueue/dequeue under high contention > +*/ > + > +#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(lc=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, minor, lcore instead of lc would be better > + const char *fname, const char *opname) { > + if (exp !=3D res) { > + printf("%s(lc=3D%u) failure: %s expected: %u, returned %u\n", Suggest using lcore in the printf > + fname, lc, opname, exp, res); > + return -ENOSPC; > + } > + return 0; > +} > + > +static int > +test_worker_prcs(void *arg) > +{ > + int32_t rc; > + uint32_t lc, n, num; minor, lcore instead of lc would be better > + 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 rte_rdtsc_precise(); > + n =3D _st_ring_dequeue_bulk(la->rng, (void **)obj, num, NULL); > + tm0 =3D rte_rdtsc_precise() - tm0; > + > + /* check return value and objects */ > + rc =3D check_ring_op(num, n, lc, __func__, > + 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; Since this seems like a performance test, should we skip validating the obj= ects? Did these tests run on Travis CI? I believe Travis CI has trouble running s= tress/performance tests if they take too much time. The RTS and HTS tests should be added to functional tests. > + > + /* enqueue num elems */ > + rte_compiler_barrier(); > + rc =3D check_updt_elem(obj, num, &loc_elm, &def_elm); > + if (rc !=3D 0) > + break; > + > + tm1 =3D rte_rdtsc_precise(); > + n =3D _st_ring_enqueue_bulk(la->rng, (void **)obj, num, NULL); > + tm1 =3D rte_rdtsc_precise() - tm1; > + > + /* check return value */ > + rc =3D check_ring_op(num, n, lc, __func__, > + RTE_STR(_st_ring_enqueue_bulk)); > + if (rc !=3D 0) > + break; > + > + lcore_stat_update(&la->stats, 1, num, tm0 + tm1, 1); > + > + } while (wrk_cmd =3D=3D WRK_CMD_RUN); > + > + la->stats.nb_cycle =3D rte_rdtsc_precise() - cl; > + return rc; > +} > + > +static int > +test_worker_avg(void *arg) > +{ > + int32_t rc; > + uint32_t lc, n, num; > + uint64_t cl; > + 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 */ > + n =3D _st_ring_dequeue_bulk(la->rng, (void **)obj, num, NULL); > + > + /* check return value and objects */ > + rc =3D check_ring_op(num, n, lc, __func__, > + 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; > + > + n =3D _st_ring_enqueue_bulk(la->rng, (void **)obj, num, NULL); > + > + /* check return value */ > + rc =3D check_ring_op(num, n, lc, __func__, > + RTE_STR(_st_ring_enqueue_bulk)); > + if (rc !=3D 0) > + break; > + > + lcore_stat_update(&la->stats, 1, num, 0, 0); > + > + } while (wrk_cmd =3D=3D WRK_CMD_RUN); > + > + /* final stats update */ > + cl =3D rte_rdtsc_precise() - cl; > + lcore_stat_update(&la->stats, 0, 0, cl, 0); > + la->stats.nb_cycle =3D cl; > + > + return rc; > +} Just wondering about the need of 2 tests which run the same functionality. = The difference is the way in which numbers are collected.=20 Does 'test_worker_avg' adding any value? IMO, we can remove 'test_worker_av= g'. > + > +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