From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id BC9D5440F0;
	Tue, 28 May 2024 09:54:06 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7F6B3402D2;
	Tue, 28 May 2024 09:54:06 +0200 (CEST)
Received: from EUR01-HE1-obe.outbound.protection.outlook.com
 (mail-he1eur01on2045.outbound.protection.outlook.com [40.107.13.45])
 by mails.dpdk.org (Postfix) with ESMTP id A5AE040150
 for <dev@dpdk.org>; Tue, 28 May 2024 09:54:03 +0200 (CEST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=P8MKp7G+PZwKIomDppjimfaY6ppilRNgMQ3aMgQkoyNoFtcHwFasicAiGfGjpNYJSnQ7S0JVOoVWRlgIqbS+D6u3b1UP3q6Ej5jnIcvxXkmtbAiGXLuSZrJX9SrA/TVa0Wgvyjhg8zc8ZpN0IXULNXgxLaKWxI+Q5FRIwKC/AFYi2Uy40ba9r1KsXIyTYhs+iPy35DnNaCmVPXzr7U7+V4rvkn42P2nksiW6kjhG9JkVTOM+ImPABpy2PfBDUeR0ijjY9fBxT8uZu6n2byrYCX8XqcRO3F4t2Fb3iUGacsYFKnsshAs5ZMP/6S5JeG3Z4gH6OX2ZIVW29nCTTVpHkw==
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=lxoYN/w1Wf1mNBCSYsWXcVWki/+bhaOqjEcnWRhCmME=;
 b=dmLMe/XoFHCZVh2mBDEOlOqDYq5lIIeu29NBoMevC1fRpPpPIQiNQZtZ4dJIHtm1vUEG8sfy4aGr8wrLf1W3kFFsZijj0GCl03BABXEAnJc6ZPOMDW7rfkC51ZTKtA+QPafrBhY60lMAj3Y7vPhjjsnBG09sMm9BiCWSwS/hUbfVNT0uKe1JecGjRCun7pW9NKdaUsXh+l9SQkjzivO5j5yrkbTzr1HeLjQA/aCpTV9pHL34tVyy1lVNUjZO+LyyR/PW5k/ZL7gwKvcGaOYgBmW9bJQBmhNxdXgOQ4+0OB6N0juIhIkSAIgsPHlFGYUitIAHBgz62JNurU7p2YuZoA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 192.176.1.74) smtp.rcpttodomain=dpdk.org 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 (0)
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=lxoYN/w1Wf1mNBCSYsWXcVWki/+bhaOqjEcnWRhCmME=;
 b=RBdXRuTkH1hnt/7ktRAEDQIZn7oda1y1PUQxs9jKaTcgmE1DNrlfqzKxKpXM1eEdYGia2CecXkWAx2/Z85jr18K+Da8IAYHjpSAGGvsnS0NT3ge6koXrMGTeWn58rngAaj3zJ+oCgICMGYzE48uV5n5/KGJ7r+Xz0wcAAaOwYo+GvSWBayVZYFpeAEBGH3U4omXzKs4wX4CDuA1iXQawAxE7Uzsy67i2TjxK8hiTzDos00+2kHmeyUH5IY8zOIHqER9w92VG4r1cDUtKVk+0Uy0fGM+qj3AprY5WvS0Yq0IbjitfOjtWdJxK8WBhiJcUoPvM2KW4JWmksxo4MieAgg==
Received: from AS9PR04CA0077.eurprd04.prod.outlook.com (2603:10a6:20b:48b::13)
 by AS8PR07MB7639.eurprd07.prod.outlook.com (2603:10a6:20b:2ad::14)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Tue, 28 May
 2024 07:54:02 +0000
Received: from AM3PEPF0000A798.eurprd04.prod.outlook.com
 (2603:10a6:20b:48b:cafe::f5) by AS9PR04CA0077.outlook.office365.com
 (2603:10a6:20b:48b::13) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.29 via Frontend
 Transport; Tue, 28 May 2024 07:54:02 +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
 AM3PEPF0000A798.mail.protection.outlook.com (10.167.16.103) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.7633.15 via Frontend Transport; Tue, 28 May 2024 07:54:02 +0000
Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by
 smtp-central.internal.ericsson.com (100.87.178.60) with Microsoft SMTP Server
 id 15.2.1544.11; Tue, 28 May 2024 09:54:01 +0200
Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100])
 by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id
 87F4C1C006A; Tue, 28 May 2024 09:54:01 +0200 (CEST)
