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 D394743BF3; Sun, 3 Mar 2024 17:05:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A4FE24068E; Sun, 3 Mar 2024 17:05:56 +0100 (CET) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mails.dpdk.org (Postfix) with ESMTP id A154C402D1 for ; Sun, 3 Mar 2024 17:05:55 +0100 (CET) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6e4d48a5823so2955182b3a.1 for ; Sun, 03 Mar 2024 08:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709481955; x=1710086755; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=HojnvQ2keez11AzwY+J4rmLU+Raj1XjRjq5uC9qV+2Q=; b=fWlXJaqB8ZvQ9W/jmKVnnbVXhHI1OGt5sIM9BkmyNs9Of0Obh2WVI2q2cShGiVLwya XP/eF+jzwZi8BOqhhv0WU4HW5RMh8twEK+yr+r9bm+w4/l/pGm08cfwzFOtuhOTGDIPO c1YXMQ81Z7eSsJ7xg5T6S/H+0VmMuADmsA93aWzrkLSqYjAri2d4I3rAcEc7TYkZez0Q niQN6C1d63fzGMYDDDgPFYHMklnLyyzxbW9od3fMDONQsT7ypUDCciTVGK412emw3EIX gEHSy49v4vMEY6sYigiFJeIzar6R2TsAreZ2/mZRNfuAugnNY0ss6rUbudNnh7ifytLi 9QNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709481955; x=1710086755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HojnvQ2keez11AzwY+J4rmLU+Raj1XjRjq5uC9qV+2Q=; b=c8mMV+KG+jyoBXtqr80QSG8ixnuTC+RufVx6YJCLx1iEPI2oL/xr5evXve8UwdeUYQ 6zirDlqcLysQ/BUYVMAKA6DK8/tSzxSffblwr1nO/gUEhf13e3DaBUtpefYfZMdZRE6U oWU5rIZQZWL0UkBJSUSs6Jo0Kut29x8d+BUErmKRAWj0BlyH1L68zzewpTripUv/oq56 u+zkKNZxzEWxbpLmG6Kb/zIK2Dr0e13jCLj5tmbv2PMaGU5dxhXtOEKqF+WZlaQUhSY4 JKjkmaZ+wTTmXmGuFQ46wZoiWUnWm7sfferNAPYs/6UGYBk9FRSTrrN9GqAukwCdMqGC fEiw== X-Forwarded-Encrypted: i=1; AJvYcCX41W8PpMx3of5AIQzrjH2tUd8+if1sXXn8NR1qxNnKZCyzcFdoShbEkx7S/H7tRiUMiOH9sueBS0XYXBY= X-Gm-Message-State: AOJu0Yy4ANAp4/ZBVkQuyQft/T4mwynuPUuCSRbpVc16rg/31Lnq27Cz ABTzB9xe3RFLKss/evGTWgI3gUZgaerBLj313WgCDIHDTED9/Yll2zD0LwV5dvs= X-Google-Smtp-Source: AGHT+IFYTN9dwEZaW04k9WWm57sRK1JZHeozcV6R7gLaB/frccDYPauc3z4x5aWvns7X3wjwXqtDYA== X-Received: by 2002:a05:6a00:92a6:b0:6e5:9a69:807 with SMTP id jw38-20020a056a0092a600b006e59a690807mr6651983pfb.6.1709481954685; Sun, 03 Mar 2024 08:05:54 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id w15-20020aa7858f000000b006e572d86152sm5971749pfn.91.2024.03.03.08.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 08:05:54 -0800 (PST) Date: Sun, 3 Mar 2024 08:05:52 -0800 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: bruce.richardson@intel.com, konstantin.v.ananyev@yandex.ru, mattias.ronnblom@ericsson.com, dev@dpdk.org Subject: Re: [PATCH] eal/x86: improve rte_memcpy const size 16 performance Message-ID: <20240303080552.1ac016b5@hermes.local> In-Reply-To: <20240302234812.9137-1-mb@smartsharesystems.com> References: <20240302234812.9137-1-mb@smartsharesystems.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Another option would be to just do what PPC already does. The ENA part is because it has some garbage trying to use memcpy always (which is one of those bad ideas). =46rom 74e7ab929e61e0481f6e0214d4d06a716b2f7d79 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sun, 3 Mar 2024 08:02:07 -0800 Subject: [PATCH] rte_memcpy: use builtin memcpy for fixed sizes This makes x86 arch do same thing as PPC, and also allows code checkers to see memcpy issues. It shows a pre-existing bug in ipsec test now. Signed-off-by: Stephen Hemminger --- drivers/net/ena/base/ena_plat_dpdk.h | 9 +----- lib/eal/x86/include/rte_memcpy.h | 45 +++++++++++++++------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/en= a_plat_dpdk.h index 14bf582a451f..997e6aa3dfbd 100644 --- a/drivers/net/ena/base/ena_plat_dpdk.h +++ b/drivers/net/ena/base/ena_plat_dpdk.h @@ -70,14 +70,7 @@ typedef uint64_t dma_addr_t; #define ENA_UDELAY(x) rte_delay_us_block(x) =20 #define ENA_TOUCH(x) ((void)(x)) -/* Redefine memcpy with caution: rte_memcpy can be simply aliased to memcp= y, so - * make the redefinition only if it's safe (and beneficial) to do so. - */ -#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64_MEMCPY) || \ - defined(RTE_ARCH_ARM_NEON_MEMCPY) -#undef memcpy -#define memcpy rte_memcpy -#endif + #define wmb rte_wmb #define rmb rte_rmb #define mb rte_mb diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_mem= cpy.h index 72a92290e05d..aab30be0eeb9 100644 --- a/lib/eal/x86/include/rte_memcpy.h +++ b/lib/eal/x86/include/rte_memcpy.h @@ -27,24 +27,6 @@ extern "C" { #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif =20 -/** - * Copy bytes from one location to another. The locations must not overlap. - * - * @note This is implemented as a macro, so it's address should not be tak= en - * and care is needed as parameter expressions may be evaluated multiple t= imes. - * - * @param dst - * Pointer to the destination of the data. - * @param src - * Pointer to the source data. - * @param n - * Number of bytes to copy. - * @return - * Pointer to the destination data. - */ -static __rte_always_inline void * -rte_memcpy(void *dst, const void *src, size_t n); - /** * Copy bytes from one location to another, * locations should not overlap. @@ -859,8 +841,8 @@ rte_memcpy_aligned(void *dst, const void *src, size_t n) return ret; } =20 -static __rte_always_inline void * -rte_memcpy(void *dst, const void *src, size_t n) +static inline void * +rte_memcpy_func(void *dst, const void *src, size_t n) { if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK)) return rte_memcpy_aligned(dst, src, n); @@ -868,6 +850,29 @@ rte_memcpy(void *dst, const void *src, size_t n) return rte_memcpy_generic(dst, src, n); } =20 + +/** + * Copy bytes from one location to another. The locations must not overlap. + * + * @note This is implemented as a macro, so it's address should not be tak= en + * and care is needed as parameter expressions may be evaluated multiple t= imes. + * + * @param dst + * Pointer to the destination of the data. + * @param src + * Pointer to the source data. + * @param n + * Number of bytes to copy. + * @return + * Pointer to the destination data. + */ +#define rte_memcpy(dst, src, n) \ + __extension__ ({ \ + (__builtin_constant_p(n)) ? \ + memcpy((dst), (src), (n)) : \ + rte_memcpy_func((dst), (src), (n)); }) + + #undef ALIGNMENT_MASK =20 #if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >=3D 100000) --=20 2.43.0