diff mbox series

[ovs-dev,1/7] ccmap: Use PADDED_MEMBERS macro in ccmap_impl structure.

Message ID 1506844660-4902-1-git-send-email-bhanuprakash.bodireddy@intel.com
State Accepted
Headers show
Series [ovs-dev,1/7] ccmap: Use PADDED_MEMBERS macro in ccmap_impl structure. | expand

Commit Message

Bodireddy, Bhanuprakash Oct. 1, 2017, 7:57 a.m. UTC
Instead of explicitly adding the pad bytes to force the structure an exact
multiple of cacheline size, let the PADDED_MEMBERS macro do the job.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
---
 lib/ccmap.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Ben Pfaff Nov. 3, 2017, 8:40 p.m. UTC | #1
On Sun, Oct 01, 2017 at 08:57:34AM +0100, Bhanuprakash Bodireddy wrote:
> Instead of explicitly adding the pad bytes to force the structure an exact
> multiple of cacheline size, let the PADDED_MEMBERS macro do the job.
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>

Thanks for the series.

I applied all of these patches to master.
diff mbox series

Patch

diff --git a/lib/ccmap.c b/lib/ccmap.c
index 08359b5..a460833 100644
--- a/lib/ccmap.c
+++ b/lib/ccmap.c
@@ -102,16 +102,15 @@  BUILD_ASSERT_DECL(sizeof(struct ccmap_bucket) == CACHE_LINE_SIZE);
 
 /* The implementation of a concurrent hash map. */
 struct ccmap_impl {
-    unsigned int n_unique;      /* Number of in-use nodes. */
-    unsigned int n;             /* Number of hashes inserted. */
-    unsigned int max_n;         /* Max nodes before enlarging. */
-    unsigned int min_n;         /* Min nodes before shrinking. */
-    uint32_t mask;              /* Number of 'buckets', minus one. */
-    uint32_t basis;             /* Basis for rehashing client's hash values. */
-
-    /* Padding to make ccmap_impl exactly one cache line long. */
-    uint8_t pad[CACHE_LINE_SIZE - sizeof(unsigned int) * 6];
-
+    PADDED_MEMBERS(CACHE_LINE_SIZE,
+        unsigned int n_unique;      /* Number of in-use nodes. */
+        unsigned int n;             /* Number of hashes inserted. */
+        unsigned int max_n;         /* Max nodes before enlarging. */
+        unsigned int min_n;         /* Min nodes before shrinking. */
+        uint32_t mask;              /* Number of 'buckets', minus one. */
+        uint32_t basis;             /* Basis for rehashing client's
+                                       hash values. */
+    );
     struct ccmap_bucket buckets[];
 };
 BUILD_ASSERT_DECL(sizeof(struct ccmap_impl) == CACHE_LINE_SIZE);