From 82137c9bc1496593523c17a4ff4f8dd21af689c0 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Mon, 30 Mar 2020 15:14:45 -0400 Subject: [PATCH] Improve _env_allocator_item fields alignment This change assures that data array is always optimally aligned. Additionally item boolean flags are put into the same uint32 as cpu number in order to save space for future additions. This change fixes ~50% performance degradation introduced by commit d822a1d1. Signed-off-by: Adam Rutkowski --- modules/cas_cache/ocf_env.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/cas_cache/ocf_env.c b/modules/cas_cache/ocf_env.c index 15ed5be..036c3e6 100644 --- a/modules/cas_cache/ocf_env.c +++ b/modules/cas_cache/ocf_env.c @@ -34,10 +34,10 @@ static inline size_t env_allocator_align(size_t size) } struct _env_allocator_item { - uint32_t cpu; - uint8_t from_rpool : 1; - uint8_t used : 1; - char data[]; + uint32_t cpu : order_base_2(NR_CPUS); + uint32_t from_rpool : 1; + uint32_t used : 1; + char data[] __attribute__ ((aligned (__alignof__(uint64_t)))); }; void *env_allocator_new(env_allocator *allocator)