From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB252606A329 for ; Tue, 1 Dec 2026 15:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=S/hM9+Fj Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E833406B7; Tue, 1 Dec 2026 16:16:56 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mails.dpdk.org (Postfix) with ESMTPS id D90F740678 for ; Tue, 1 Dec 2026 16:16:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796138212; x=1827674212; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZWXlZtieZlKSIF1agjOJaEwEwhz3KUX8zzfWG8Z0yqU=; b=S/hM9+Fjx/Kho8UUw261by65mnbK5ZNFnYrF+G+oqS+BKrmhblfDs6kl OTTm4tkrpcp+QUpBAwivZ66Jt8ceiGqREgzP+HXzFvb63fMy+ZjgiZG+2 efEs7ol/NxpFDvAnGBMFampofENcFmd0VsuW186dQXkfbZt/AFKqvApqm GmS9h49J4uvWtHutBa6x+alO7WFeej2fByE0xbc70PT0DyjPCkd23Aq5P B9yDMq4MPCWLqejO6k6pUXzlJjcW1MUbi9uZ/zkKHOcV2MKZMguvV+BVr ghPgG+1qYmJreHKMgtCjO9sn/oBZvr+rL6u1Ta9HYxVffMKIDbcFFFV2H g==; X-CSE-ConnectionGUID: kkYVSkgARB24rSUp+/AZgQ== X-CSE-MsgGUID: kUU4N0q5SpaOPnqWOigoVQ== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5023500" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="5023500" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 07:16:51 -0800 X-CSE-ConnectionGUID: q8gdy8bNT6aIPOXPqCT9uQ== X-CSE-MsgGUID: DTP9hZhtQM2mCW29C8r0/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13749417" Received: from silpixa00401385.ir.intel.com ([10.20.224.226]) by fmviesa001.fm.intel.com with ESMTP; 01 Dec 2026 07:16:49 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH 09/11] test/thash: add perf tests for new RSS functions Date: Tue, 1 Dec 2026 15:16:21 +0000 Message-ID: <20261201151623.2240031-10-bruce.richardson@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261201151623.2240031-1-bruce.richardson@intel.com> References: <20261201151623.2240031-1-bruce.richardson@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Add performance tests for the RSS calculation functions for L3/L4 keys. For each look at l3, l3+contiguous l4, and l3+split l4. Signed-off-by: Bruce Richardson --- app/test/test_thash_perf.c | 97 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/app/test/test_thash_perf.c b/app/test/test_thash_perf.c index 9d391fd296..44bda932c7 100644 --- a/app/test/test_thash_perf.c +++ b/app/test/test_thash_perf.c @@ -3,8 +3,10 @@ */ #include +#include #include #include +#include #include #include @@ -12,12 +14,14 @@ #include #include #include +#include #include #include "test.h" #define ITERATIONS (1 << 15) #define BATCH_SZ (1 << 10) +#define RSS_ITERATIONS (1 << 12) #define IPV4_2_TUPLE_LEN (8) #define IPV4_4_TUPLE_LEN (12) @@ -86,6 +90,66 @@ run_rss_calc_bulk(uint32_t *tuples[BATCH_SZ], int len, const void *key) return end_tsc - start_tsc; } +#define RUN_PACKET_BENCH(label, call) do { \ + volatile uint32_t accumulated = 0; \ + const uint64_t start = rte_rdtsc_precise(); \ + for (unsigned int i = 0; i < RSS_ITERATIONS; i++) { \ + for (unsigned int j = 0; j < BATCH_SZ; j++) { \ + uint32_t hash; \ + if ((call) != 0) \ + return -1; \ + accumulated ^= hash; \ + } \ + } \ + const uint64_t elapsed = rte_rdtsc_precise() - start; \ + printf("Average %-32s %.1f cycles (%s)\n", label, \ + (double)elapsed / (RSS_ITERATIONS * BATCH_SZ), mode); \ + RTE_SET_USED(accumulated); \ +} while (0) + +static int +run_rss_packet_perf(const struct rte_thash_rss_ctx *ctx, const char *mode) +{ + static struct { + struct rte_ipv4_hdr ip; + uint8_t ports[4]; + } v4[BATCH_SZ]; + static struct { + struct rte_ipv6_hdr ip; + uint8_t ports[4]; + } v6[BATCH_SZ]; + static uint8_t split_ports[BATCH_SZ][4]; + + for (unsigned int i = 0; i < BATCH_SZ; i++) { + const uint32_t ports = rte_rand(); + + v4[i].ip.src_addr = rte_rand(); + v4[i].ip.dst_addr = rte_rand(); + for (unsigned int byte = 0; byte < sizeof(v6[i].ip.src_addr); byte++) { + v6[i].ip.src_addr.a[byte] = rte_rand(); + v6[i].ip.dst_addr.a[byte] = rte_rand(); + } + memcpy(v4[i].ports, &ports, sizeof(ports)); + memcpy(v6[i].ports, &ports, sizeof(ports)); + memcpy(split_ports[i], &ports, sizeof(ports)); + } + + printf("\nRSS packet hash (%s):\n", mode); + RUN_PACKET_BENCH("rte_thash_rss_ipv4_l3", rte_thash_rss_ipv4_l3(ctx, &v4[j].ip, &hash)); + RUN_PACKET_BENCH("rte_thash_rss_ipv4_l4 direct", + rte_thash_rss_ipv4_l4(ctx, &v4[j].ip, v4[j].ports, &hash)); + RUN_PACKET_BENCH("rte_thash_rss_ipv4_l4 split", + rte_thash_rss_ipv4_l4(ctx, &v4[j].ip, split_ports[j], &hash)); + RUN_PACKET_BENCH("rte_thash_rss_ipv6_l3", rte_thash_rss_ipv6_l3(ctx, &v6[j].ip, &hash)); + RUN_PACKET_BENCH("rte_thash_rss_ipv6_l4 direct", + rte_thash_rss_ipv6_l4(ctx, &v6[j].ip, v6[j].ports, &hash)); + RUN_PACKET_BENCH("rte_thash_rss_ipv6_l4 split", + rte_thash_rss_ipv6_l4(ctx, &v6[j].ip, split_ports[j], &hash)); + + return 0; +} +#undef RUN_PACKET_BENCH + static void run_thash_test(unsigned int tuple_len) { @@ -137,7 +201,7 @@ run_thash_test(unsigned int tuple_len) static void enable_gfni_simd_bitwidth(void) { -#ifdef RTE_THASH_GFNI_DEFINED +#ifdef RTE_ARCH_X86 const uint16_t cur = rte_vect_get_max_simd_bitwidth(); if (cur >= RTE_VECT_SIMD_512) @@ -151,7 +215,8 @@ enable_gfni_simd_bitwidth(void) const int ret = rte_vect_set_max_simd_bitwidth(RTE_VECT_SIMD_512); if (ret != 0) { - printf("WARNING: CPU supports GFNI, but max SIMD bitwidth is pinned at %u, so GFNI is not benchmarked\n", + printf("WARNING: CPU supports GFNI, but max SIMD bitwidth is pinned at %u, " + "so GFNI is not benchmarked\n", cur); return; } @@ -164,14 +229,40 @@ enable_gfni_simd_bitwidth(void) static int test_thash_perf(void) { + const uint16_t original_bitwidth = rte_vect_get_max_simd_bitwidth(); + const bool scalar_selected = + rte_vect_set_max_simd_bitwidth(RTE_VECT_SIMD_DISABLED) == 0; + struct rte_thash_rss_ctx *scalar = rte_thash_rss_ctx_create(default_rss_key, + sizeof(default_rss_key), 0); + struct rte_thash_rss_ctx *simd = NULL; + int ret; + + if (scalar_selected) + rte_vect_set_max_simd_bitwidth(original_bitwidth); + if (scalar == NULL) + return -1; + enable_gfni_simd_bitwidth(); + if (scalar_selected && rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) { + simd = rte_thash_rss_ctx_create(default_rss_key, sizeof(default_rss_key), 0); + if (simd == NULL) { + rte_thash_rss_ctx_free(scalar); + return -1; + } + } run_thash_test(IPV4_2_TUPLE_LEN); run_thash_test(IPV4_4_TUPLE_LEN); run_thash_test(IPV6_2_TUPLE_LEN); run_thash_test(IPV6_4_TUPLE_LEN); - return 0; + ret = run_rss_packet_perf(scalar, scalar_selected ? "scalar" : "configured SIMD"); + if (ret == 0 && simd != NULL) + ret = run_rss_packet_perf(simd, "512-bit limit"); + rte_thash_rss_ctx_free(scalar); + rte_thash_rss_ctx_free(simd); + + return ret; } REGISTER_PERF_TEST(thash_perf_autotest, test_thash_perf); -- 2.55.0