summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHonnappa Nagarahalli <honnappa.nagarahalli@arm.com>2018-10-26 00:37:31 -0500
committerThomas Monjalon <thomas@monjalon.net>2018-10-26 12:45:40 +0200
commitdbdbc4a2e9c4b67247ef2f6556debe7522b5d2e4 (patch)
tree75acd2183b146163d1762812ae3da9640c7bb777
parent9d033dac7d7cacca9559e0381f99b4c730e80979 (diff)
downloaddpdk-dbdbc4a2e9c4b67247ef2f6556debe7522b5d2e4.zip
dpdk-dbdbc4a2e9c4b67247ef2f6556debe7522b5d2e4.tar.gz
dpdk-dbdbc4a2e9c4b67247ef2f6556debe7522b5d2e4.tar.xz
hash: fix key store element alignment
Fix the key store array element alignment such that every array element is aligned on KEY_ALIGNMENT boundary. This is required to make 'pdata' in 'struct rte_hash_key' align on its natural boundary for atomic load/store. Fixes: 473d1bebce43 ("hash: allow to store data in hash table") Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> Reviewed-by: Gavin Hu <gavin.hu@arm.com> Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com> Reviewed-by: Steve Capper <steve.capper@arm.com> Reviewed-by: Yipeng Wang <yipeng1.wang@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
-rw-r--r--lib/librte_hash/rte_cuckoo_hash.c4
-rw-r--r--lib/librte_hash/rte_cuckoo_hash.h2
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index e087393..d79ba68 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -279,7 +279,9 @@ rte_hash_create(const struct rte_hash_parameters *params)
rte_ring_sp_enqueue(r_ext, (void *)((uintptr_t) i));
}
- const uint32_t key_entry_size = sizeof(struct rte_hash_key) + params->key_len;
+ const uint32_t key_entry_size =
+ RTE_ALIGN(sizeof(struct rte_hash_key) + params->key_len,
+ KEY_ALIGNMENT);
const uint64_t key_tbl_size = (uint64_t) key_entry_size * num_key_slots;
k = rte_zmalloc_socket(NULL, key_tbl_size,
diff --git a/lib/librte_hash/rte_cuckoo_hash.h b/lib/librte_hash/rte_cuckoo_hash.h
index ff95181..601b2ce 100644
--- a/lib/librte_hash/rte_cuckoo_hash.h
+++ b/lib/librte_hash/rte_cuckoo_hash.h
@@ -123,7 +123,7 @@ struct rte_hash_key {
};
/* Variable key size */
char key[0];
-} __attribute__((aligned(KEY_ALIGNMENT)));
+};
/* All different signature compare functions */
enum rte_hash_sig_compare_function {