mirror of
https://github.com/openvswitch/ovs
synced 2025-10-17 14:28:02 +00:00
cmap: Use PADDED_MEMBERS_CACHELINE_MARKER in cmap_impl.
Instead of explicitly adding the pad bytes to force the structure an exact multiple of cacheline size, let the macro do the job. This way the pad bytes will be auto adjusted when the new members get introduced in to the structure. Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
committed by
Ben Pfaff
parent
6be7aa7d54
commit
82f197ca5a
19
lib/cmap.c
19
lib/cmap.c
@@ -165,13 +165,18 @@ BUILD_ASSERT_DECL(sizeof(struct cmap_bucket) == CACHE_LINE_SIZE);
|
||||
|
||||
/* The implementation of a concurrent hash map. */
|
||||
struct cmap_impl {
|
||||
unsigned int n; /* Number of in-use elements. */
|
||||
unsigned int max_n; /* Max elements before enlarging. */
|
||||
unsigned int min_n; /* Min elements before shrinking. */
|
||||
uint32_t mask; /* Number of 'buckets', minus one. */
|
||||
uint32_t basis; /* Basis for rehashing client's hash values. */
|
||||
uint8_t pad[CACHE_LINE_SIZE - 4 * 5]; /* Pad to end of cache line. */
|
||||
struct cmap_bucket buckets[1];
|
||||
PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline0,
|
||||
unsigned int n; /* Number of in-use elements. */
|
||||
unsigned int max_n; /* Max elements before enlarging. */
|
||||
unsigned int min_n; /* Min elements before shrinking. */
|
||||
uint32_t mask; /* Number of 'buckets', minus one. */
|
||||
uint32_t basis; /* Basis for rehashing client's
|
||||
hash values. */
|
||||
);
|
||||
|
||||
PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline1,
|
||||
struct cmap_bucket buckets[1];
|
||||
);
|
||||
};
|
||||
BUILD_ASSERT_DECL(sizeof(struct cmap_impl) == CACHE_LINE_SIZE * 2);
|
||||
|
||||
|
Reference in New Issue
Block a user