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 DB809A0521; Tue, 3 Nov 2020 15:52:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C0373CB2E; Tue, 3 Nov 2020 15:52:08 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2052.outbound.protection.outlook.com [40.107.22.52]) by dpdk.org (Postfix) with ESMTP id 0FCE5CB04 for ; Tue, 3 Nov 2020 15:52:07 +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=PQrEM6YqlePG6idZrnMZ/awmWXEs9AabmypN5qYHtGM=; b=2akZEN8anztOBvMkjLND/qSmGoUyMaxLlcU0YcowZs8O1XZp5tUn5tUOT+aUT27UXGFqQy7Ry4bfcJgMVOWdStAcnRFsS9SfxoURTKIvD+dDD91dbQcJ5hfmAxPfGS7wTiHjFieWWVB5Bep48KVPH4lcqp3of3tsTKC6iL4onNc= Received: from MR2P264CA0188.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::27) by DBBPR08MB4839.eurprd08.prod.outlook.com (2603:10a6:10:da::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.29; Tue, 3 Nov 2020 14:52:04 +0000 Received: from VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:501:0:cafe::ba) by MR2P264CA0188.outlook.office365.com (2603:10a6:501::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Tue, 3 Nov 2020 14:52:03 +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 VE1EUR03FT031.mail.protection.outlook.com (10.152.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3520.15 via Frontend Transport; Tue, 3 Nov 2020 14:52:02 +0000 Received: ("Tessian outbound a64c3afb6fc9:v64"); Tue, 03 Nov 2020 14:52:00 +0000 X-CR-MTA-TID: 64aa7808 Received: from 315443279353.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1E119DF7-0E9D-4A27-89E9-4BF663F0C7CB.1; Tue, 03 Nov 2020 14:51:55 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 315443279353.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Nov 2020 14:51:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mNBqXmG4VAU4oo9xh6fw9iZ37TZcvSM1HtdMBIrJDqx49DVjDNCyJSZ3P+bqJcr1nYPTX+DZsL9rK8qYOEpQ4sZeUfrnZs//+dZ7IrHsXoSRAN6izyZ/nnEuDMVbBTb3ayJaXcesGMh/X3vP67uvkpiFaUhTnq42lPgrpDFS/Yr1Xd2IJvjqOLJcZBP5z2w2zcwxhFpz8Pf7YPRnTV6idXlOWAv1LLu/vnTahnhevSJVHqj74As47oy7M/YIvkC6Bai5MtbmYXHapz5r+69A2B5hdKFqzD+DhtbC4QHzKxqy3FMok84N3ZUbNx3TaQt0evXCbSmE6ixMf6GMvIW0GQ== 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=PQrEM6YqlePG6idZrnMZ/awmWXEs9AabmypN5qYHtGM=; b=PLzA2+QmG2K8Mr3BmhPJG1DVNS+eYVIv1So8OFCEoLRxoefq0HdVGdmhU8gHDiX+PmRTUJLAm5n3eJs5ySFcw+WDNU6I4JftWVWw0B7DS0JQnB1IBtFzPeyJUfMvT+Oht0tYp9lO5M9WXufhheY7gO36gKftUvJCXNIid0HDiM3VJ7klFclIEaDVob6Ygs2rF9BJVdIUtDg+Q1etphfSLPjDJlS0hZnZPnWmDyL/MNGwrfuwzaak1NKpRArImCGK+ZGJMWebroedgbdi6wfpHlGowZMm358m/dIt4jsVyJTtORvtrK8oXelcrKaBrry1t1YOnirGsjjNIcDorHDaQQ== 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=PQrEM6YqlePG6idZrnMZ/awmWXEs9AabmypN5qYHtGM=; b=2akZEN8anztOBvMkjLND/qSmGoUyMaxLlcU0YcowZs8O1XZp5tUn5tUOT+aUT27UXGFqQy7Ry4bfcJgMVOWdStAcnRFsS9SfxoURTKIvD+dDD91dbQcJ5hfmAxPfGS7wTiHjFieWWVB5Bep48KVPH4lcqp3of3tsTKC6iL4onNc= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DB7PR08MB4585.eurprd08.prod.outlook.com (2603:10a6:10:7b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 3 Nov 2020 14:51:53 +0000 Received: from DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::7814:9c1:781f:475d]) by DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::7814:9c1:781f:475d%4]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 14:51:53 +0000 From: Honnappa Nagarahalli To: Dharmik Thakkar CC: Bruce Richardson , Vladimir Medvedkin , "dev@dpdk.org" , nd , Honnappa Nagarahalli , nd Thread-Topic: [dpdk-dev] [PATCH v2 4/4] test/lpm: avoid code duplication in rcu qsbr perf Thread-Index: AQHWsXOe/GYRfGhBrk+npnXu35aBe6m1ynWwgAAHkgCAAA3XkIAAkVmAgAANPLA= Date: Tue, 3 Nov 2020 14:51:53 +0000 Message-ID: References: <20201029153634.10647-1-dharmik.thakkar@arm.com> <20201102235203.6342-1-dharmik.thakkar@arm.com> <20201102235203.6342-5-dharmik.thakkar@arm.com> <9B5688D2-D668-4EE4-9ECF-150BDEF5A292@arm.com> <73640BD5-01D1-4DE3-B0E8-5A3404734DD3@arm.com> In-Reply-To: <73640BD5-01D1-4DE3-B0E8-5A3404734DD3@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 14509E9512196440A336A8637C0CB798.0 x-checkrecipientchecked: true Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [217.140.110.7] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7cf604b0-724c-43ee-95cc-08d8800806a9 x-ms-traffictypediagnostic: DB7PR08MB4585:|DBBPR08MB4839: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2000;OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: rc9BDESTZ3SBQZj8XsNhIPbqNlIubQbI1G2BhhpVXgt64xdpHMDG2TkCFSXqt3lRNnQjjsMNHeC9IePcM7igfSCaPcmJRMIzs79HNHF8Nbjs8Wuu/NrwjCg+KHvB/r8IN4dAwaXeKDfYahy92Rpbzy0v5vrNqDPD8S2+i8iVnG6UFfl4fyz5UpPvMCed4uLdN/rM0QVBVY6HvkAKWWF/b3gJ8GEZwVTZxEqFRrdx2VBwF+IuqogCJwkRgZsUitviVwIvsFjFUyuG8Cuqs13fA1ZI2BQ01Ae0bEENMubEjROFRIGeSeZKMiNJoDBknZFfEaH+IRMMLI6lbk6z/EsSIw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBAPR08MB5814.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(136003)(396003)(39860400002)(6636002)(6862004)(7696005)(186003)(5660300002)(66946007)(26005)(33656002)(86362001)(478600001)(76116006)(71200400001)(2906002)(316002)(54906003)(9686003)(55016002)(30864003)(66476007)(8936002)(83380400001)(66446008)(66556008)(6506007)(52536014)(4326008)(64756008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: F9gSRHDNoGUFUVDgIm1UzQVQ2cXnaL+pZjE+ek4ksR7L4/xgizkwHkJfX/dQ7QcLLpg2kslJmjvZ3ZQliKYF5PGgRVCTCBVTDlNl6GXiATB16JvI6PbjFFhsVeUShBALIe32mNQ2sGMht9kR9l8jaO2VCOHcn+gw2N3NvFEAOPfIWSfIKFf2zNjin4jpbPy6Zfq4ZR3iydwNSxBgOfQvxGdnbR4d77iImQZCcpHAocp+2iD7VkK0tZCd9PuptyIjJ3D/bQkEWZS2XEO7h+/cfMG0nAkH6qBAatoPpwuAwh4yXI38ebPsTlWAscY916lVm+kzk10RCq75BTE4L8V/yUDpD5St/3gdh6txX3U7jSNrpXgCQnOA92BBn5nhPXvgl4E01im4qH5UhRRndKFwbD7rsosR3sDnP1Xv8eQC0Hpira4P0pZgITS7g0MGWqhQZz/9czGX4f3nu7xUX9L3dW6EWDrEKAUnO0gfJpGlIIBiuFUWD8CXGm0agJa5S0m/4wnvZ/I97aKQ1xy2UwZ9gbZlOuHOEIT1y0UUdQSFZUpwah3DJavqYQ2loXRbQ/jWfs36sYsNGHOU26A7OyrruUFYiZNIEyun/XyFWP4YA3HRwSMQO6PiHnLo1+bPmU516hI/HZgUFCRV3nAJo7umYg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB4585 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7a0addee-ebed-4092-314d-08d8800800fa X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2jPlMe45qw35gWnwWAtF+tmUljMPQdTb9Avb7avHU6YWsbvk+PqfDpBi0JaebOpOvOGtd91VGWbhKHknYB3Kd8Nfgggdasb/kYlRbcUL/yvKyMQNFtAzXWCvN8ZYYEIC0hyNws9G8cQrUBNNjQrj4pibAks6YYAlLxK+sV05a3tprSJzSG4iep+ElKdATLmC5N1RW21ind8jusUwPxr6AYjE0abfFw8PIFzEh+OmgJClyDGP5LH4odlJVyLiDN6VrEagY55jOQV9+stPTDZSnBy41ND44ocNY1CaBtR5QMQ6GHJCoG4yxdOMbVClH/E7MSUNjIoi9wmhzSPWgemyXt47wLeWB/qkOfBgm+hvWikYGzh8+Z+uvUQI2bKv1hk8FrT2v7/TYb7beD2m6y1BKw== 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)(396003)(346002)(39860400002)(136003)(376002)(46966005)(70586007)(47076004)(478600001)(70206006)(52536014)(86362001)(2906002)(54906003)(83380400001)(8936002)(33656002)(81166007)(336012)(26005)(186003)(5660300002)(30864003)(82740400003)(6636002)(4326008)(6506007)(55016002)(356005)(6862004)(316002)(7696005)(9686003)(36906005)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 14:52:02.0053 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cf604b0-724c-43ee-95cc-08d8800806a9 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: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4839 Subject: Re: [dpdk-dev] [PATCH v2 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" > >>>> > >>>> 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 | 362 > >>>> ++++++++++----------------------------- > >>>> 1 file changed, 91 insertions(+), 271 deletions(-) > >>>> > >>>> diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c > >>>> index > >>>> 224c92fa3d65..229c835c23f7 100644 > >>>> --- a/app/test/test_lpm_perf.c > >>>> +++ b/app/test/test_lpm_perf.c > >>>> @@ -67,6 +67,12 @@ enum { > >>>> IP_CLASS_C > >>>> }; > >>>> > >>>> +enum { > >>>> +SINGLE_WRITER =3D 1, > >>>> +MULTI_WRITER_1, > >>>> +MULTI_WRITER_2 > >>>> +}; > >>> Do we need this? Can we use the number of cores instead? > >>> > >> > >> There are 3 combinations of writes (adds/deletes): > >> 1. Write all the entries - in case of a single writer 2. Write half > >> of the entries - in case of multiple writers 3. Write remaining half > >> of the entries - in case of multiple writers > >> > >> So, I think this is required. > > IMO, this is not scalable. Essentially, we need 2 parameters to divide = the > routes among each writer thread. We need 2 parameters, 1) total number of > writers 2) the core ID in the linear space. > > Creating a structure with these 2 and passing that to the writer thread > would be better and scalable. >=20 > Yes, agreed this is only applicable for 2 writers. Currently, the multi w= riter > test is only limited to a maximum of 2 writers. > To support more number of writers, we need something like this (which I > believe is in lines with your suggestion): > 1. Calculate what each writer will write: single_insert =3D TOTAL_WRITES = / > num_writers 2. Pass core ID in linear space as an argument to the writer > function: pos_core 3. Calculate si and ei in the writer function: si =3D = pos_core * > single_insert; ei =3D si + single_insert >=20 > I can update the patch to enable more than 2 writers. > Do you also suggest we expand the scope of the test to test with more tha= n > 2 writers? > This will increase the time for which the test is running (which currentl= y is > significant even with 2 writers). Agree, no to increasing the number of writers. Yes for making the code more= generic. >=20 > > > >> > >>>> + > >>>> /* struct route_rule_count defines the total number of rules in > >>>> following a/b/c > >>>> * each item in a[]/b[]/c[] is the number of common IP address class > >>>> A/B/C, not > >>>> * including the ones for private local network. > >>>> @@ -430,11 +436,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 > >>>> +SINGLE_WRITER) { si =3D 0; ei =3D NUM_LDEPTH_ROUTE_ENTRIES; } > >>>> +/* 2 Writers (writer_id =3D 2/3)*/ > >>>> +else if (writer_id =3D=3D MULTI_WRITER_1) { > >>>> si =3D 0; > >>>> ei =3D NUM_LDEPTH_ROUTE_ENTRIES / 2; > >>>> } else { > >>>> @@ -447,29 +458,35 @@ test_lpm_rcu_qsbr_writer(void *arg) for (i =3D > >>>> 0; i < RCU_ITERATIONS; i++) { > >>>> /* Add all the entries */ > >>>> for (j =3D si; j < ei; j++) { > >>>> -pthread_mutex_lock(&lpm_mutex); > >>>> +if (writer_id !=3D SINGLE_WRITER) > >>>> +pthread_mutex_lock(&lpm_mutex); > >>>> 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); > >>>> -pthread_mutex_unlock(&lpm_mutex); > >>>> +if (writer_id !=3D SINGLE_WRITER) > >>>> + > >>>> pthread_mutex_unlock(&lpm_mutex); > >>>> return -1; > >>>> } > >>>> -pthread_mutex_unlock(&lpm_mutex); > >>>> +if (writer_id !=3D SINGLE_WRITER) > >>>> +pthread_mutex_unlock(&lpm_mutex); > >>>> } > >>>> > >>>> /* Delete all the entries */ > >>>> for (j =3D si; j < ei; j++) { > >>>> -pthread_mutex_lock(&lpm_mutex); > >>>> +if (writer_id !=3D SINGLE_WRITER) > >>>> +pthread_mutex_lock(&lpm_mutex); > >>>> if (rte_lpm_delete(lpm, > >>>> large_ldepth_route_table[j].ip, > >>>> large_ldepth_route_table[j].depth) !=3D 0) { printf("Failed to delet= e > >>>> iteration %d, route# %d\n", i, j); > >>>> -pthread_mutex_unlock(&lpm_mutex); > >>>> +if (writer_id !=3D SINGLE_WRITER) > >>>> + > >>>> pthread_mutex_unlock(&lpm_mutex); > >>>> return -1; > >>>> } > >>>> -pthread_mutex_unlock(&lpm_mutex); > >>>> +if (writer_id !=3D SINGLE_WRITER) > >>>> +pthread_mutex_unlock(&lpm_mutex); > >>>> } > >>>> } > >>>> > >>>> @@ -482,16 +499,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 > >>>> least 3\n"); @@ -504,273 +522,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 > >>>> least 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]); > >>>> - > >>>> -rte_lpm_free(lpm); > >>>> -rte_free(rv); > >>>> -lpm =3D NULL; > >>>> -rv =3D NULL; > >>>> - > >>>> -/* Test without RCU integration */ -printf("\nPerf test: 1 writer, > >>>> %d readers, RCU integration disabled\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); > >>>> +__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); > >>>> > >>>> -writer_done =3D 0; > >>>> -__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); > >>>> +/* Launch reader threads */ > >>>> +for (i =3D j; i < num_cores; i++) > >>>> +rte_eal_remote_launch(reader_f, NULL, enabled_core_ids[i]); > >>>> > >>>> -/* Launch reader threads */ > >>>> -for (i =3D 0; i < num_cores; i++) > >>>> -rte_eal_remote_launch(test_lpm_reader, NULL, > >>>> -enabled_core_ids[i]); > >>>> +/* Launch writer threads */ > >>>> +for (i =3D 0; i < j; i++) > >>>> +rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, > >>>> +(void *)(uintptr_t)(i + j), > >>> This can be just 'j'? > >>> > >>>> +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 +767,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; > >>>> } > >>>> -- > >>>> 2.17.1 >=20