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 E9CC5A0521; Tue, 3 Nov 2020 05:33:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C91C5AC8F; Tue, 3 Nov 2020 05:33:39 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60089.outbound.protection.outlook.com [40.107.6.89]) by dpdk.org (Postfix) with ESMTP id 42B89A8E9 for ; Tue, 3 Nov 2020 05:33:38 +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=I6MtZ+HWFeExkD5IU5/j89d7jxCippDSyQXhN14rUGg=; b=uEvwt1K/TqnrqXznBtfcjX6YAIuL8DlO8yt+QxPM0Rgptf7miCu64VsuKWZvtact+5xa6u0PLlYJD4VU2TT2M6NURb84RV0oPG3RMEFaVtqQBlh9wlVCHC1PwYgba+B49pcU5KzzZWIkwqjI6preQuY4mWYMz4DuOj6VQ96rsKk= Received: from AM5PR0601CA0039.eurprd06.prod.outlook.com (2603:10a6:203:68::25) by DBBPR08MB5993.eurprd08.prod.outlook.com (2603:10a6:10:1f4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.22; Tue, 3 Nov 2020 04:33:36 +0000 Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:68:cafe::9b) by AM5PR0601CA0039.outlook.office365.com (2603:10a6:203:68::25) 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:33:35 +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 VE1EUR03FT038.mail.protection.outlook.com (10.152.19.112) 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:33:35 +0000 Received: ("Tessian outbound c579d876a324:v64"); Tue, 03 Nov 2020 04:33:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 45507215e9a719be X-CR-MTA-TID: 64aa7808 Received: from d86fb253a6d0.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7F5CCFC5-4FE2-49CB-90C9-4D2C356B5398.1; Tue, 03 Nov 2020 04:33:29 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d86fb253a6d0.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Nov 2020 04:33:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gbpO6U/HoPVrkrhG/RBIKN/2F/U24xpV1WBJR+KxasS2YNO341KeXyJgu9zsodZde0UbIsL0PlinAsiQPpRSDTznGdCgsYtTYAGrohUayVVuTKb9e8HHpGOMl1IFG2/lGeQDqRcpul3KtX7wKrF3J+JRhpmlzsS+SPReOJ1emH3sCrLT7wq5uRkyCTYvtNkdPXZ9D4N8TqRX0Gb+7Fzz0/G3mCzPd60NJKaz1NE25BOGuyMeRP5NU1k7Uda1vFe9wD2NE55Q920I8rFQGSNOSWq137LZOi7B2tJVXzIa3+lMRb3TrRGHnY4v2nsJig0Tg+fod8oVn77WZbs+7WQXQQ== 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=I6MtZ+HWFeExkD5IU5/j89d7jxCippDSyQXhN14rUGg=; b=Ca+IXtMV3ZfR3YdhCmzWGVUapbl/2CwJkklyHZuKUCSQXKsjhWI/9X9xT7a1Z32YXMg3btW1ZE0Cfh/ey1gzQXueDY0OWpfZulxdTW8dGfN8hEQ8T/Z9+Ku+4vaqbN/fNR/tCOeoqcxmV/gr9CTixA/2PvCRyt7RuHLtYvGGrHw0pd5R2Zem1i3+h1kAaZp2dv/mwe4y9ronBZQxwqn+CayZjEwZmYjNYcP+MMlP9u7CcU18BYykatxC6CHgrSPXB4aCqJuNX2kWtcyDYA/Stmn5UjFcu5U6qNgme3GO1Iwxfar/VyUqXHmZ7UDf8I62O5EG+spNo9I5Uky6zdkWdQ== 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=I6MtZ+HWFeExkD5IU5/j89d7jxCippDSyQXhN14rUGg=; b=uEvwt1K/TqnrqXznBtfcjX6YAIuL8DlO8yt+QxPM0Rgptf7miCu64VsuKWZvtact+5xa6u0PLlYJD4VU2TT2M6NURb84RV0oPG3RMEFaVtqQBlh9wlVCHC1PwYgba+B49pcU5KzzZWIkwqjI6preQuY4mWYMz4DuOj6VQ96rsKk= Received: from VI1PR08MB4622.eurprd08.prod.outlook.com (2603:10a6:803:bc::17) by VE1PR08MB4926.eurprd08.prod.outlook.com (2603:10a6:802:a9::22) 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 04:33:25 +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 04:33:24 +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+RuZL0muXNCkPJ3yQKm10bmA Date: Tue, 3 Nov 2020 04:33:24 +0000 Message-ID: <9B5688D2-D668-4EE4-9ECF-150BDEF5A292@arm.com> 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: 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: aee09616-0fd5-4478-8365-08d87fb1a0e1 x-ms-traffictypediagnostic: VE1PR08MB4926:|DBBPR08MB5993: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2276;OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: bBSKSjqTCk39K2vdxfBjd8XSbUYRmnSusKpk70//piZvffzW0nr5Qz3QjCAuR+xoUnBWjbA/Ue0DQ8ctKJR22CnHOsKeQA9A/B/8fpu/5ENYilNWeZpcMtIS6cJu71NuayKJ+6jdjUfv2J5C3/0xy8+zKlTwhoJiENEVcoigkiSg8ys/v4Mk4YIS5QgXwGJNO3l89wGU9sKSzfaxbTZVl2DdowllLS6uvJemLpWZRk8BUF6GZMSkxzxZXk7SAJTrjm2nLHpfZNk/MAMl/JkfQSYo4S0oBke9doSG5ARHt8cjiwxaAOjmjiG9EKqSFILv9UeWus1gDPtRe/lLAy5CIw== 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)(346002)(39860400002)(366004)(396003)(136003)(376002)(54906003)(4326008)(6512007)(6862004)(83380400001)(33656002)(37006003)(316002)(86362001)(30864003)(26005)(2906002)(8936002)(71200400001)(6506007)(66446008)(76116006)(186003)(478600001)(36756003)(6486002)(2616005)(66476007)(91956017)(66556008)(5660300002)(64756008)(53546011)(66946007)(6636002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: NOPR/UKLnj88uab0XezZQM7kf43ymxBR44B5rBFmoXLn4QntIdb6MZg+WoQ4TY9I6mzh9vZUm7CpF9qF9Aup/Rr8igV31ZPqSirPiSVgyBJVLL4Vh+nj0jO8Xa6lfqj8VNwiYGwubT/keEKDgfYHUkvDmTXv+e8fz5GQQPgYCfLShG4IcemV9pYAFPKw7aMo08roNKt8HyQz0p7JIph0XLllQAPWCOmNvc+WkaT3x/wrjkBi5/tXXM/1OQp8Fpu2K7WZq4Lc0o0XDVeSaJOg2QBeGYINulRsQix7kxWF3OP1LkXnXpjbDQ9ovMj8dq1xJYQsk0hstswvSjIedPRHRNaqOimClrpnsuW0TZuojtIa1wZLjISNCtLATOyLq4a7lrqJAyDxx/ojRI9e8xGY7zAGgrIX+4OLA8YcOkizPnL8WJ87ZNIUFbLUirS3jISkCtmKX1uTiSDbI9bZFwU1PoklI3fUKdKIZ7zZb3Jmr50mluYOe2F0/CxKQqNK6+Wu91Tkzghg0t7MD7VYMXl6FdDUDtJ7/ZAmnZfjCxvwT6gkcBiKXzswegDMxfIJpgvedmb5Oc4YIVsGUZfh4wPKCPITZXPMjXy0uqlzuK1gqs/cPyntL9dnb0bT0AQVgGcuRoKVWB0yT4ezdZPmSRXE4w== Content-Type: text/plain; charset="us-ascii" Content-ID: <28B1063799E6564AAA32C40E908FC47F@eurprd08.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4926 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: VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: fb8de8be-f34b-4603-a55d-08d87fb19a5f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RqN1ayXzH0208nRMFXGPn/pN6shD48NO0Mmyq4Ka6JOw6iBF4X24fAci2cvSOYzk0ap9tfGvAbKJ9EFBGh40VxVh5dBP/0Z769aWUUki60F9HMDdtAh+cfXuyIYRYHZAxXm1EqoPGB+UL0ZhiPAk5RsnuCSRpmrq9XcwY+1CB2SCaFJkq6BygfvKzBRvJtoKrd54jgSAINRPLrao4PYx+gKSuAWg+LKPV0mFyUbkWzx9QbfAhmOhMbv11GQmkWu750JFvBA2KAmvM5s4sqOGoHrES5qHrZ7xR5yrrZ9nJS2LYgrtBbVF7QjIOGFGU+ln+zC4e7oYaS6Zi5cFVRa1JuTrl5borLk3MZRltv9ynNZWkCiwplbRZJQ14Tpd6OwHmUp7cmuntXAJeHSHLLfn4g== 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)(376002)(39860400002)(136003)(46966005)(6486002)(6862004)(5660300002)(36756003)(336012)(36906005)(83380400001)(86362001)(316002)(54906003)(33656002)(6636002)(186003)(70586007)(70206006)(2906002)(37006003)(26005)(4326008)(2616005)(47076004)(478600001)(356005)(6512007)(81166007)(30864003)(6506007)(53546011)(82310400003)(82740400003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 04:33:35.6418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aee09616-0fd5-4478-8365-08d87fb1a0e1 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: VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB5993 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 10:21 PM, Honnappa Nagarahalli wrote: >=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 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. >> + >> /* 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'? >=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