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 01CF4A04E7; Tue, 3 Nov 2020 23:35:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D7A0CAD0E; Tue, 3 Nov 2020 23:35:55 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70057.outbound.protection.outlook.com [40.107.7.57]) by dpdk.org (Postfix) with ESMTP id 24ADEACAA for ; Tue, 3 Nov 2020 23:35:55 +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=tAEG0MEdmK31IfQHjF4zEEr0RHvnwdtwRrIliS815rM=; b=3gcGqcrNL/GxQXeA8OplsPe14HZKrDuh+3OYcYx/DVvs6tVg0icLR2IYU1nShWoc0wXNxYcRLmyakzbgp2/aJLoJEET8UAy3TNI3zrfhfMN5RpkjvIIIjwh5zzWMTqmuJCuT8lmNGCJ8FIKZFVF7fU3qcgiJlAl9UuWhhKnYrFI= Received: from AM5PR0701CA0059.eurprd07.prod.outlook.com (2603:10a6:203:2::21) by AM9PR08MB5938.eurprd08.prod.outlook.com (2603:10a6:20b:2da::8) 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 22:35:52 +0000 Received: from AM5EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:2:cafe::20) by AM5PR0701CA0059.outlook.office365.com (2603:10a6:203:2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.10 via Frontend Transport; Tue, 3 Nov 2020 22:35:52 +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 AM5EUR03FT054.mail.protection.outlook.com (10.152.16.212) 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 22:35:52 +0000 Received: ("Tessian outbound c579d876a324:v64"); Tue, 03 Nov 2020 22:35:51 +0000 X-CR-MTA-TID: 64aa7808 Received: from fa01f15d807e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EEC9964C-D17C-47DC-9927-92E7D72D1D9B.1; Tue, 03 Nov 2020 22:35:46 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fa01f15d807e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Nov 2020 22:35:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iTqTb5PT8eEimqzsLVqYP3Wyc44q2ytlIXoymu0c3v8uOBlTt7dJBLCI3qY6puoHwf6ks7+8Mc0piW8aUsqL6pDXjE0x4rGvv83qgWBuo7W2GRzxV6/CwZEF1hIeFYmRT8kR+coTwOQxZXdOUwjo3gh7lNHfLLVSuvmLYeFa9xMpC01n7WdGUCLaKJrHaQXZqlbv2CzRxqjQTgha5tFeV6Ghpn5ZXf3wdb060mMhvSboTt0ykAykOYPsGJsTBCqpS1RpZj8gm+YNn0URsgwK9dB7+ZBcABP80DbiMGmE58OtJwkyI1a8XgGKnHH4W6rZNY9KdFry2eLzsqXmvLr9hg== 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=tAEG0MEdmK31IfQHjF4zEEr0RHvnwdtwRrIliS815rM=; b=LAmsjyE5s+Y1+v4dbfoQP49Kh7NRtPIiIFGYuMhswhDdW/sAvQ+7/9OeqiJFC5vX5LZiXzSsHVw1f30WlkKx47eccPth25XCq9W8afqVEvpRUiLE/SP4sOa3J1yowxa8vsOi5Z4vYqPk9QBFVd/pqUFfImoeypxxhD5XWttyjQjKA3VvCNszkrrWK7gNbtFkoPtVxZyeEw3Y1r4BgRs5h0YYi4UeZhyrr+CwYxXbUAqGMbZUwH3nhWendBeE9Yt6q4yN40kB1JSStZSZ9qYPRLgpiicFc+7ufHU+Ecx+M9jvrkS1GGdVFanTTADuTHA+eFBpUgyJKRdtbZcFixfS0Q== 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=tAEG0MEdmK31IfQHjF4zEEr0RHvnwdtwRrIliS815rM=; b=3gcGqcrNL/GxQXeA8OplsPe14HZKrDuh+3OYcYx/DVvs6tVg0icLR2IYU1nShWoc0wXNxYcRLmyakzbgp2/aJLoJEET8UAy3TNI3zrfhfMN5RpkjvIIIjwh5zzWMTqmuJCuT8lmNGCJ8FIKZFVF7fU3qcgiJlAl9UuWhhKnYrFI= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DB7PR08MB3883.eurprd08.prod.outlook.com (2603:10a6:10:76::28) 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 22:35:43 +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 22:35:43 +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 v4 4/4] test/lpm: avoid code duplication in rcu qsbr perf Thread-Index: AQHWsjA5vlmBroTw8EOY2IVs6CuRoqm2/sUA Date: Tue, 3 Nov 2020 22:35:43 +0000 Message-ID: References: <20201103051224.12620-1-dharmik.thakkar@arm.com> <20201103222352.11566-1-dharmik.thakkar@arm.com> <20201103222352.11566-5-dharmik.thakkar@arm.com> In-Reply-To: <20201103222352.11566-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: 60CCC2BFF4AB55489C53A8A1DC2917EB.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: f45eb896-9047-42ab-5c82-08d88048d1f2 x-ms-traffictypediagnostic: DB7PR08MB3883:|AM9PR08MB5938: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:655;OLM:655; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: X+7aemelUd9fE4Ieo1QKREi0HeEN6OO9vctpuIiDDG6q49HnR56C8l1hhnynceWoeFJfBa27MzeZGPqqe+1F0iv5nar/5Sl9l3lQsl1PhK1AbLXGRgojlwEIIADgSzIe8nIyiD39Voo7+BhMX1vJTSMR05c4LHxgCbdH5VGnbQYT43rNwgtuF84sQldAhtUvjSXcJtQ+wlZ0JV//1pVH5QAgPVhB+1bDoX+fcXgmJ4CxkW57PoIROfqVshCEXmpRPudVJNUn1QVFu2pluk3xRJSLUzRSnvobK81NUPSCvDTNKxU7Lzs5NbB35B1n1OVx 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)(136003)(39860400002)(366004)(346002)(396003)(66446008)(55016002)(66476007)(66946007)(8936002)(26005)(5660300002)(76116006)(64756008)(9686003)(66556008)(53546011)(4326008)(6506007)(52536014)(71200400001)(110136005)(478600001)(86362001)(54906003)(186003)(30864003)(83380400001)(7696005)(2906002)(316002)(33656002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 1CKgO7tTEs+aQ9ioHsZ1XmguzO7s4vLKWD0bT1FpDdOmZeCIa5G4b1ndfSpQhzMdZO9WSjEVGbxSqlKm1MOqnXo2dobkeWSFCsN9PWFBmL0zaoTiYCi/o34uGDiQMiQNoxx66ymCadyz0BlnTO+QVaqvMeioTXSLOvfholQhUo/eP6He7XP1THcgADkQMz8hC9ss9Mz2ePgAzYp4/e6zurtAo2lQLhRd4RG1wTlwOBpnb0cW1gkIJxZIDVC3sqgnnDa7qX03VDodwmFajngRlu9hrP3pnWMr+84Hh1vXtq1aYflALFrawK15DISRO/MA3ATuVTIr9+dCqBo7hfbb5zEtUBYJpKn3kI2O8GcP+SvrWwvoPKId6QAsypkrXq8ql8zlrnDgaSD1zQIjoRFzFCrb+VI/bQj2PNrhuAjbGagWXBLepxlSzk25v1FTlxqtIzum0wVyBhdA/6JJlGGv4DqF6tJD9Tf6wzJMy0UG3AVMSwF8diaWYSHNC28SpgKZ0n9RTLZC2B2/osDoeeKndRv1XNCvS2n8jSv+Ap9UASGL+hyfPXLCYMogCmBkvnyaIMluXKhuEZguqxZjZO1IsRYgFoLDzY4xUf5xeUNllnkURbDaGzSj+4c2LgiIaIsWhYwf6rr7cVw1CMmZ5dxCgg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3883 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: AM5EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c60f2616-4a4c-4b92-48f1-08d88048cce3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b3a2Fmwew6kAT7cOpJpkJlJKf4g90nM4t5BJETmwatO4mX0/h5aJ2loRdMzyDzjD++k8I1Q5Q9W5/JRJL1i0iBm7RokAbsQZSqu/UfENbiRKKL72UVzrknNKw4giLqqWMiiACclGsSUEJC4FxO4L2CaiSPWNwaLgRRVO6cpuuVvF5bJdgAvt2VW8Gd+AgCsk2DhYHb13Yyrw11DIWNLumoKn6mox17Pp0IcR15lflczXOTFM7ZZ4J+GdHDZ7NcfWJQlvUKA91426s6z5wu+gNnorYlWmHieo5vuqyH2w+ZvCZ9R8BfPogrhMYmWxDZ7EMyXa8JEmiDoOAb5Z7PJh6G89zFLzmoXLuXXqsR86figUICsnG0ud0BirNg134ZVgr+NfzfVJQcupAXQDlfggDA== 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)(136003)(346002)(376002)(39860400002)(396003)(46966005)(82740400003)(81166007)(47076004)(30864003)(53546011)(86362001)(336012)(8936002)(36906005)(478600001)(7696005)(82310400003)(33656002)(356005)(83380400001)(316002)(70586007)(55016002)(26005)(9686003)(5660300002)(54906003)(70206006)(186003)(110136005)(52536014)(4326008)(2906002)(6506007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 22:35:52.0427 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f45eb896-9047-42ab-5c82-08d88048d1f2 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: AM5EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5938 Subject: Re: [dpdk-dev] [PATCH v4 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" > -----Original Message----- > From: dev On Behalf Of Dharmik Thakkar > Sent: Tuesday, November 3, 2020 4:24 PM > To: Bruce Richardson ; Vladimir Medvedkin > > Cc: dev@dpdk.org; nd ; Dharmik Thakkar > > Subject: [dpdk-dev] [PATCH v4 4/4] test/lpm: avoid code duplication in rc= u > qsbr perf >=20 > Avoid code duplication by combining single and multi threaded tests >=20 > Also, enable support for more than 2 writers >=20 > Signed-off-by: Dharmik Thakkar > Reviewed-by: Ruifeng Wang Looks good Reviewed-by: Honnappa Nagarahalli > --- > app/test/test_lpm_perf.c | 359 +++++++++------------------------------ > 1 file changed, 84 insertions(+), 275 deletions(-) >=20 > diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c index > c8e70ec89ff5..a1485e74e77f 100644 > --- a/app/test/test_lpm_perf.c > +++ b/app/test/test_lpm_perf.c > @@ -23,6 +23,7 @@ static struct rte_rcu_qsbr *rv; static volatile uint8_= t > writer_done; static volatile uint32_t thr_id; static uint64_t gwrite_cy= cles; > +static uint32_t single_insert; > /* LPM APIs are not thread safe, use mutex to provide thread safety */ > static pthread_mutex_t lpm_mutex =3D PTHREAD_MUTEX_INITIALIZER; >=20 > @@ -430,24 +431,21 @@ 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); > uint32_t next_hop_add =3D 0xAA; > + bool single_writer =3D (single_insert =3D=3D > NUM_LDEPTH_ROUTE_ENTRIES) ? > + true : false; > + uint8_t pos_core =3D (uint8_t)((uintptr_t)arg); >=20 > - /* 2 writer threads are used */ > - if (core_id % 2 =3D=3D 0) { > - si =3D 0; > - ei =3D NUM_LDEPTH_ROUTE_ENTRIES / 2; > - } else { > - si =3D NUM_LDEPTH_ROUTE_ENTRIES / 2; > - ei =3D NUM_LDEPTH_ROUTE_ENTRIES; > - } > + si =3D pos_core * single_insert; > + ei =3D si + single_insert; >=20 > /* Measure add/delete. */ > begin =3D rte_rdtsc_precise(); > 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 (!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) { > @@ -455,19 +453,22 @@ test_lpm_rcu_qsbr_writer(void *arg) > i, j); > goto error; > } > - pthread_mutex_unlock(&lpm_mutex); > + if (!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 (!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); > goto error; > } > - pthread_mutex_unlock(&lpm_mutex); > + if (!single_writer) > + pthread_mutex_unlock(&lpm_mutex); > } > } >=20 > @@ -478,22 +479,24 @@ test_lpm_rcu_qsbr_writer(void *arg) > return 0; >=20 > error: > - pthread_mutex_unlock(&lpm_mutex); > + if (!single_writer) > + pthread_mutex_unlock(&lpm_mutex); > return -1; > } >=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"); @@ -506,273 +509,79 @@ > 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); > - 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); > + 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); > + > + /* Calculate writes by each writer */ > + single_insert =3D NUM_LDEPTH_ROUTE_ENTRIES / 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; > } > - } > - total_cycles =3D rte_rdtsc_precise() - begin; >=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); > + reader_f =3D test_lpm_rcu_qsbr_reader; > + } else > + reader_f =3D test_lpm_reader; >=20 > - 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); > - rte_free(rv); > - lpm =3D NULL; > - rv =3D NULL; > + writer_done =3D 0; > + __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); >=20 > - /* 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, > + 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 > @@ -948,10 +757,10 @@ test_lpm_perf(void) > rte_lpm_delete_all(lpm); > rte_lpm_free(lpm); >=20 > - if (test_lpm_rcu_perf() < 0) > + if (test_lpm_rcu_perf_multi_writer(0) < 0) > return -1; >=20 > - if (test_lpm_rcu_perf_multi_writer() < 0) > + if (test_lpm_rcu_perf_multi_writer(1) < 0) > return -1; >=20 > return 0; > -- > 2.17.1