From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>
To: <dev@dpdk.org>
CC: <hofors@lysator.liu.se>, =?UTF-8?q?Morten=20Br=C3=B8rup?=
 <mb@smartsharesystems.com>, Stephen Hemminger <stephen@networkplumber.org>,
 =?UTF-8?q?Mattias=20R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>
Subject: [RFC v2] eal: provide option to use compiler memcpy instead of RTE
Date: Tue, 28 May 2024 09:43:54 +0200
Message-ID: <20240528074354.190779-1-mattias.ronnblom@ericsson.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20240527111151.188607-1-mattias.ronnblom@ericsson.com>
References: <20240527111151.188607-1-mattias.ronnblom@ericsson.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: AM3PEPF0000A798:EE_|AS8PR07MB7639:EE_
X-MS-Office365-Filtering-Correlation-Id: aba815f7-3185-4069-204e-08dc7eeb56f4
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
 ARA:13230031|36860700004|376005|82310400017|1800799015; 
X-Microsoft-Antispam-Message-Info: =?utf-8?B?VVRaM3FObW85VEwzV2FjeDZFRVN6ekZGOE5uRUpWc1BhaU1uK25HSFVsTjJj?=
 =?utf-8?B?YlR2SHYrRVN1bDFpTzRMSkl0VlJITDVoc1dmSnhTRXJzdE9FRElXUklsb1ll?=
 =?utf-8?B?Qi9kemlSSDArZ1d5ZUJLUVZmckMzV2UwR09LWWc2Ym0wS0pUV1NFYitteHFX?=
 =?utf-8?B?c0w0MS9Ga1N5REpqeVE3WWdjK1BPSU5DVFd6eHJ2VkdyNEt5bkVWb2NydTI2?=
 =?utf-8?B?R2dqWXM2akczbStDdVozM3EvM005THVmU3RoWXBlU2YyUWlhdDIrcDJQeG9y?=
 =?utf-8?B?WjdzOTlzOFB3SlpHZ2taekdnVmRPR0R1enhJWVpRWnQ0S2swRi8rVW1wc3pa?=
 =?utf-8?B?b2YyUytpQUxjSGJKb3RmV0EyaUtCRGdGajJkQVNINTl0K001djA4My8rdVA5?=
 =?utf-8?B?TWlWVTdJNGVtbHByaGxRTmNpRjhNWEx3aHlOU2krYXp2ZHo0c1JWUkNibUNl?=
 =?utf-8?B?anZZV2FBVTFsSkhTbVk0WnBQdEk4WVQ3WGZmeXB0UldMY3lXN2RNTDFLeXFo?=
 =?utf-8?B?c3JpVS9yOUxwaXMrNzlUajZtUGYxNnJSSGM5dnM4RnhXQVFIcGM1dU9qQnY3?=
 =?utf-8?B?MkNxTHRQSDBJYzhoMCt3c3lRUi9LWENPZmVIOUEzd0VaQmdXMTlQNjBuVXdp?=
 =?utf-8?B?OTlXYXp3UlMvdU5paHpmQitnTzlNTXRpSVJ5YzlNdk5oU2hPRmowWTdrTXFS?=
 =?utf-8?B?WFdOVHRhM3JjenRNU1ZZQnZaRmo5alM2aXAyWkd0NTJ0Zi9iMkQySDJvN0lJ?=
 =?utf-8?B?ckRaWDRXdXoxUjJEaWdSelpzU3V4UmgwcXphM0V5bFRITkd1R2ZVMG5DNGNx?=
 =?utf-8?B?Mno5YXd1cGpuVk13ZUFlcS9RQXRqMUNaNDNLYldlbDhJcXVtN2ZBcENmTUxM?=
 =?utf-8?B?d1QxL0tCbmdMcEtDWm1hZC9VUmdKRExud0RvSERYRW5zaGViOUd3NkJBcitT?=
 =?utf-8?B?NERVMTJObk4vcG5Cb2xZVzBha1ZwQW80QUNad21ySHBSUVhTZlBZVlo2VUFB?=
 =?utf-8?B?bjA1TTd0a2tObTNSbm1IdXRtYjlHNC82ZC91cXhxdldIZVdDQlFDTVo4MzQy?=
 =?utf-8?B?NTFjNXZ1R0E2TUUyaE9Tc3VsQ0tQNW1yQjlrSkNLekgxcUcrMXhxSytYdVgz?=
 =?utf-8?B?SzNqL2xUajdSdUJhb2RTdE5lRHpacm5VVkt2Z1ZFWFRhcHl5QVN1UGk5cmZC?=
 =?utf-8?B?MXBSOVBYTXNzeE9aeWtXSVVrcmFZMU9SeVdBayt6L21XOWYvcWNYVlN0bzV5?=
 =?utf-8?B?cGR3d2NoMXFZVjROWXdkbDBVUnBFKzdWcFQwcjduQS9VR0ZnMUR1V0ZDT010?=
 =?utf-8?B?cUFYd0ExNWRTVkNqKzFWN2pzSFNKZTR2MkZUaVh2dXV5Z1VlVENjeFFncTN4?=
 =?utf-8?B?bU51ek81T0ZBd21aSEdvQmFkTUI0aUhyZFI1V0tmRjIxT3NHTHJnb2t2QU9W?=
 =?utf-8?B?MjVyQ3c3blNGZUZib0loZlowcUk3NFJZK2ZqZlU2R1J2STRWUmFsRWNrWTVl?=
 =?utf-8?B?eVdOYzdMd2lyNUFQMGgzNFprUEZXTENIbWhmb1hnSkg4ZnJXYiszdXdwanVY?=
 =?utf-8?B?Mnc3ZEt3MGhLaVFTd3Y0bk9sNWJNRTRpSnFYWVpuazFmbVpKNTBhUHFlYnI1?=
 =?utf-8?B?T2c1RVlIZmlVazlkeGxSQnF2Y1Y3c1FKNEpOQXYrOUdNbFV3elpROFRKU2Qy?=
 =?utf-8?B?Nm8xLzFvaFMvbXRpWXpTNWZQVVNxWXV2bXIwUEN5dlVJZ0dWSm8vN2ZmdWNP?=
 =?utf-8?B?c0tDT3JUNGd4bVRkbFhlQVNpUmUyNHhFS3dLSmdsY1NYYksyMkVKSW5EaGgv?=
 =?utf-8?B?TEFlYTNldUdSL0luRVhNMUhycmZQMXIvd3RlSUlma3ZtVnpsZEdMU0RFU2JY?=
 =?utf-8?Q?QwuDJSTvJ9Rc8?=
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:(13230031)(36860700004)(376005)(82310400017)(1800799015);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: ericsson.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2024 07:54:02.0396 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: aba815f7-3185-4069-204e-08dc7eeb56f4
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: AM3PEPF0000A798.eurprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7639
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Provide build option to have functions in <rte_memcpy.h> delegate to
the standard compiler/libc memcpy(), instead of using the various
traditional, handcrafted, per-architecture rte_memcpy()
implementations.

