From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0CC59A00C4 for ; Mon, 11 Jul 2022 14:14:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 08D1241614; Mon, 11 Jul 2022 14:14:58 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150080.outbound.protection.outlook.com [40.107.15.80]) by mails.dpdk.org (Postfix) with ESMTP id 05C71410DD; Mon, 11 Jul 2022 14:14:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NQ7mH6DUD75XPAFGvG69n+TYS6U4v1MQHyhB6SDusnVuzVaERyUluCnJIapVeo2yqxIs+FudJdz4iHeM6jxGynqbRy/REO3cV46GY7/cq9TEtqLQbE51xqpAxJCgkqMWZs9Egj6USD2NPMz5t/C+TdiPXGzFEz4YyTkxIyXUYsdZmETpCvFrSr8NyEem39FzPwivCi4QKTMb5xP/F980XyfIzSTlowIuRGaBoyf+dxTIhyigPcVa7BdCpVUj7cKdqyOxOEA9PCOcdW1M44LkTfEM7q9y0fejZ90rZOc+6Wajbco/mCoI0H2ABhdyg6F3qX8bgBCFCpfAXR0O6Aj/Zw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EBBa4grGwq109fNyAN0RlDvQIUbr4QF0wGD5HH8NdrI=; b=eqbIs8qwTWKdVi/ajEJdiiugMluf3kaQGNsnxplBKKbihVY+T/vZ43C6HoT9do4oTDE75O05bwWfHnR5in5hOkB6+rI6a8jCCCAZjKk6qOBAh2uiStiddHGmZaHghRmGhum0h79Mz++vb4YDy9T91NDqhtzerSAt1mG3iQdVvRSdOra3lk0ftfEeivvkj+CTtwy3sWhUcZTleTZ0heYjro6IFdAuh0tbi1+LnVfEQo0uMpeYq9zzedqTsKRIw6ecTdeJdl4Vyb+xVSpfKXrkaqAwNxk/7cfB64nZurTKPmR7ORPRFV/B0YeIvPH8Bw12K8FteNfMXfbuFNXdYnpOqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=6wind.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EBBa4grGwq109fNyAN0RlDvQIUbr4QF0wGD5HH8NdrI=; b=b0aEa/mXiY+UvfWFrcrcjvgvOyXkcUZ3lV3J4UG6lT+ulmbkVfuVkljQmpMQsBxUHSIuw/0WaECD304AIfSFrhg/WOllRFoca+Whh5QLXrdQ8wul+QKi9DPcNRwrlMIvMAXbr8dYAfY8dYgfjqnw3/ZQR2rr1y1tt/Zvh+EycKY= Received: from FR0P281CA0087.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::12) by AM6PR07MB4807.eurprd07.prod.outlook.com (2603:10a6:20b:3d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.12; Mon, 11 Jul 2022 12:14:55 +0000 Received: from VE1EUR02FT046.eop-EUR02.prod.protection.outlook.com (2603:10a6:d10:1e:cafe::7b) by FR0P281CA0087.outlook.office365.com (2603:10a6:d10:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.11 via Frontend Transport; Mon, 11 Jul 2022 12:14:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by VE1EUR02FT046.mail.protection.outlook.com (10.152.12.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.5417.15 via Frontend Transport; Mon, 11 Jul 2022 12:14:54 +0000 Received: from ESESBMB504.ericsson.se (153.88.183.171) by ESESBMR505.ericsson.se (153.88.183.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.28; Mon, 11 Jul 2022 14:14:22 +0200 Received: from ESESSMB504.ericsson.se (153.88.183.165) by ESESBMB504.ericsson.se (153.88.183.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.28; Mon, 11 Jul 2022 14:14:21 +0200 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.192) with Microsoft SMTP Server id 15.1.2375.28 via Frontend Transport; Mon, 11 Jul 2022 14:14:21 +0200 Received: from localhost.localdomain (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 0D78B1C0060; Mon, 11 Jul 2022 14:14:22 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: Emil Berg , , , , , , , =?UTF-8?q?Morten=20Br=C3=B8rup?= , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v3 1/2] app/test: add cksum performance test Date: Mon, 11 Jul 2022 14:11:31 +0200 Message-ID: <20220711121132.34546-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afc2e760-7855-48b6-86e2-08da6336f6d9 X-MS-TrafficTypeDiagnostic: AM6PR07MB4807:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cfvR2U54lY21AQXhtTrQ1vmGYEF+vddmq5qFWb6UXw4wzKrgo/svv7Wp1HiCXwRU0oYmGYY6HkiQBTuBJjUok42Ctx1a+vW41VZBnXY0oJfkznHR+7J9Jud5rStedWEpkhD7FV7S+8yaETH2yjnoYeB48iVXKlM3hQ6cYdcMWUjF/LCGLmVK/xY6MgkH42YURsl0uhieqoVTrbDGo3lQ3+cakOIUHKSkgX+1IWHeN0kcmaY5TWmVLOG1yJkC9e0kn24v1Md45R/oo+q7Rg5Gmxey4dkZeKdo+Xqqlljjvqfr+/VWAPu/Ex8na7/yQ2J3WcYXNJKFX7t2GoRwqFaWVGG6sqBKcY94XKr8I/BTIcTJQXcmfG+HjjKoBdBT16X8RrtS1ISvPgs95lOCJQdinhmBci0xibGWPgIn6xovwUuRfgAXLY1+4gJ2/llMbZLYy2k9nzT2WSSEKR8YEV8aPdiqEwcS03+ae0KPqqixpdgxAdVrDESZ53Jf5BOGnq6GJ9obGhdZkCK4lKMq2msRS/K6seTYKX7CzQMSbLj1NaEgJ7CkLvKadid6b5wWZvYV89HCL0rHoXv49w0+IvSthfQSgzoPwurarXT/v0aMF8DNca9+ys47K4fqvidIXY/9oBvMR60HK7LvvIvZtF5EX7eOkukYpo0Zpaqe8VIbcwnhJrPAJe9n+DBTWy3nkeEXHUVoFklbBHY1UPAQRYhQjJ6BEumZ8w1PA2zM3Cm9nK+BD3Ba0G4vQ09olKctnCDutYaGmFy3k1v0mL7LAFFRxphaLZ5uhSaH4IVUcLYQEEaSZ7ks+xufJ7Z7lq1DTfYS X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(376002)(136003)(346002)(396003)(40470700004)(36840700001)(46966006)(6666004)(316002)(356005)(478600001)(1076003)(70206006)(4326008)(41300700001)(26005)(107886003)(2616005)(40140700001)(5660300002)(82310400005)(8936002)(6266002)(2906002)(40480700001)(47076005)(83380400001)(70586007)(86362001)(40460700003)(7636003)(36860700001)(6916009)(82960400001)(82740400003)(336012)(8676002)(54906003)(186003)(66574015)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2022 12:14:54.6400 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afc2e760-7855-48b6-86e2-08da6336f6d9 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT046.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR07MB4807 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Add performance test for the rte_raw_cksum() function, which delegates the actual work to __rte_raw_cksum(), which in turn is used by other functions in need of Internet checksum calculation. Signed-off-by: Mattias Rönnblom --- v3: * Changed init function buffer parameter type, to avoid cast. * Code formatting improved. v2: * Added __rte_unused to unused volatile variable, to keep the Intel compiler happy. --- MAINTAINERS | 1 + app/test/meson.build | 1 + app/test/test_cksum_perf.c | 117 +++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 app/test/test_cksum_perf.c diff --git a/MAINTAINERS b/MAINTAINERS index c923712946..2a4c99e05a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1414,6 +1414,7 @@ Network headers M: Olivier Matz F: lib/net/ F: app/test/test_cksum.c +F: app/test/test_cksum_perf.c Packet CRC M: Jasvinder Singh diff --git a/app/test/meson.build b/app/test/meson.build index 431c5bd318..191db03d1d 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -18,6 +18,7 @@ test_sources = files( 'test_bpf.c', 'test_byteorder.c', 'test_cksum.c', + 'test_cksum_perf.c', 'test_cmdline.c', 'test_cmdline_cirbuf.c', 'test_cmdline_etheraddr.c', diff --git a/app/test/test_cksum_perf.c b/app/test/test_cksum_perf.c new file mode 100644 index 0000000000..1f296cae34 --- /dev/null +++ b/app/test/test_cksum_perf.c @@ -0,0 +1,117 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Ericsson AB + */ + +#include + +#include +#include +#include +#include +#include + +#include "test.h" + +#define NUM_BLOCKS 10 +#define ITERATIONS 1000000 + +static const size_t data_sizes[] = { 20, 21, 100, 101, 1500, 1501 }; + +static __rte_noinline uint16_t +do_rte_raw_cksum(const void *buf, size_t len) +{ + return rte_raw_cksum(buf, len); +} + +static void +init_block(char *buf, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + buf[i] = (char)rte_rand(); +} + +static int +test_cksum_perf_size_alignment(size_t block_size, bool aligned) +{ + char *data[NUM_BLOCKS]; + char *blocks[NUM_BLOCKS]; + unsigned int i; + uint64_t start; + uint64_t end; + /* Floating point to handle low (pseudo-)TSC frequencies */ + double block_latency; + double byte_latency; + volatile __rte_unused uint64_t sum = 0; + + for (i = 0; i < NUM_BLOCKS; i++) { + data[i] = rte_malloc(NULL, block_size + 1, 0); + + if (data[i] == NULL) { + printf("Failed to allocate memory for block\n"); + return TEST_FAILED; + } + + init_block(data[i], block_size + 1); + + blocks[i] = aligned ? data[i] : data[i] + 1; + } + + start = rte_rdtsc(); + + for (i = 0; i < ITERATIONS; i++) { + unsigned int j; + for (j = 0; j < NUM_BLOCKS; j++) + sum += do_rte_raw_cksum(blocks[j], block_size); + } + + end = rte_rdtsc(); + + block_latency = (end - start) / (double)(ITERATIONS * NUM_BLOCKS); + byte_latency = block_latency / block_size; + + printf("%-9s %10zd %19.1f %16.2f\n", aligned ? "Aligned" : "Unaligned", + block_size, block_latency, byte_latency); + + for (i = 0; i < NUM_BLOCKS; i++) + rte_free(data[i]); + + return TEST_SUCCESS; +} + +static int +test_cksum_perf_size(size_t block_size) +{ + int rc; + + rc = test_cksum_perf_size_alignment(block_size, true); + if (rc != TEST_SUCCESS) + return rc; + + rc = test_cksum_perf_size_alignment(block_size, false); + + return rc; +} + +static int +test_cksum_perf(void) +{ + uint16_t i; + + printf("### rte_raw_cksum() performance ###\n"); + printf("Alignment Block size TSC cycles/block TSC cycles/byte\n"); + + for (i = 0; i < RTE_DIM(data_sizes); i++) { + int rc; + + rc = test_cksum_perf_size(data_sizes[i]); + if (rc != TEST_SUCCESS) + return rc; + } + + return TEST_SUCCESS; +} + + +REGISTER_TEST_COMMAND(cksum_perf_autotest, test_cksum_perf); -- 2.25.1