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 74285A0521; Tue, 3 Nov 2020 15:04:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1693FCACC; Tue, 3 Nov 2020 15:03:56 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2065.outbound.protection.outlook.com [40.107.20.65]) by dpdk.org (Postfix) with ESMTP id 51E23CA8B for ; Tue, 3 Nov 2020 15:03:53 +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=aIfAD5z6Nhu0gEH+m4X6Z9LGnXs7pZqcHGM8QOIk4FU=; b=ZJknjaUXzOvgP/F1j+xkHRCYz0zzxtX8Y11bEjwWYYX1oQApiKT7LKRRcMoRtWt3ZNgilVmmOQ+IiyLv5QnhVU41/QsZyS51/rzoQQlQWJFtlnSe0uVIoZkb0FTjfk8oacnj/tUkL+x2p1llNj69I6BmXl6woH+B97NEeMv90/4= Received: from AM5PR04CA0019.eurprd04.prod.outlook.com (2603:10a6:206:1::32) by AM0PR08MB3266.eurprd08.prod.outlook.com (2603:10a6:208:66::25) 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:03:50 +0000 Received: from VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::d9) by AM5PR04CA0019.outlook.office365.com (2603:10a6:206:1::32) 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:03:50 +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 VE1EUR03FT034.mail.protection.outlook.com (10.152.18.85) 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:03:49 +0000 Received: ("Tessian outbound c579d876a324:v64"); Tue, 03 Nov 2020 14:03:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 708a4884af8f9a02 X-CR-MTA-TID: 64aa7808 Received: from bc744638bc17.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 627B49CF-DD7B-4B0B-9333-316463D5B4CE.1; Tue, 03 Nov 2020 14:03:11 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bc744638bc17.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Nov 2020 14:03:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cU6u0UtoK7xCJFDr65oHM3/Cn40GMMThKexr6c0hV5e+sAnCNqFYcljMorgt/00ipx97fjFbsQaUwXInEV0DXkMkKQWt/0SrYDY2RLKcg8cCk24ICKhLDiUbQZc26CW/ZGHjRNCaesOzukvQzz0Knrlwvd3wqlIjPOBQumqYMkeVUcNv3Nwgj10Eqnj5LvuRPfJpbYpw7rs3Oy99EjADeiipLC7KhZ96Gd85GqNlvsomKGMNEMWyGgzlF5fyZWkYqoBpn8RTEskxZfJurk/xZe/tQcxU1QkGNjUv/jBWhsyZ5HVLb56oh2Uzoi7VLRaZ8SVm6gvkutofTsUm4Dn4UA== 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=aIfAD5z6Nhu0gEH+m4X6Z9LGnXs7pZqcHGM8QOIk4FU=; b=Tf32eCbvSHbVSHmyzPQpl2KhFChaaTg/Y/h5H+T+mqfXO+T9uWFRhmh5vMOfGRHJ5nNxunP19fbp6rTmV/I1leUWP9P6xyYVeW+WuwfcftPUvZJenazxob8ATdGTNKHr3SfVrQSOGzmdTiNJldgh0Rbcbh5zmUfHSk1r677KqAdIaEgkA8V+nTA29BCBgLcVsEBXhztpwC0uND9EZWL8L+GjvIPJy5ljFtpIPsxvtp+i18AnM5ey3DM58/8gFldwzvAfoBsGYZwqUUnUhJkvZYZVfIDZ/pt9es83goGw83SwnBdsk7BIX9iSUSdB9PVhT9EBSg6b6HGYbJsZ3cWQ2A== 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=aIfAD5z6Nhu0gEH+m4X6Z9LGnXs7pZqcHGM8QOIk4FU=; b=ZJknjaUXzOvgP/F1j+xkHRCYz0zzxtX8Y11bEjwWYYX1oQApiKT7LKRRcMoRtWt3ZNgilVmmOQ+IiyLv5QnhVU41/QsZyS51/rzoQQlQWJFtlnSe0uVIoZkb0FTjfk8oacnj/tUkL+x2p1llNj69I6BmXl6woH+B97NEeMv90/4= Received: from VI1PR08MB4622.eurprd08.prod.outlook.com (2603:10a6:803:bc::17) by VI1PR0801MB1870.eurprd08.prod.outlook.com (2603:10a6:800:85::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 3 Nov 2020 14:03:10 +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; Tue, 3 Nov 2020 14:03:09 +0000 From: Dharmik Thakkar To: Honnappa Nagarahalli CC: Bruce Richardson , Vladimir Medvedkin , "dev@dpdk.org" , nd Thread-Topic: [dpdk-dev] [PATCH v2 4/4] test/lpm: avoid code duplication in rcu qsbr perf Thread-Index: AQHWsZjMtNMX+RuZL0muXNCkPJ3yQKm10bmAgAAQmACAAI6bgA== Date: Tue, 3 Nov 2020 14:03:09 +0000 Message-ID: <73640BD5-01D1-4DE3-B0E8-5A3404734DD3@arm.com> 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> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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: [72.182.82.154] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: aeaa09f6-4611-4409-bf6f-08d8800149f2 x-ms-traffictypediagnostic: VI1PR0801MB1870:|AM0PR08MB3266: 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: hZMxy81Pckrpl0v0QHmwK5K8ME2aiJKRhZQnEviIEyl2v7DYIDNCdjAc+vW93OOgm2fCvt7c2O5KLIDExAAog59lvZnOW2DESSwhnS1ibs4jgLPqjSa+zgKEp+zGLI9mRr1HRdj2gES69B2QOtZ9JYpO9cS5VvZ8E296GRXH/Ge0SAKEMYgte4v3Gj2QRyB7r1lFk3PtuJjyla01FTXeLQJceczmRUcNCTubJAt1STzg0OAmAOvWB2TvwQJnwcJ/5wEnXOuDGHn968U6cuvTVA615ITAEWFwwHVO961Z3HUGKkPfNvn9AkIG5+iBLr6xCnUHI6bywBnQZxgAP5Sl5Q== 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)(396003)(39850400004)(136003)(366004)(376002)(346002)(33656002)(66556008)(66946007)(64756008)(53546011)(6506007)(66476007)(66446008)(83380400001)(186003)(6862004)(26005)(54906003)(478600001)(6636002)(76116006)(91956017)(316002)(37006003)(2616005)(30864003)(4326008)(5660300002)(2906002)(86362001)(8936002)(36756003)(6486002)(71200400001)(6512007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 3DeCrDZ/txwsoyeSjb4cYtk8j/tTEQHB4TQtX2rUG2C/YHKkx97Nbg4A6G5Ket1Jz2/LF4XLrCTiFKXqoqFxI/fBuab0yF8LkhkDshjpxfumNYxRqmPsqAGeBqgAZI5ZcMG/LpSh6zpmCxy8pOX6RsVQ3VmHaRROJRnd7vZ4bQBNXuJPVr+w/BUrnXp+K9mnkc3cxPIgBpHyTahf7yBlTD5xDYIyLGEScJNC3O7Ris9u0bPLNzQigBRQGNo/816uOLsiLEfAeBXniVVPhNJ/9rttmd7I0rgMuY75gIz3EOcv8Zq0AAF1qDgezGvR/l4eZ7mnJeSOCPeEQA8ANfml/RuBoHmIwdAHruiPImKurlEW/N+uUls32kJf1/PCw2m/foToXFGblF+ljB5Ngg6o+NOJahLKqoWedI7kwP83k3NWeztKmyjP7xOVwR/ywjmajiUIAptZwH/POHTRP2HaLFLCyGGDVMyehVD3stOwJgPm6Ivht3ZzqpQQGuP61aawny3yXoMKXx9bY4CQtlQ0tnmCgcBBBb7fy1U7J8QOIu35PYmB7cdbhWSN8pVP6b0UcE5muVrXyhTYLQ1dqD8K8vG/xQsFiar5lrHrbuFndtKsqrRAsmtigWPzSr850ThCvt50u8ALPx/Zoyzq+7lAUw== Content-Type: text/plain; charset="us-ascii" Content-ID: <6B0D16CB4D8B1D4FA2C3CB98B0DB84DB@eurprd08.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1870 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: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c7d4a6e5-a30f-4daf-2b9e-08d88001323a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eEVtAdkJc+siHr61LG/MJNtflAK0mA+OiN8Q3Y6vDGAebSONlRVF3QMUruTMnGNljPxnczI2QqDQIp+21ifnFduFhMA+FC5zAERlsPSwtL5EF/ckf0QS4IoDDJTmvXtmht2rprDp3ZEbF2x3v6DSAOS713wh3mMh+NCQW8nPvj99FhMW/0AyBzXDKwKVi9nzW3xAiIPGVVRx/p+l/Tm+lDJBbcA4/lSLyPI7jUnm0H4lEabWWKCNd4GDbASC74eK3Bb5MsdwJGrrL+FHbJKkFKCNdk5xpau0kYCrGeNmqk3lIW/HkGbZqL0zalrjL87CTPC7HKkaNTwJ/srrLrnUBCMXrlnIPEl1CiRsqiPICBh3Tv2yO3oBhy2jJrJCqcse/FaRSSn1p1HdW2npi7L7Zw== 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)(376002)(39860400002)(346002)(136003)(396003)(46966005)(33656002)(5660300002)(53546011)(6862004)(6506007)(6512007)(8936002)(70206006)(70586007)(36756003)(6636002)(86362001)(30864003)(82310400003)(2906002)(82740400003)(4326008)(81166007)(83380400001)(356005)(47076004)(54906003)(478600001)(26005)(186003)(336012)(36906005)(2616005)(37006003)(316002)(6486002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 14:03:49.5553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aeaa09f6-4611-4409-bf6f-08d8800149f2 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: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3266 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" > On Nov 2, 2020, at 11:32 PM, Honnappa Nagarahalli wrote: >=20 > >=20 >>>>=20 >>>> Avoid code duplication by combining single and multi threaded tests >>>>=20 >>>> Signed-off-by: Dharmik Thakkar >>>> Reviewed-by: Ruifeng Wang >>>> --- >>>> app/test/test_lpm_perf.c | 362 >>>> ++++++++++----------------------------- >>>> 1 file changed, 91 insertions(+), 271 deletions(-) >>>>=20 >>>> 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 >>>> }; >>>>=20 >>>> +enum { >>>> +SINGLE_WRITER =3D 1, >>>> +MULTI_WRITER_1, >>>> +MULTI_WRITER_2 >>>> +}; >>> Do we need this? Can we use the number of cores instead? >>>=20 >>=20 >> There are 3 combinations of writes (adds/deletes): >> 1. Write all the entries - in case of a single writer 2. Write half of t= he entries - >> in case of multiple writers 3. Write remaining half of the entries - in = case of >> multiple writers >>=20 >> So, I think this is required. > IMO, this is not scalable. Essentially, we need 2 parameters to divide th= e 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 w= ould be better and scalable. Yes, agreed this is only applicable for 2 writers. Currently, the multi wri= ter test is only limited to a maximum of 2 writers. To support more number of writers, we need something like this (which I bel= ieve 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_ins= ert; ei =3D si + single_insert 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 than = 2 writers? This will increase the time for which the test is running (which currently = is significant even with 2 writers). >=20 >>=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; >>>>=20 >>>> -/* 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); >>>> } >>>>=20 >>>> /* 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 delete >>>> 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); >>>> } >>>> } >>>>=20 >>>> @@ -482,16 +499,17 @@ test_lpm_rcu_qsbr_writer(void *arg) >>>>=20 >>>> /* >>>> * 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; >>>>=20 >>>> 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++; >>>> } >>>>=20 >>>> -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; >>>> } >>>>=20 >>>> -/* 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 delet= e >>>> 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; >>>>=20 >>>> -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); >>>>=20 >>>> -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); >>>>=20 >>>> -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]); >>>>=20 >>>> -/* 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'? >>>=20 >>>> +enabled_core_ids[i]); >>>>=20 >>>> -/* 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; >>>> -} >>>>=20 >>>> -/* 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); >>>>=20 >>>> return 0; >>>>=20 >>>> @@ -946,9 +767,8 @@ test_lpm_perf(void) >>>> rte_lpm_delete_all(lpm); >>>> rte_lpm_free(lpm); >>>>=20 >>>> -test_lpm_rcu_perf(); >>>> - >>>> -test_lpm_rcu_perf_multi_writer(); >>>> +test_lpm_rcu_perf_multi_writer(0); >>>> +test_lpm_rcu_perf_multi_writer(1); >>>>=20 >>>> return 0; >>>> } >>>> -- >>>> 2.17.1