cmake: Add option for "mem: per-CPU allocator cache (ThunderX2 workaround)"

Change-Id: I7156cf433b2081246d1d9b8e4fde489609676ef1
This commit is contained in:
Masamichi Takagi
2019-07-24 11:08:32 +09:00
parent c52370b959
commit f0bc1a6b07
5 changed files with 14 additions and 0 deletions

View File

@@ -87,6 +87,7 @@ option(ENABLE_RUSAGE "Enable rusage support" ON)
option(ENABLE_QLMPI "Enable qlmpi programs" OFF)
option(ENABLE_UTI "Enable uti support" OFF)
option(ENABLE_UBSAN "Enable undefined behaviour sanitizer on mckernel size" OFF)
option(ENABLE_PER_CPU_ALLOC_CACHE "Enable per-CPU allocator cache (ThunderX2 workaround)" OFF)
find_package(PkgConfig REQUIRED)
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
@@ -197,4 +198,5 @@ message("ENABLE_UTI: ${ENABLE_UTI}")
message("ENABLE_WERROR: ${ENABLE_WERROR}")
message("ENABLE_UBSAN: ${ENABLE_UBSAN}")
message("ENABLE_LINUX_WORK_IRQ_FOR_IKC: ${ENABLE_LINUX_WORK_IRQ_FOR_IKC}")
message("ENABLE_PER_CPU_ALLOC_CACHE: ${ENABLE_PER_CPU_ALLOC_CACHE}")
message("-------------------------------")

View File

@@ -28,6 +28,9 @@
/* whether undefined behaviour sanitizer is enabled */
#cmakedefine ENABLE_UBSAN 1
/* whether per-CPU allocator cache (ThunderX2 workaround) is enabled */
#cmakedefine ENABLE_PER_CPU_ALLOC_CACHE 1
/* Path of bind-mount source directory */
#cmakedefine ROOTFSDIR "${ROOTFSDIR}"

View File

@@ -42,7 +42,9 @@ void cpu_local_var_init(void)
clv[i].monitor = monitor->cpu + i;
clv[i].rusage = rusage.cpu + i;
INIT_LIST_HEAD(&clv[i].smp_func_req_list);
#ifdef ENABLE_PER_CPU_ALLOC_CACHE
clv[i].free_chunks.rb_node = NULL;
#endif
}
cpu_local_var_initialized = 1;

View File

@@ -15,6 +15,7 @@
#include <process.h>
#include <syscall.h>
#include <config.h>
/*
* CPU Local Storage (cls)
*/
@@ -103,8 +104,10 @@ struct cpu_local_var {
/* UTI */
void *uti_futex_resp;
#ifdef ENABLE_PER_CPU_ALLOC_CACHE
/* Per-CPU memory allocator cache */
struct rb_root free_chunks;
#endif
} __attribute__((aligned(64)));
extern int cpu_local_var_initialized;

View File

@@ -609,6 +609,7 @@ unsigned long ihk_numa_alloc_pages(struct ihk_mc_numa_node *node,
unsigned long addr = 0;
mcs_lock_node_t mcs_node;
#ifdef ENABLE_PER_CPU_ALLOC_CACHE
/* Check CPU local cache first */
if (cpu_local_var_initialized) {
unsigned long irqflags;
@@ -624,6 +625,7 @@ unsigned long ihk_numa_alloc_pages(struct ihk_mc_numa_node *node,
return addr;
}
}
#endif
mcs_lock_lock(&node->lock, &mcs_node);
@@ -652,6 +654,7 @@ void ihk_numa_free_pages(struct ihk_mc_numa_node *node,
{
mcs_lock_node_t mcs_node;
#ifdef ENABLE_PER_CPU_ALLOC_CACHE
/* CPU local cache */
if (cpu_local_var_initialized) {
unsigned long irqflags;
@@ -670,6 +673,7 @@ void ihk_numa_free_pages(struct ihk_mc_numa_node *node,
return;
}
}
#endif
if (addr < node->min_addr ||
(addr + (npages << PAGE_SHIFT)) > node->max_addr) {