Allocator structures cacheline alignment
Align atomic fields to a different cacheline, so no false sharing between CPUs occur. Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com>
This commit is contained in:
parent
94dc9048c7
commit
c751974ae0
@ -14,16 +14,16 @@ struct _env_allocator {
|
|||||||
/*!< Memory pool ID unique name */
|
/*!< Memory pool ID unique name */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/*!< Size of specific item of memory pool */
|
|
||||||
uint32_t item_size;
|
|
||||||
|
|
||||||
/*!< OS handle to memory pool */
|
/*!< OS handle to memory pool */
|
||||||
struct kmem_cache *kmem_cache;
|
struct kmem_cache *kmem_cache;
|
||||||
|
|
||||||
/*!< Number of currently allocated items in pool */
|
|
||||||
atomic_t count;
|
|
||||||
|
|
||||||
struct cas_reserve_pool *rpool;
|
struct cas_reserve_pool *rpool;
|
||||||
|
|
||||||
|
/*!< Size of specific item of memory pool */
|
||||||
|
uint32_t item_size;
|
||||||
|
|
||||||
|
/*!< Number of currently allocated items in pool */
|
||||||
|
atomic_t count __attribute__((aligned(64)));
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline size_t env_allocator_align(size_t size)
|
static inline size_t env_allocator_align(size_t size)
|
||||||
|
@ -25,11 +25,17 @@
|
|||||||
#define CAS_DEBUG_PARAM(format, ...)
|
#define CAS_DEBUG_PARAM(format, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* This is currently 24B padded/force aligned to 32B.
|
||||||
|
* With a 64B cacheline this means two structs on different cores may
|
||||||
|
* invalidate each other. This shouldn't happen between different physical
|
||||||
|
* CPUs and cause false sharing though, since with an even number of cores
|
||||||
|
* per CPU same cacheline shouldn't be polluted from the other physical CPU.
|
||||||
|
* */
|
||||||
struct _cas_reserve_pool_per_cpu {
|
struct _cas_reserve_pool_per_cpu {
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
atomic_t count;
|
atomic_t count;
|
||||||
};
|
} __attribute__((__aligned__(32)));
|
||||||
|
|
||||||
struct cas_reserve_pool {
|
struct cas_reserve_pool {
|
||||||
uint32_t limit;
|
uint32_t limit;
|
||||||
|
Loading…
Reference in New Issue
Block a user