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 A6605A04E7; Mon, 2 Nov 2020 23:12:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 03FE9377E; Mon, 2 Nov 2020 23:12:12 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60069.outbound.protection.outlook.com [40.107.6.69]) by dpdk.org (Postfix) with ESMTP id 90E8D354D for ; Mon, 2 Nov 2020 23:12:09 +0100 (CET) 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=YH5+6ksN5ucOnb1FxxZd26flcHmR319BNrWwoLSd26A=; b=I42+fWvFYf0CeQ+bgyrXAqxY8wfdiwbe+1f+tPmyQcRpAUBQLHFsPD+6MGKSRQOrLEpXd8e37kgF+Ud8TLTfQUmJAiKbTKGoOVWxW+Jtavyyno9nFRKqJyD3aM+njn+8OvH4VtJS734jGfhDhBERNxcoL+RGZckAxy7GaLboeTA= Received: from AM5PR0402CA0016.eurprd04.prod.outlook.com (2603:10a6:203:90::26) by DB7PR08MB3724.eurprd08.prod.outlook.com (2603:10a6:10:30::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.29; Mon, 2 Nov 2020 22:12:07 +0000 Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::1f) by AM5PR0402CA0016.outlook.office365.com (2603:10a6:203:90::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.19 via Frontend Transport; Mon, 2 Nov 2020 22:12:06 +0000 X-MS-Exchange-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=pass 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 VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3520.15 via Frontend Transport; Mon, 2 Nov 2020 22:12:06 +0000 Received: ("Tessian outbound c189680f801b:v64"); Mon, 02 Nov 2020 22:12:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 15a30621609bdc29 X-CR-MTA-TID: 64aa7808 Received: from de59713f7515.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 749E995E-3910-4FD2-8CD9-A9DBD180B720.1; Mon, 02 Nov 2020 22:12:00 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id de59713f7515.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 02 Nov 2020 22:12:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJROkN/ghntJa2CgaJ997KX2ZevDDTe2+PUcgoH5d1a+GpLsgeEdwVYTxGs3iOANRUiPLSXZ0cZIgCLPGwYiczFyGFhoQELBSzLEkR8oJiarv/jz7vXFQq0xomuvHQsLBqU4eaU0kERoxeeQ4MfNTS6w5Y2AopuH28rzFHBL1rAuIfcObtMW7KZHU4G8kPw6URItlQ2nn9TIDv1wcpbkpcclsfI+pTI2KrcLX1PN+M7hXXG8G5UFrQLbNvCDEkLK5ypI5qXBYim0JmcU4893Oipp6BSJc29ZTlH9mMg9gUYgmCOx0lgO2xXvum/pVTBoSE2+dtlJXgHOGh3o2IbY1Q== 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=YH5+6ksN5ucOnb1FxxZd26flcHmR319BNrWwoLSd26A=; b=IH9+VhG+WhbYSGPWeInKuq7a7D/PvLCUdPDbT7ymWfihSH5Hyhf5MJU/m/6ROEvLQJ30IRFO2QC/wco4br43bdL/UiMwKOrsGEzOgVu+nBZVSp4NpVdjC2yNyfhwzaKR7CjrxVxFGSqaD13WVVJKnAy6kvIMZuvxK6+SwRhlVf+Rv1S9ZTZ65sMb96Rx/LuzbQMLtkD2LSTUN7LzRVcinVshOZgl8MbRC5LIzV3GtaOJt0yR+RSw6yD9PCPicnFp6TkGyc7pXD6QSQrMV9rsLxDiiA3hjqPNiwIW47pP692pzWSNvFbmtQLDSK7NwhNxAIXsA2hDUyiQvu71BWhDsA== 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=YH5+6ksN5ucOnb1FxxZd26flcHmR319BNrWwoLSd26A=; b=I42+fWvFYf0CeQ+bgyrXAqxY8wfdiwbe+1f+tPmyQcRpAUBQLHFsPD+6MGKSRQOrLEpXd8e37kgF+Ud8TLTfQUmJAiKbTKGoOVWxW+Jtavyyno9nFRKqJyD3aM+njn+8OvH4VtJS734jGfhDhBERNxcoL+RGZckAxy7GaLboeTA= Received: from VI1PR08MB4622.eurprd08.prod.outlook.com (2603:10a6:803:bc::17) by VI1PR08MB3312.eurprd08.prod.outlook.com (2603:10a6:803:46::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.22; Mon, 2 Nov 2020 22:11:57 +0000 Received: from VI1PR08MB4622.eurprd08.prod.outlook.com ([fe80::e9cc:b2a4:eb77:980b]) by VI1PR08MB4622.eurprd08.prod.outlook.com ([fe80::e9cc:b2a4:eb77:980b%7]) with mapi id 15.20.3499.030; Mon, 2 Nov 2020 22:11:57 +0000 From: Dharmik Thakkar To: "Medvedkin, Vladimir" CC: Bruce Richardson , "dev@dpdk.org" , nd Thread-Topic: [PATCH 4/4] test/lpm: avoid code duplication in rcu qsbr perf Thread-Index: AQHWrgljMK2CHNEqa0W9SDvRj4pGiKm1HBsAgABSK4A= Date: Mon, 2 Nov 2020 22:11:57 +0000 Message-ID: <374AEEB6-ADF8-4960-BB64-CBD6046F5379@arm.com> References: <20201029153634.10647-1-dharmik.thakkar@arm.com> <20201029153634.10647-4-dharmik.thakkar@arm.com> <60004746-5cdb-9f03-5392-ce43793280b6@intel.com> In-Reply-To: <60004746-5cdb-9f03-5392-ce43793280b6@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [72.182.82.154] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ae40099a-e14b-4b21-d437-08d87f7c55e3 x-ms-traffictypediagnostic: VI1PR08MB3312:|DB7PR08MB3724: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:989;OLM:989; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: JF/KBxZN0rTcQQMjHlld47D1qXoOzae2IDvGb6e7+xiw7F49NSMU3DumVw9pmjZ/RC++lI7XDyV5lzAypi2A0kyYqzou/i9CtL011WLHBTT92SlXoZiJDQsqFPADsSsHL+m/0NrKuBqszeULFsao69SCiquEr7v8h5PBLOBheOhdGpz6PnZwgTRPxbAD0453RefakDTnIuYx1y/WXzhxMeVMttOCDiz+kvE2hpuUbHz+zy7WmbeAFNDyUo97sDlW+VH0+k0EABO+Ejt2yLMhJuTca9DMSjui5LvEB95t+bWlV93RJ0xfr6vzKNi+PgW/ X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB4622.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(376002)(396003)(346002)(366004)(86362001)(53546011)(4326008)(186003)(6486002)(8676002)(316002)(71200400001)(6512007)(6506007)(6916009)(33656002)(8936002)(26005)(54906003)(36756003)(66946007)(2616005)(66476007)(2906002)(478600001)(83380400001)(5660300002)(30864003)(76116006)(91956017)(66556008)(64756008)(66446008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: cl/ZP5gKYXeThA1YDDSM+oOrr1pV12l3yClzcirbpZQNI2Y4/f7qO8vsMmfB8bfRvX+ATnXK0q4eksaaB9GlbkEsXf9a2TEkbM6XLGRo9lXi62rS3dWsy8P76KVI1tE9+Ro1zstK+lTZeQUVjd9y1uYfh9TZnA/1F/pUD3XYRXaf9Pes5JRKKlyuxxmpQtVv/oGD+J+iBzVb70FDagKjk2MWHCXhLdRiqD/ZylK/wJmDxccRKdpgVxJyFonG73XyMj7/u9Y4qQofnpDwcqX1q+Lxx6u8fdm8+l9FVxiPm1Sg/+PpW7jtSKWOXLt4YoWIdKmeIBjGgmjI4ozBwaxDn1a8X+1RNh5qdCq15pfgFm4v5RlIsnC4z7X1zC7OXhXV+qnbB+8ZrMQ0dzP9nKGMT9isLs+JdCAqJllJgDa3N5en2vQGK0wOWF93+ixoZwCohbvKpwXasmQlqwUIAmZGnjJnQiKU1h2H7OK1UxmBUMsCwKo73EsTGEqeITODS6Qre++6OKNQ0hdb/49UXEct+KTl6nH3atBAN6Ofw4QajE3BwmyzqhLJMPc05+N01qbnKum35f4ZYYC5YccHCq1sdDXp+Yjvyu1z+K9/qIVKMNJUkkbEczA2RgA2oAfh0tqbEwxQSDnQ8dwC/PbOyITWng== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3312 Original-Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 2cf970cb-be94-420a-7607-08d87f7c50a6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K2QMIqImwACnXmfoqJ9ZGZHTYVkaXrQ9X15b2422rze7OE7uyIrsHsaE3nIBjTrkvnOgQZdTlOejo2UqsY1NdbjCr3/6EOva/iPk3vxIm/zrBjMX1s4l3mcckqiKmr+MJszjXF+PGrBjz5TIT1WRTFv6a4Najo6VauKHD2ohoxUgmpr6Cf9AmopsWmJHLbg+KVrbRtP73KkUXszyh/PkTnGG1KDXAbP3f63rQJfemc5DeD9nCBhBZe/OnYcBZwsKKz2TGn9h6pDBHaqeJUP7tXHzuEPOpgF6ZMKGOq4ju4u/3GLYb5GiT3TRn0JZpSFfH23/ZqBndcev6QWVB5wjgwH1Y49Z1F6gPF1+yvQGF+ztjBrC4T3aqsLOs66BkEc/rkpaC7am2Va1+AsXppYnjA== 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; SFS:(4636009)(346002)(396003)(376002)(136003)(39860400002)(46966005)(2616005)(8676002)(336012)(8936002)(6862004)(186003)(6486002)(26005)(4326008)(86362001)(53546011)(6506007)(36756003)(30864003)(54906003)(5660300002)(70206006)(478600001)(70586007)(316002)(36906005)(82310400003)(47076004)(33656002)(82740400003)(6512007)(81166007)(2906002)(356005)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2020 22:12:06.5172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae40099a-e14b-4b21-d437-08d87f7c55e3 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-AuthSource: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3724 Subject: Re: [dpdk-dev] [PATCH 4/4] test/lpm: avoid code duplication in rcu qsbr perf 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" > On Nov 2, 2020, at 11:17 AM, Medvedkin, Vladimir wrote: >=20 > Hi Dharmik, >=20 > Thanks for the patches, see comments inlined >=20 >=20 > On 29/10/2020 15:36, Dharmik Thakkar wrote: >> Avoid code duplication by combining single and multi threaded tests >> Signed-off-by: Dharmik Thakkar >> Reviewed-by: Ruifeng Wang >> --- >> app/test/test_lpm_perf.c | 338 +++++++++------------------------------ >> 1 file changed, 73 insertions(+), 265 deletions(-) >> diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c >> index 4f15db4f85ee..08312023b661 100644 >> --- a/app/test/test_lpm_perf.c >> +++ b/app/test/test_lpm_perf.c >> @@ -430,11 +430,16 @@ test_lpm_rcu_qsbr_writer(void *arg) >> { >> unsigned int i, j, si, ei; >> uint64_t begin, total_cycles; >> - uint8_t core_id =3D (uint8_t)((uintptr_t)arg); >> + uint8_t writer_id =3D (uint8_t)((uintptr_t)arg); >> uint32_t next_hop_add =3D 0xAA; >> - /* 2 writer threads are used */ >> - if (core_id % 2 =3D=3D 0) { >> + /* Single writer (writer_id =3D 1) */ >> + if (writer_id =3D=3D 1) { >=20 > Probably it would be better to use enum here instead of 1/2/3? >=20 Yes, I will update the patch. >> + si =3D 0; >> + ei =3D NUM_LDEPTH_ROUTE_ENTRIES; >> + } >> + /* 2 Writers (writer_id =3D 2/3)*/ >> + else if (writer_id =3D=3D 2) { >> si =3D 0; >> ei =3D NUM_LDEPTH_ROUTE_ENTRIES / 2; >> } else { >> @@ -482,16 +487,17 @@ test_lpm_rcu_qsbr_writer(void *arg) >> /* >> * Functional test: >> - * 2 writers, rest are readers >> + * 1/2 writers, rest are readers >> */ >> static int >> -test_lpm_rcu_perf_multi_writer(void) >> +test_lpm_rcu_perf_multi_writer(uint8_t use_rcu) >> { >> struct rte_lpm_config config; >> size_t sz; >> - unsigned int i; >> + unsigned int i, j; >> uint16_t core_id; >> struct rte_lpm_rcu_config rcu_cfg =3D {0}; >> + int (*reader_f)(void *arg) =3D NULL; >> if (rte_lcore_count() < 3) { >> printf("Not enough cores for lpm_rcu_perf_autotest, expecting at leas= t 3\n"); >> @@ -504,273 +510,76 @@ test_lpm_rcu_perf_multi_writer(void) >> num_cores++; >> } >> - printf("\nPerf test: 2 writers, %d readers, RCU integration enabled\n= ", >> - num_cores - 2); >> - >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> - >> - /* Init RCU variable */ >> - sz =3D rte_rcu_qsbr_get_memsize(num_cores); >> - rv =3D (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz, >> - RTE_CACHE_LINE_SIZE); >> - rte_rcu_qsbr_init(rv, num_cores); >> - >> - rcu_cfg.v =3D rv; >> - /* Assign the RCU variable to LPM */ >> - if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) !=3D 0) { >> - printf("RCU variable assignment failed\n"); >> - goto error; >> - } >> - >> - writer_done =3D 0; >> - __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); >> - >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - >> - /* Launch reader threads */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL, >> - enabled_core_ids[i]); >> - >> - /* Launch writer threads */ >> - for (i =3D 0; i < 2; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, >> - (void *)(uintptr_t)i, >> - enabled_core_ids[i]); >> - >> - /* Wait for writer threads */ >> - for (i =3D 0; i < 2; i++) >> - if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) >> - goto error; >> - >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %"PRIu64" cycles\n", >> - __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) / TOTAL_WRITES >> - ); >> - >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_wait_lcore(enabled_core_ids[i]); >> - >> - rte_lpm_free(lpm); >> - rte_free(rv); >> - lpm =3D NULL; >> - rv =3D NULL; >> - >> - /* Test without RCU integration */ >> - printf("\nPerf test: 2 writers, %d readers, RCU integration disabled\n= ", >> - num_cores - 2); >> - >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> - >> - writer_done =3D 0; >> - __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - >> - /* Launch reader threads */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_reader, NULL, >> - enabled_core_ids[i]); >> - >> - /* Launch writer threads */ >> - for (i =3D 0; i < 2; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, >> - (void *)(uintptr_t)i, >> - enabled_core_ids[i]); >> - >> - /* Wait for writer threads */ >> - for (i =3D 0; i < 2; i++) >> - if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) >> - goto error; >> - >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %"PRIu64" cycles\n", >> - __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) >> - / TOTAL_WRITES); >> - >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_wait_lcore(enabled_core_ids[i]); >> - >> - rte_lpm_free(lpm); >> - >> - return 0; >> - >> -error: >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - rte_eal_mp_wait_lcore(); >> - >> - rte_lpm_free(lpm); >> - rte_free(rv); >> - >> - return -1; >> -} >> - >> -/* >> - * Functional test: >> - * Single writer, rest are readers >> - */ >> -static int >> -test_lpm_rcu_perf(void) >> -{ >> - struct rte_lpm_config config; >> - uint64_t begin, total_cycles; >> - size_t sz; >> - unsigned int i, j; >> - uint16_t core_id; >> - uint32_t next_hop_add =3D 0xAA; >> - struct rte_lpm_rcu_config rcu_cfg =3D {0}; >> - >> - if (rte_lcore_count() < 2) { >> - printf("Not enough cores for lpm_rcu_perf_autotest, expecting at leas= t 2\n"); >> - return TEST_SKIPPED; >> - } >> - >> - num_cores =3D 0; >> - RTE_LCORE_FOREACH_WORKER(core_id) { >> - enabled_core_ids[num_cores] =3D core_id; >> - num_cores++; >> - } >> - >> - printf("\nPerf test: 1 writer, %d readers, RCU integration enabled\n", >> - num_cores); >> - >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> - >> - /* Init RCU variable */ >> - sz =3D rte_rcu_qsbr_get_memsize(num_cores); >> - rv =3D (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz, >> - RTE_CACHE_LINE_SIZE); >> - rte_rcu_qsbr_init(rv, num_cores); >> - >> - rcu_cfg.v =3D rv; >> - /* Assign the RCU variable to LPM */ >> - if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) !=3D 0) { >> - printf("RCU variable assignment failed\n"); >> - goto error; >> - } >> - >> - writer_done =3D 0; >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - >> - /* Launch reader threads */ >> - for (i =3D 0; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL, >> - enabled_core_ids[i]); >> - >> - /* Measure add/delete. */ >> - begin =3D rte_rdtsc_precise(); >> - for (i =3D 0; i < RCU_ITERATIONS; i++) { >> - /* Add all the entries */ >> - for (j =3D 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++) >> - if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip, >> - large_ldepth_route_table[j].depth, >> - next_hop_add) !=3D 0) { >> - printf("Failed to add iteration %d, route# %d\n", >> - i, j); >> + for (j =3D 1; j < 3; j++) { >> + if (use_rcu) >> + printf("\nPerf test: %d writer(s), %d reader(s)," >> + " RCU integration enabled\n", j, num_cores - j); >> + else >> + printf("\nPerf test: %d writer(s), %d reader(s)," >> + " RCU integration disabled\n", j, num_cores - j); >> + >> + /* Create LPM table */ >> + config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> + config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> + config.flags =3D 0; >> + lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> + TEST_LPM_ASSERT(lpm !=3D NULL); >> + >> + /* Init RCU variable */ >> + if (use_rcu) { >> + sz =3D rte_rcu_qsbr_get_memsize(num_cores); >> + rv =3D (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz, >> + RTE_CACHE_LINE_SIZE); >> + rte_rcu_qsbr_init(rv, num_cores); >> + >> + rcu_cfg.v =3D rv; >> + /* Assign the RCU variable to LPM */ >> + if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) !=3D 0) { >> + printf("RCU variable assignment failed\n"); >> goto error; >> } >> - /* Delete all the entries */ >> - for (j =3D 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++) >> - if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip, >> - large_ldepth_route_table[j].depth) !=3D 0) { >> - printf("Failed to delete iteration %d, route# %d\n", >> - i, j); >> - goto error; >> - } >> - } >> - total_cycles =3D rte_rdtsc_precise() - begin; >> + reader_f =3D test_lpm_rcu_qsbr_reader; >> + } else >> + reader_f =3D test_lpm_reader; >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %g cycles\n", >> - (double)total_cycles / TOTAL_WRITES); >> + writer_done =3D 0; >> + __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 0; i < num_cores; i++) >> - if (rte_eal_wait_lcore(enabled_core_ids[i]); >> + __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - rte_lpm_free(lpm); >> - rte_free(rv); >> - lpm =3D NULL; >> - rv =3D NULL; >> + /* Launch reader threads */ >> + for (i =3D j; i < num_cores; i++) >> + rte_eal_remote_launch(reader_f, NULL, >> + enabled_core_ids[i]); >> - /* Test without RCU integration */ >> - printf("\nPerf test: 1 writer, %d readers, RCU integration disabled\n"= , >> - num_cores); >> + /* Launch writer threads */ >> + for (i =3D 0; i < j; i++) >> + rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, >=20 > So now even single writer will acquire a lock for every _add/_delete oper= ation. I don't think it is necessary. Yes, agreed it is not necessary. I wanted to avoid additional if () stateme= nt, but I can add it in the new version. >=20 >> + (void *)(uintptr_t)(i + j), >> + enabled_core_ids[i]); >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> - >> - writer_done =3D 0; >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - >> - /* Launch reader threads */ >> - for (i =3D 0; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_reader, NULL, >> - enabled_core_ids[i]); >> - >> - /* Measure add/delete. */ >> - begin =3D rte_rdtsc_precise(); >> - for (i =3D 0; i < RCU_ITERATIONS; i++) { >> - /* Add all the entries */ >> - for (j =3D 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++) >> - if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip, >> - large_ldepth_route_table[j].depth, >> - next_hop_add) !=3D 0) { >> - printf("Failed to add iteration %d, route# %d\n", >> - i, j); >> + /* Wait for writer threads */ >> + for (i =3D 0; i < j; i++) >> + if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) >> goto error; >> - } >> - /* Delete all the entries */ >> - for (j =3D 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++) >> - if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip, >> - large_ldepth_route_table[j].depth) !=3D 0) { >> - printf("Failed to delete iteration %d, route# %d\n", >> - i, j); >> - goto error; >> - } >> + printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> + printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> + printf("Average LPM Add/Del: %"PRIu64" cycles\n", >> + __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) >> + / TOTAL_WRITES); >> + >> + writer_done =3D 1; >> + /* Wait until all readers have exited */ >> + for (i =3D j; i < num_cores; i++) >> + rte_eal_wait_lcore(enabled_core_ids[i]); >> + >> + rte_lpm_free(lpm); >> + rte_free(rv); >> + lpm =3D NULL; >> + rv =3D NULL; >> } >> - total_cycles =3D rte_rdtsc_precise() - begin; >> - >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %g cycles\n", >> - (double)total_cycles / TOTAL_WRITES); >> - >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 0; i < num_cores; i++) >> - rte_eal_wait_lcore(enabled_core_ids[i]); >> - >> - rte_lpm_free(lpm); >> return 0; >> @@ -946,9 +755,8 @@ test_lpm_perf(void) >> rte_lpm_delete_all(lpm); >> rte_lpm_free(lpm); >> - test_lpm_rcu_perf(); >> - >> - test_lpm_rcu_perf_multi_writer(); >> + test_lpm_rcu_perf_multi_writer(0); >> + test_lpm_rcu_perf_multi_writer(1); >> return 0; >> } >=20 > --=20 > Regards, > Vladimir