A new meson build option 'use_cc_memcpy' is added. The default is
true. It's not obvious what should be the default, but compiler
memcpy() is enabled by default in this RFC so any tests run with this
patch use the new approach.

One purpose of this RFC is to make it easy to evaluate the costs and
benefits of a switch.

Only Loongarch, ARM and x86 is implemented. Only x86 is tested.

RFC v2:
 * Fix bug where rte_memcpy.h was not installed on x86.
 * Made attempt to make Loongarch compile.

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 config/meson.build                     |  1 +
 lib/eal/arm/include/rte_memcpy.h       | 10 +++++
 lib/eal/include/generic/rte_memcpy.h   | 62 +++++++++++++++++++++++---
 lib/eal/loongarch/include/rte_memcpy.h | 52 ++-------------------
 lib/eal/x86/include/meson.build        |  1 +
 lib/eal/x86/include/rte_memcpy.h       | 11 ++++-
 meson_options.txt                      |  2 +
 7 files changed, 82 insertions(+), 57 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 8c8b019c25..456056628e 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -353,6 +353,7 @@ endforeach
 # set other values pulled from the build options
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
+dpdk_conf.set('RTE_USE_CC_MEMCPY', get_option('use_cc_memcpy'))
 dpdk_conf.set('RTE_ENABLE_STDATOMIC', get_option('enable_stdatomic'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
 dpdk_conf.set('RTE_PKTMBUF_HEADROOM', get_option('pkt_mbuf_headroom'))
diff --git a/lib/eal/arm/include/rte_memcpy.h b/lib/eal/arm/include/rte_memcpy.h
index 47dea9a8cc..e8aff722df 100644
--- a/lib/eal/arm/include/rte_memcpy.h
+++ b/lib/eal/arm/include/rte_memcpy.h
@@ -5,10 +5,20 @@
 #ifndef _RTE_MEMCPY_ARM_H_
 #define _RTE_MEMCPY_ARM_H_
 
+#include <rte_config.h>
+
+#ifdef RTE_USE_CC_MEMCPY
+
+#include <generic/rte_memcpy.h>
+
+#else
+
 #ifdef RTE_ARCH_64
 #include <rte_memcpy_64.h>
 #else
 #include <rte_memcpy_32.h>
 #endif
 
+#endif /* RTE_USE_CC_MEMCPY */
+
 #endif /* _RTE_MEMCPY_ARM_H_ */
diff --git a/lib/eal/include/generic/rte_memcpy.h b/lib/eal/include/generic/rte_memcpy.h
index e7f0f8eaa9..f2f66f372d 100644
--- a/lib/eal/include/generic/rte_memcpy.h
+++ b/lib/eal/include/generic/rte_memcpy.h
@@ -5,12 +5,20 @@
 #ifndef _RTE_MEMCPY_H_
 #define _RTE_MEMCPY_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  * @file
  *
  * Functions for vectorised implementation of memcpy().
  */
 
+#include <stdint.h>
+#include <string.h>
+#include <rte_vect.h>
+
 /**
  * Copy 16 bytes from one location to another using optimised
  * instructions. The locations should not overlap.
@@ -35,8 +43,6 @@ rte_mov16(uint8_t *dst, const uint8_t *src);
 static inline void
 rte_mov32(uint8_t *dst, const uint8_t *src);
 
-#ifdef __DOXYGEN__
-
 /**
  * Copy 48 bytes from one location to another using optimised
  * instructions. The locations should not overlap.
@@ -49,8 +55,6 @@ rte_mov32(uint8_t *dst, const uint8_t *src);
 static inline void
 rte_mov48(uint8_t *dst, const uint8_t *src);
 
-#endif /* __DOXYGEN__ */
-
 /**
  * Copy 64 bytes from one location to another using optimised
  * instructions. The locations should not overlap.
@@ -87,8 +91,6 @@ rte_mov128(uint8_t *dst, const uint8_t *src);
 static inline void
 rte_mov256(uint8_t *dst, const uint8_t *src);
 
-#ifdef __DOXYGEN__
-
 /**
  * Copy bytes from one location to another. The locations must not overlap.
  *
@@ -111,6 +113,52 @@ rte_mov256(uint8_t *dst, const uint8_t *src);
 static void *
 rte_memcpy(void *dst, const void *src, size_t n);
 
-#endif /* __DOXYGEN__ */
+#ifdef RTE_USE_CC_MEMCPY
+static inline void
+rte_mov16(uint8_t *dst, const uint8_t *src)
+{
+	memcpy(dst, src, 16);
+}
+
+static inline void
+rte_mov32(uint8_t *dst, const uint8_t *src)
+{
+	memcpy(dst, src, 32);
+}
+
+static inline void
+rte_mov48(uint8_t *dst, const uint8_t *src)
+{
+	memcpy(dst, src, 48);
+}
+
+static inline void
+rte_mov64(uint8_t *dst, const uint8_t *src)
+{
+	memcpy(dst, src, 64);
+}
+
+static inline void
+rte_mov128(uint8_t *dst, const uint8_t *src)
+{
+	memcpy(dst, src, 128);
+}
+
+static inline void
+rte_mov256(uint8_t *dst, const uint8_t *src)
+{
+	memcpy(dst, src, 256);
+}
+
+static inline void *
+rte_memcpy(void *dst, const void *src, size_t n)
+{
+	return memcpy(dst, src, n);
+}
+#endif /* RTE_USE_CC_MEMCPY */
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _RTE_MEMCPY_H_ */
diff --git a/lib/eal/loongarch/include/rte_memcpy.h b/lib/eal/loongarch/include/rte_memcpy.h
index 22578d40f4..159420d3b7 100644
--- a/lib/eal/loongarch/include/rte_memcpy.h
+++ b/lib/eal/loongarch/include/rte_memcpy.h
@@ -5,57 +5,11 @@
 #ifndef RTE_MEMCPY_LOONGARCH_H
 #define RTE_MEMCPY_LOONGARCH_H
 
-#include <stdint.h>
-#include <string.h>
+#include "rte_config.h"
 
-#include "rte_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef RTE_USE_CC_MEMCPY
+#define RTE_USE_CC_MEMCPY
 
 #include "generic/rte_memcpy.h"
 
-static inline void
-rte_mov16(uint8_t *dst, const uint8_t *src)
-{
-	memcpy(dst, src, 16);
-}
-
-static inline void
-rte_mov32(uint8_t *dst, const uint8_t *src)
-{
-	memcpy(dst, src, 32);
-}
-
-static inline void
-rte_mov48(uint8_t *dst, const uint8_t *src)
-{
-	memcpy(dst, src, 48);
-}
-
-static inline void
-rte_mov64(uint8_t *dst, const uint8_t *src)
-{
-	memcpy(dst, src, 64);
-}
-
-static inline void
-rte_mov128(uint8_t *dst, const uint8_t *src)
-{
-	memcpy(dst, src, 128);
-}
-
-static inline void
-rte_mov256(uint8_t *dst, const uint8_t *src)
-{
-	memcpy(dst, src, 256);
-}
-
-#define rte_memcpy(d, s, n)	memcpy((d), (s), (n))
-
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* RTE_MEMCPY_LOONGARCH_H */
diff --git a/lib/eal/x86/include/meson.build b/lib/eal/x86/include/meson.build
index 52d2f8e969..09c2fe2485 100644
--- a/lib/eal/x86/include/meson.build
+++ b/lib/eal/x86/include/meson.build
@@ -16,6 +16,7 @@ arch_headers = files(
         'rte_spinlock.h',
         'rte_vect.h',
 )
+
 arch_indirect_headers = files(
         'rte_atomic_32.h',
         'rte_atomic_64.h',
diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
index 72a92290e0..c5ba74d2ed 100644
--- a/lib/eal/x86/include/rte_memcpy.h
+++ b/lib/eal/x86/include/rte_memcpy.h
@@ -11,12 +11,19 @@
  * Functions for SSE/AVX/AVX2/AVX512 implementation of memcpy().
  */
 
+#include <rte_config.h>
+
+#ifdef RTE_USE_CC_MEMCPY
+
+#include <generic/rte_memcpy.h>
+
+#else
+
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>
 #include <rte_vect.h>
 #include <rte_common.h>
-#include <rte_config.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -878,4 +885,6 @@ rte_memcpy(void *dst, const void *src, size_t n)
 }
 #endif
 
+#endif /* RTE_USE_CC_MEMCPY */
+
 #endif /* _RTE_MEMCPY_X86_64_H_ */
diff --git a/meson_options.txt b/meson_options.txt
index e49b2fc089..263b0e7882 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -60,3 +60,5 @@ option('tests', type: 'boolean', value: true, description:
        'build unit tests')
 option('use_hpet', type: 'boolean', value: false, description:
        'use HPET timer in EAL')
+option('use_cc_memcpy', type: 'boolean', value: true, description:
+       'Have rte_memcpy() delegate to compiler/libc memcpy() instead of using custom implementation.')
-- 
2.34.1