From 38be4ef2552d53d2cf38049b6c9ce20583f72f07 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 14 Nov 2018 21:14:52 +0100 Subject: [PATCH] config: compile time detection of cache line size for aarch64 (fixes #214) --- include/villas/config.h.in | 7 +++++++ include/villas/queue.h | 2 +- lib/kernel/kernel.c | 5 ++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/villas/config.h.in b/include/villas/config.h.in index 490cee296..2057a84f0 100644 --- a/include/villas/config.h.in +++ b/include/villas/config.h.in @@ -57,6 +57,13 @@ extern "C" { #define USER_AGENT "VILLASnode (" BUILDID ")" +/* Hard-coded cache line size */ +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) + #define CACHELINE_SIZE 64 +#else + #error "Unsupported architecture" +#endif + /* Required kernel version */ #define KERNEL_VERSION_MAJ 3 #define KERNEL_VERSION_MIN 6 diff --git a/include/villas/queue.h b/include/villas/queue.h index 7b06b21e6..68f7ed469 100644 --- a/include/villas/queue.h +++ b/include/villas/queue.h @@ -39,6 +39,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -47,7 +48,6 @@ extern "C" { /* Forward declarations */ struct memory_type; -#define CACHELINE_SIZE 64 typedef char cacheline_pad_t[CACHELINE_SIZE]; struct queue_cell { diff --git a/lib/kernel/kernel.c b/lib/kernel/kernel.c index 37ab4907c..00e23d757 100644 --- a/lib/kernel/kernel.c +++ b/lib/kernel/kernel.c @@ -299,14 +299,13 @@ int kernel_get_version(struct version *v) return 0; } +/** @todo Do not rely on hard-coded sizes */ int kernel_get_cacheline_size() { #if defined(__linux__) && defined(__x86_64__) return sysconf(_SC_LEVEL1_ICACHE_LINESIZE); -#elif defined(__x86_64__) || defined(__i386__) - return 64; /** @todo fixme */ #else - #error "Unsupported architecture" + return CACHELINE_SIZE; #endif }