From c60266d1ea9604f4651092d79bed8ec0b571544a Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Wed, 17 Jan 2024 12:00:16 +0000 Subject: [PATCH] memif: use VPP cacheline size for memif when compiling within VPP Type: make memif.h file is independent code which can be used outside of VPP. Hence it uses its own cacheline size MACRO. This patch sets the value of MEMIF_CACHELINE_SIZE in the cmake file for memif plugin to VPP_CACHE_LINE_SIZE. Signed-off-by: Mohsin Kazmi Change-Id: I8185e78897f4571f1a0430dd7e758816e127444c --- extras/libmemif/CMakeLists.txt | 11 +++++++++++ extras/libmemif/src/CMakeLists.txt | 1 + src/plugins/memif/CMakeLists.txt | 2 ++ 3 files changed, 14 insertions(+) diff --git a/extras/libmemif/CMakeLists.txt b/extras/libmemif/CMakeLists.txt index 8f057e98f3a..1526abdce3a 100644 --- a/extras/libmemif/CMakeLists.txt +++ b/extras/libmemif/CMakeLists.txt @@ -61,6 +61,17 @@ set(CMAKE_INSTALL_MESSAGE NEVER) find_package(Threads REQUIRED) include_directories(${CMAKE_THREADS_INCLUDE_DIRS}) +if(DEFINED LIBMEMIF_CACHELINE_SIZE) + # Cache line size assigned via cmake args +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)") + set(LIBMEMIF_CACHELINE_SIZE 128) +else() + set(LIBMEMIF_CACHELINE_SIZE 64) +endif() + +message(STATUS "System Architecture: ${CMAKE_SYSTEM_PROCESSOR}") +message(STATUS "Libmemif Cacheline Size: ${LIBMEMIF_CACHELINE_SIZE}") + check_function_exists(memfd_create HAVE_MEMFD_CREATE) if(${HAVE_MEMFD_CREATE}) add_definitions(-DHAVE_MEMFD_CREATE) diff --git a/extras/libmemif/src/CMakeLists.txt b/extras/libmemif/src/CMakeLists.txt index ddb8a52f82b..8b3223d0990 100644 --- a/extras/libmemif/src/CMakeLists.txt +++ b/extras/libmemif/src/CMakeLists.txt @@ -34,6 +34,7 @@ include_directories(${HEADERS_DIR}) add_library(memif SHARED ${MEMIF_SOURCES}) target_link_libraries(memif ${CMAKE_THREAD_LIBS_INIT}) +target_compile_definitions(memif PUBLIC MEMIF_CACHELINE_SIZE=${LIBMEMIF_CACHELINE_SIZE}) find_library(LIB_BSD bsd) if(LIB_BSD) diff --git a/src/plugins/memif/CMakeLists.txt b/src/plugins/memif/CMakeLists.txt index b86d30adb97..4bbf6ba39db 100644 --- a/src/plugins/memif/CMakeLists.txt +++ b/src/plugins/memif/CMakeLists.txt @@ -33,3 +33,5 @@ add_vpp_plugin(memif INSTALL_HEADERS memif.h ) + +add_compile_definitions(MEMIF_CACHELINE_SIZE=${VPP_CACHE_LINE_SIZE})