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 4E37DA04B1; Wed, 4 Nov 2020 17:49:51 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D3E42C16; Wed, 4 Nov 2020 17:49:50 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70085.outbound.protection.outlook.com [40.107.7.85]) by dpdk.org (Postfix) with ESMTP id 5C1822BFF for ; Wed, 4 Nov 2020 17:49:48 +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=pcvEtMtsfVE4mbdxLoHTcJx79KwtN7C9mFXvM3qbjic=; b=5J8EXfKZ6ek8ZOshWqV9QE/O8GuswXsFtC95Ty29P+NBAKcN/RclVVlvkNB/Dh8xMVllVxN+KT3/mYYdIUSTAr+Gj49qg5/ABaOu9AolobRoDVPbcRK7RSvgpfgb2BeO8TxtfF3DAvZ6vhhQyZBywiPwecwkLkJep7CNiAa9E3U= Received: from AM6PR01CA0067.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::44) by DB7PR08MB3164.eurprd08.prod.outlook.com (2603:10a6:5:24::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Wed, 4 Nov 2020 16:49:45 +0000 Received: from AM5EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::b6) by AM6PR01CA0067.outlook.office365.com (2603:10a6:20b:e0::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 4 Nov 2020 16:49:45 +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 AM5EUR03FT035.mail.protection.outlook.com (10.152.16.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3520.15 via Frontend Transport; Wed, 4 Nov 2020 16:49:44 +0000 Received: ("Tessian outbound 7c188528bfe0:v64"); Wed, 04 Nov 2020 16:49:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ba981a588662f603 X-CR-MTA-TID: 64aa7808 Received: from 3a05cf594cca.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2D7F06E0-2B58-420B-97C6-256AA0C4E83B.1; Wed, 04 Nov 2020 16:49:39 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3a05cf594cca.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 04 Nov 2020 16:49:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aCEKnsrarCSjv9mYARJYnluoRZWgKOsyMglBBY8CYX/uAUJCqA999DD3anWg5naZhsUdM+1dKJ0gC2vctXgyEQe5MAXIcICHA9FcPf7LYnKgCqxDqqwLV13Mmm7QSetuNe/OXurHaxM78Q7YnYEOqUAvVLtByhO0QkRsOUfkLYig0nGzh+W87CnYg/4whCRxKlWTsP71/mxFDp4Yce7xhn4O8F4kp18jEJKToDY39OkwTWubkyKHj26MWPNyEhLp9wnjfL5o7bsY3QodJCR0stW+dlYpoKrrl4kaM+bQdakZsgzjUZSmdmnFrAdPck0vBqw41UNUXftySRI+XIDz+w== 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=pcvEtMtsfVE4mbdxLoHTcJx79KwtN7C9mFXvM3qbjic=; b=Ki52jBSg5MhJmQZK/QJn4PBvgXbEarHsSxm3FAxj8gZVqe3Hpgn1OEO3t96XK857zvxI7ztq5ABRIDXCyFk+QNqgIQpSHF2vJzEJCSQoSLPa+FVqtTNlwL4DdfizpcHso4Rkm/q79E7vF12Y4KOI1oNOfK0bHfo1Ut7hwfAb+76l+sCTBql131cjzVewsabtNS6T4meyb6/xFVupIweCPdCNZWx7dYYxeNjOf4PEgXbw59aoTLtH5pLLN/phTZll3yLKp+1dPp83KO3LAuQlLuxB9mcHra13crP0XrW8Zu592Lt5gpf3R2VF009XAIE4naiUhXUS/kNzYkjYkseKsA== 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=pcvEtMtsfVE4mbdxLoHTcJx79KwtN7C9mFXvM3qbjic=; b=5J8EXfKZ6ek8ZOshWqV9QE/O8GuswXsFtC95Ty29P+NBAKcN/RclVVlvkNB/Dh8xMVllVxN+KT3/mYYdIUSTAr+Gj49qg5/ABaOu9AolobRoDVPbcRK7RSvgpfgb2BeO8TxtfF3DAvZ6vhhQyZBywiPwecwkLkJep7CNiAa9E3U= Received: from VI1PR08MB4622.eurprd08.prod.outlook.com (2603:10a6:803:bc::17) by VI1PR0801MB1664.eurprd08.prod.outlook.com (2603:10a6:800:59::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.29; Wed, 4 Nov 2020 16:49:36 +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.032; Wed, 4 Nov 2020 16:49:36 +0000 From: Dharmik Thakkar To: "Medvedkin, Vladimir" CC: Bruce Richardson , "dev@dpdk.org" , nd Thread-Topic: [PATCH v4 4/4] test/lpm: avoid code duplication in rcu qsbr perf Thread-Index: AQHWsjAlcUbviuryd0KXPQdqVEFP6qm4HuGAgAARsoA= Date: Wed, 4 Nov 2020 16:49:36 +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> <9cd57800-ee10-f7ca-b003-efa9add973d4@intel.com> In-Reply-To: <9cd57800-ee10-f7ca-b003-efa9add973d4@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: intel.com; dkim=none (message not signed) header.d=none;intel.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: 5a1fd48a-e2e0-4be0-c9ce-08d880e1a22c x-ms-traffictypediagnostic: VI1PR0801MB1664:|DB7PR08MB3164: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:454;OLM:454; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: fCB4kaPdVKny1S6Hli0HZMUO9r26SuPOb7a1JEtC3B68bkbIAynVLCPkh0NLtzoRvKcUYtDbynOqQQbmhle0cM2hQKDwhWCUGTUhawsfXC4ww5O3TtmUZzZ4elpGRtXbx3vrhg1wAGoIaEm0GISHSeCcjxLcUbrwHECkHES/YYwZ37FcjgukPt0dI79bBpCLOXSDgKWiNcFTQL5jYN6cZSbQjV6wW5Vz5/8+QH+9zYZ591K7u6D8Dnix2xmuou6dk3IWI3FSR8LSyRrPAC67CHzGlPEG97cRlMGcc9gTxI/2svq7r5QfLYbchMsaOqvA 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)(366004)(136003)(39860400002)(376002)(346002)(396003)(83380400001)(91956017)(54906003)(478600001)(76116006)(316002)(2616005)(66446008)(66946007)(66476007)(66556008)(33656002)(64756008)(6512007)(5660300002)(2906002)(4326008)(30864003)(6506007)(36756003)(53546011)(8936002)(8676002)(26005)(6486002)(186003)(86362001)(71200400001)(6916009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 9YUg0EzRcNyIc1HGGPfedsxgrm3XKRYXvi3DseIkIyLeRCzNu392F6jTdTpvHpMwCDwb1Rqy4cxMyuyjY2PaDDxDb9zj4TTs1AKnHkgIjpgDDstCutJB5VgisD5oDsw+NBwL/5ziXIBzDqTh1I5n5OCVEACMqwRDVwkH16J5b2bNw2k0kUeyE6DHMIvrg43Qw4biOlMTO8EBNMW8HSihCyhHmfXEmaftzo+DGEmrPjLqFJJDCllbr1r67DMlLys/EZiZ00+bJUVDmrHDPw/2mB5DlJWswMmcKYpJpTioiEoPr09fmLBprB/vGFKiRxaxILTNmgMo0UF6LM18TzAx2nzPsaXz5n+5M6X9dvx/lMWV4YZFSiO2zoILMFk0S9iHeR/DhKff165fGFRB196mqy2myTTVzo+TZ86xmXVPf3tuDg+e9bCWkS4T0C/igHXF2SsidHOmCpiKn9MhyfjwXOwRYgwqsLPNioIzanJxD/ZBCl1rEkVHeZUYZyU9YGcW745edQuJN9dm+UhSCJXXTaDHURLaJoIsUsqwTTOIV6/ZwlZ65TrD4zkjiGyCcxTBvq9cENTx8dFjK3ASFzWW9qg8o1al4mSMRIc7UA5Dt1kq7r3mFx6IfDuDFSyaQ178ufZaJHbrCs5Kq5SagUuPYA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-ID: <88190D8D2B3A3C4CA9827C58EDB86A03@eurprd08.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1664 Original-Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4d22321f-2ac8-4e3e-c45d-08d880e19cec X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oUAs51+SaU4L0gPbaHI+88HDpPPQmpKGcz1rTCFvjjEfJjrBtQI/aMbdsGv74gNmEEpSL3zA0enFJrG2WdSsLOu0bS6iUC4/oUo8vQC/g4LPAMW5p+s5Y04fTipRHVrXzanI+U4JtPF7RgkN7BiIRNwVnOB1dA0wGJhnMLtythNdPLOxKHscKLc7tzQzZp3d5cEVQdY/ETPMWh3hu/GEt9fe/BTqkqgr+t992fynj8tfmOhDmJxZk63MOkT9YYcsNolnL4FNVi6yyoOXruJQ1XKegBXisVpzD5+HoOUzCil/eYZoTCgBDbHam1GbLU3OjC7MYa+nJX6Z3ux/UMNqzLzzKT0ASi187e6j09uFAlwMsh/qemfDJs7mnWrwM2Mq0mdAClrfdC4e5C8F4Hq9gA== 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)(346002)(39860400002)(376002)(136003)(396003)(46966005)(336012)(53546011)(186003)(8936002)(83380400001)(26005)(6486002)(6512007)(6506007)(82310400003)(8676002)(478600001)(82740400003)(2616005)(81166007)(356005)(2906002)(47076004)(33656002)(36756003)(4326008)(30864003)(5660300002)(36906005)(86362001)(54906003)(316002)(6862004)(70206006)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2020 16:49:44.8966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a1fd48a-e2e0-4be0-c9ce-08d880e1a22c 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: AM5EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3164 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" > On Nov 4, 2020, at 9:46 AM, Medvedkin, Vladimir wrote: >=20 > Hi Thakkar, >=20 > On 03/11/2020 22:23, Dharmik Thakkar wrote: >> Avoid code duplication by combining single and multi threaded tests >> Also, enable support for more than 2 writers >> Signed-off-by: Dharmik Thakkar >> Reviewed-by: Ruifeng Wang >> --- >> app/test/test_lpm_perf.c | 359 +++++++++------------------------------ >> 1 file changed, 84 insertions(+), 275 deletions(-) >> 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_cycles; >> +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; >> @@ -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); >> - /* 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 > In this case, given that you are doing > "single_insert =3D NUM_LDEPTH_ROUTE_ENTRIES / j;" > below, the number of ldepth_routes must be a multiple of the number of wr= iters, so some number of routes can be skipped in the opposite case. Consid= er something like: >=20 > number_of_writers =3D j; > ... > si =3D (pos_core * NUM_LDEPTH_ROUTE_ENTRIES)/number_of_writers; > ei =3D ((pos_core + 1 ) * NUM_LDEPTH_ROUTE_ENTRIES)/number_of_writers; >=20 Yes, agreed some routes can be skipped. I will update the patch with the ab= ove changes. Thanks! >=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); >> } >> /* 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); >> } >> } >> @@ -478,22 +479,24 @@ test_lpm_rcu_qsbr_writer(void *arg) >> return 0; >> error: >> - pthread_mutex_unlock(&lpm_mutex); >> + if (!single_writer) >> + pthread_mutex_unlock(&lpm_mutex); >> return -1; >> } >> /* >> * Functional test: >> - * 2 writers, rest are readers >> + * 1/2 writers, rest are readers >> */ >> static int >> -test_lpm_rcu_perf_multi_writer(void) >> +test_lpm_rcu_perf_multi_writer(uint8_t use_rcu) >> { >> struct rte_lpm_config config; >> size_t sz; >> - unsigned int i; >> + unsigned int i, j; >> uint16_t core_id; >> struct rte_lpm_rcu_config rcu_cfg =3D {0}; >> + int (*reader_f)(void *arg) =3D NULL; >> if (rte_lcore_count() < 3) { >> printf("Not enough cores for lpm_rcu_perf_autotest, expecting at leas= t 3\n"); >> @@ -506,273 +509,79 @@ test_lpm_rcu_perf_multi_writer(void) >> num_cores++; >> } >> - printf("\nPerf test: 2 writers, %d readers, RCU integration enabled\n= ", >> - num_cores - 2); >> - >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> - >> - /* Init RCU variable */ >> - sz =3D rte_rcu_qsbr_get_memsize(num_cores); >> - rv =3D (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz, >> - RTE_CACHE_LINE_SIZE); >> - rte_rcu_qsbr_init(rv, num_cores); >> - >> - rcu_cfg.v =3D rv; >> - /* Assign the RCU variable to LPM */ >> - if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) !=3D 0) { >> - printf("RCU variable assignment failed\n"); >> - goto error; >> - } >> - >> - writer_done =3D 0; >> - __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); >> - >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - >> - /* Launch reader threads */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL, >> - enabled_core_ids[i]); >> - >> - /* Launch writer threads */ >> - for (i =3D 0; i < 2; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, >> - (void *)(uintptr_t)i, >> - enabled_core_ids[i]); >> - >> - /* Wait for writer threads */ >> - for (i =3D 0; i < 2; i++) >> - if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) >> - goto error; >> - >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %"PRIu64" cycles\n", >> - __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) >> - / TOTAL_WRITES); >> - >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_wait_lcore(enabled_core_ids[i]); >> - >> - rte_lpm_free(lpm); >> - rte_free(rv); >> - lpm =3D NULL; >> - rv =3D NULL; >> - >> - /* Test without RCU integration */ >> - printf("\nPerf test: 2 writers, %d readers, RCU integration disabled\n= ", >> - num_cores - 2); >> - >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> - >> - writer_done =3D 0; >> - __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - >> - /* Launch reader threads */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_reader, NULL, >> - enabled_core_ids[i]); >> - >> - /* Launch writer threads */ >> - for (i =3D 0; i < 2; i++) >> - rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, >> - (void *)(uintptr_t)i, >> - enabled_core_ids[i]); >> - >> - /* Wait for writer threads */ >> - for (i =3D 0; i < 2; i++) >> - if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) >> - goto error; >> - >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %"PRIu64" cycles\n", >> - __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) >> - / TOTAL_WRITES); >> - >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 2; i < num_cores; i++) >> - rte_eal_wait_lcore(enabled_core_ids[i]); >> - >> - rte_lpm_free(lpm); >> - >> - return 0; >> - >> -error: >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - rte_eal_mp_wait_lcore(); >> - >> - rte_lpm_free(lpm); >> - rte_free(rv); >> - >> - return -1; >> -} >> - >> -/* >> - * Functional test: >> - * Single writer, rest are readers >> - */ >> -static int >> -test_lpm_rcu_perf(void) >> -{ >> - struct rte_lpm_config config; >> - uint64_t begin, total_cycles; >> - size_t sz; >> - unsigned int i, j; >> - uint16_t core_id; >> - uint32_t next_hop_add =3D 0xAA; >> - struct rte_lpm_rcu_config rcu_cfg =3D {0}; >> - >> - if (rte_lcore_count() < 2) { >> - printf("Not enough cores for lpm_rcu_perf_autotest, expecting at leas= t 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; >> - 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; >> - 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); >> - /* Test without RCU integration */ >> - printf("\nPerf test: 1 writer, %d readers, RCU integration disabled\n"= , >> - num_cores); >> - >> - /* Create LPM table */ >> - config.max_rules =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.number_tbl8s =3D NUM_LDEPTH_ROUTE_ENTRIES; >> - config.flags =3D 0; >> - lpm =3D rte_lpm_create(__func__, SOCKET_ID_ANY, &config); >> - TEST_LPM_ASSERT(lpm !=3D NULL); >> + __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> - writer_done =3D 0; >> - __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST); >> + /* Launch reader threads */ >> + for (i =3D j; i < num_cores; i++) >> + rte_eal_remote_launch(reader_f, NULL, >> + enabled_core_ids[i]); >> - /* Launch reader threads */ >> - for (i =3D 0; i < num_cores; i++) >> - rte_eal_remote_launch(test_lpm_reader, NULL, >> - enabled_core_ids[i]); >> + /* Launch writer threads */ >> + for (i =3D 0; i < j; i++) >> + rte_eal_remote_launch(test_lpm_rcu_qsbr_writer, >> + (void *)(uintptr_t)i, >> + enabled_core_ids[i]); >> - /* Measure add/delete. */ >> - begin =3D rte_rdtsc_precise(); >> - for (i =3D 0; i < RCU_ITERATIONS; i++) { >> - /* Add all the entries */ >> - for (j =3D 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++) >> - if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip, >> - large_ldepth_route_table[j].depth, >> - next_hop_add) !=3D 0) { >> - printf("Failed to add iteration %d, route# %d\n", >> - i, j); >> + /* Wait for writer threads */ >> + for (i =3D 0; i < j; i++) >> + if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0) >> goto error; >> - } >> - /* Delete all the entries */ >> - for (j =3D 0; j < NUM_LDEPTH_ROUTE_ENTRIES; j++) >> - if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip, >> - large_ldepth_route_table[j].depth) !=3D 0) { >> - printf("Failed to delete iteration %d, route# %d\n", >> - i, j); >> - goto error; >> - } >> + printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> + printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> + printf("Average LPM Add/Del: %"PRIu64" cycles\n", >> + __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) >> + / TOTAL_WRITES); >> + >> + writer_done =3D 1; >> + /* Wait until all readers have exited */ >> + for (i =3D j; i < num_cores; i++) >> + rte_eal_wait_lcore(enabled_core_ids[i]); >> + >> + rte_lpm_free(lpm); >> + rte_free(rv); >> + lpm =3D NULL; >> + rv =3D NULL; >> } >> - total_cycles =3D rte_rdtsc_precise() - begin; >> - >> - printf("Total LPM Adds: %d\n", TOTAL_WRITES); >> - printf("Total LPM Deletes: %d\n", TOTAL_WRITES); >> - printf("Average LPM Add/Del: %g cycles\n", >> - (double)total_cycles / TOTAL_WRITES); >> - >> - writer_done =3D 1; >> - /* Wait until all readers have exited */ >> - for (i =3D 0; i < num_cores; i++) >> - rte_eal_wait_lcore(enabled_core_ids[i]); >> - >> - rte_lpm_free(lpm); >> return 0; >> @@ -948,10 +757,10 @@ test_lpm_perf(void) >> rte_lpm_delete_all(lpm); >> rte_lpm_free(lpm); >> - if (test_lpm_rcu_perf() < 0) >> + if (test_lpm_rcu_perf_multi_writer(0) < 0) >> return -1; >> - if (test_lpm_rcu_perf_multi_writer() < 0) >> + if (test_lpm_rcu_perf_multi_writer(1) < 0) >> return -1; >> return 0; >=20 > --=20 > Regards, > Vladimir