From ae1564df934f2c3b8213481f13ae0b9e6c4a9d2a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 9 Nov 2016 11:12:44 -0500 Subject: [PATCH] include/mempool: align shard_t to cacheline Signed-off-by: Sage Weil --- src/include/mempool.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/include/mempool.h b/src/include/mempool.h index e3733f8910a40..52bce73207795 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -31,6 +31,7 @@ #include + /* Memory Pools @@ -167,10 +168,14 @@ enum { num_shards = 1 << num_shard_bits }; +// align shard to a cacheline struct shard_t { std::atomic bytes = {0}; std::atomic items = {0}; -}; + char __padding[128 - sizeof(std::atomic)*2]; +} __attribute__ ((aligned (128))); + +static_assert(sizeof(shard_t) == 128, "shard_t should be cacheline-sized"); struct stats_t { ssize_t items = 0; -- 2.39.5