From ac61a8498e4aff93c8bc269d0904ef5d2cb10200 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 8 Jun 2016 22:30:30 +0200 Subject: [PATCH] added function to get system cache line size --- include/linux.h | 3 +++ lib/linux.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/linux.h b/include/linux.h index 64e5bde77..1a73c3416 100644 --- a/include/linux.h +++ b/include/linux.h @@ -48,4 +48,7 @@ int kernel_module_load(const char *module); /** Set parameter of loaded kernel module */ int kernel_module_set_param(const char *module, const char *param, const char *value); +/** Get cacheline size in bytes */ +int kernel_get_cacheline_size(); + #endif /* _LINUX_H_ */ diff --git a/lib/linux.c b/lib/linux.c index e6f495426..c95081a8d 100644 --- a/lib/linux.c +++ b/lib/linux.c @@ -123,4 +123,8 @@ int kernel_has_cmdline(const char *substr) return -1; return strstr(cmd, substr) ? 0 : -1; +} +int kernel_get_cacheline_size() +{ + return sysconf(_SC_LEVEL1_ICACHE_LINESIZE); } \ No newline at end of file