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 1EECDA0521; Tue, 3 Nov 2020 05:21:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DCA93AC90; Tue, 3 Nov 2020 05:21:31 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60075.outbound.protection.outlook.com [40.107.6.75]) by dpdk.org (Postfix) with ESMTP id F2E0EAC8F for ; Tue, 3 Nov 2020 05:21:29 +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=aCLhg6cjqXG6UAgyXV/H4vlRAd+IiHxd7CnAmx18aq0=; b=0hl915WPRFvVllF/UZ1JfCd9jHa3bW1UXg7K+/fLkOxIAvuIPIxNHkGxs4k1JHr0ns0vzQPlU0kUW5920aM3RKx1IEojGp/PDLZYSDExadCMulHXM93VmqUgps8JZbtifbWSNqfwauOAH9nvbEW8fqjb9AAxKCFkfpcQFB0WaNs= Received: from MR2P264CA0040.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500::28) by DB8PR08MB4137.eurprd08.prod.outlook.com (2603:10a6:10:a5::16) 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 04:21:27 +0000 Received: from VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:0:cafe::46) by MR2P264CA0040.outlook.office365.com (2603:10a6:500::28) 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 04:21:27 +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 VE1EUR03FT051.mail.protection.outlook.com (10.152.19.75) 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 04:21:26 +0000 Received: ("Tessian outbound a64c3afb6fc9:v64"); Tue, 03 Nov 2020 04:21:25 +0000 X-CR-MTA-TID: 64aa7808 Received: from d51958e24467.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FAAFB4D3-7F8D-42DE-A8FD-CDFBB0356A57.1; Tue, 03 Nov 2020 04:21:20 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d51958e24467.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Nov 2020 04:21:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CRz3gTCg75V0kt5cBOIf2C10GNzedSNs2Y+5rTYfd6ZCmmVh2AcBs0Ydrph21Xhglnb0osoeRun34wgzI5iUotO0zBwNb5sPgbuZ4Iubc1GdBpPKzQGuNyszT/vbRFZpqUvQ3oL0izKnkRRIuZzVQSbxH5Q8TqjZE2wkqTerAQ5la6cERcbJCbQKaiZVjys4mlcGD7XyS0Iw1a8D5Zb+dQjAMzEZBv9r5D3umvTdbvFPOaNiNR8kg7po3k3ooFRAHZ/QxyVNjOQifpSSR3cIa4TA2UgaM0KRwLoNfjHOiWaoSWM7RiQoWyjVENOVwy08dgZ3LkufwK6VDLOKnx7KaQ== 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=aCLhg6cjqXG6UAgyXV/H4vlRAd+IiHxd7CnAmx18aq0=; b=OEq3/Yfr8TP9Bj7+8Xmqn3R0JIMdRL9OWGSqHEppp8Ut3+NvCKFbgnykZcXTugKKsuejFWAB3VjgNI0fqVPNMoodeaa8fKQJfX3hT4FXUrkimY6fQUPP0cMw6AVkrDdYNaVvHP1cdCtoicXtzG67lP22GI0TEUp3h3ag6s1F3bKVqHES4vWMoQybYtCHreiYeO5bxvOwuJG81Du9TWW5/9cHQFvpbSM5ZBS8pd4sKjYkYmLgKZUK7hedoe+usliY2ITsPcPIyBcRSxTBB5EFxUboW76WkehfjZryG1Zn87Jx9LyQcyYa+TuUcPHvQCBdPnEYEKzBQDnQr5x8+Gxgqw== 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=aCLhg6cjqXG6UAgyXV/H4vlRAd+IiHxd7CnAmx18aq0=; b=0hl915WPRFvVllF/UZ1JfCd9jHa3bW1UXg7K+/fLkOxIAvuIPIxNHkGxs4k1JHr0ns0vzQPlU0kUW5920aM3RKx1IEojGp/PDLZYSDExadCMulHXM93VmqUgps8JZbtifbWSNqfwauOAH9nvbEW8fqjb9AAxKCFkfpcQFB0WaNs= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DBBPR08MB4441.eurprd08.prod.outlook.com (2603:10a6:10:cd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.30; Tue, 3 Nov 2020 04:21:19 +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.030; Tue, 3 Nov 2020 04:21:19 +0000 From: Honnappa Nagarahalli To: Dharmik Thakkar , Bruce Richardson , Vladimir Medvedkin CC: "dev@dpdk.org" , nd , Dharmik Thakkar , Honnappa Nagarahalli , nd Thread-Topic: [dpdk-dev] [PATCH v2 4/4] test/lpm: avoid code duplication in rcu qsbr perf Thread-Index: AQHWsXOe/GYRfGhBrk+npnXu35aBe6m1ynWw Date: Tue, 3 Nov 2020 04:21:19 +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> In-Reply-To: <20201102235203.6342-5-dharmik.thakkar@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 2AAEF6B5C6DCD54B8591FF9409686040.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: [70.113.13.105] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: db583e14-94a8-4b34-46b7-08d87fafeecf x-ms-traffictypediagnostic: DBBPR08MB4441:|DB8PR08MB4137: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2150;OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dDCoMzHidwPGcwN/hjy8f31jA8taay4Yy1Tj6XvT4kLagFGmpOsdcYIB+RoJqx5VawshM/vzTxnb7+l72dJusndcy4i19of0x5wdUfYweTOufgDBOufhEg+7zMXQQx5LlWFacB5tnVTB+U1JxnxqXu3s2TuCNivvh2fwOPS2ZDAm1afVbofPAJCnTRrFvJ17b3EcdWKtq48rh+0rd5pby4SRP/c8+Ak8Yi7XInzEVDfby32nOXbnuraUX66Rl92dseoNaLTXQtQ1BDpukfz86RYVj+Kt8rqTzISmXXwQ6r+SaNrzHFTMiQ6X0LirGKaLiAVyjrEteJqMLBAGYJKt9w== 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)(346002)(366004)(376002)(39860400002)(396003)(136003)(71200400001)(4326008)(54906003)(86362001)(33656002)(9686003)(55016002)(6506007)(52536014)(66946007)(76116006)(66476007)(30864003)(478600001)(2906002)(66556008)(8936002)(66446008)(186003)(64756008)(7696005)(110136005)(26005)(316002)(5660300002)(83380400001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 7WF6nOov4v2M7vBaKhhtIgR32L00H3NO4IyoFIZ+cbli4SVMyefV9j8df9X87CRTG/MnkD68bKsY0e4vWCYA6gqfC/6CQ3JHL28ScjGLqjhbuuRXSCRNdRo1UOtURvx2Bm9kaiTGDG7gP0VIh4GrZNwD1FDC2LNVf+QtaU0N74Ouk/2Cjs7J4IZv50BJhqzlY17RxOkXfebFKy+gHcxHamba1AehbvCI4bGdndIXvtk1IbHQIn648gdFWPTVuNDMpON48UUBXycTQJvbDmOxZ3QWywOsAOjp43NPeYAkUputHHts7U2Of/VkeqFnOsW1JPGwxE9SDe3AeRugC895+RW9VjNKY8dTdSb05af/1Q+xoxfV/U+eKG1wkHojrJQmYYUhqDjonNuwc/kRawJPUfvApW8k79ukfpz0wKHEzZrZ2AO+sjfevYbAJD3yCZUjNvtAHa5zW3CAwCrc1bqjLpuZLRZYHvnt6JTbbwahhIbdwvjyz1FdvKJjRT5+hvRN3fEYPaa/vGuX+pJl4HuGAzF3Hhva4qW8gK45lmYxUrL14ZA/KcAndyiDFnATWcFNZ8Od6Am5tfc4PK2aXWLfeL+LPKo2mu3GjQIuq296xGG347HlilUh6sGM7MunifbB6nOiU4LhoT9Yl2LRSBTrkg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4441 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: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 36bd2ef0-589d-453e-d8c5-08d87fafe9d7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jYnLsdY2hU/7V6ZO4mmQaYaQWjB1BXaq6HrR3Ax0y3omuck7st8xC7FAzb2oTysvG0KlbkC8rm0HHgDFu8igXZ9GePCK2FQMjR9jR8pLOg/hxbbvuQbWStGNUITUEnM7PaOyfI6RIpTPxLyoMzJGHlaMWEVvNd9Kl4a5b0qivaYyBxhbvP/omVrLNBR3CoRkT5BwGI+lB4oPGyh9jtMtAuon9XA6T2swWiplCnlqXIKGXQmdyFWxRDhaat+kZWrrBloXRL3EC3UcuVClRmw7gZbZbnU+sXWmQ7PaDvGsYG5WEvQZ+HkTFtpAYcSyeObVtiRZzCZP96nHH/+8V8hQt02KuHL5pN2IBz86Q5wdnKUFb4qXYgeGxw+i4XoVJJobM44cgV9CP/dRnyug59Fxfw== 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)(136003)(346002)(376002)(39860400002)(46966005)(81166007)(186003)(4326008)(70586007)(110136005)(33656002)(6506007)(83380400001)(47076004)(54906003)(26005)(70206006)(2906002)(82740400003)(356005)(336012)(7696005)(55016002)(478600001)(82310400003)(8936002)(5660300002)(316002)(86362001)(9686003)(52536014)(30864003)(36906005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 04:21:26.2498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db583e14-94a8-4b34-46b7-08d87fafeecf 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: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4137 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" >=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? > + > /* struct route_rule_count defines the total number of rules in followin= g > 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 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; >=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'? > + 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