From 01b2c23faecee4a60cccf8219bf37fa588009b8d Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 3 May 2018 08:26:39 -0400 Subject: Harmonize vec/pool_get_aligned object sizes and alignment requests Object sizes must evenly divide alignment requests, or vice versa. Otherwise, only the first object will be aligned as requested. Three choices: add CLIB_CACHE_LINE_ALIGN_MARK(align_me) at the end of structures, manually pad to an even divisor or multiple of the alignment request, or use plain vectors/pools. static assert for enforcement. Change-Id: I41aa6ff1a58267301d32aaf4b9cd24678ac1c147 Signed-off-by: Dave Barach --- src/vnet/dpo/classify_dpo.h | 5 +++++ src/vnet/dpo/l3_proxy_dpo.h | 6 ++++++ src/vnet/dpo/load_balance.h | 6 ++++++ src/vnet/dpo/load_balance_map.h | 6 ++++++ src/vnet/dpo/lookup_dpo.h | 6 ++++++ src/vnet/dpo/mpls_disposition.h | 6 ++++++ src/vnet/dpo/mpls_label_dpo.h | 6 ++++++ src/vnet/dpo/receive_dpo.h | 6 ++++++ src/vnet/dpo/replicate_dpo.h | 6 ++++++ 9 files changed, 53 insertions(+) (limited to 'src/vnet/dpo') diff --git a/src/vnet/dpo/classify_dpo.h b/src/vnet/dpo/classify_dpo.h index 48f4b2bf8a5..439727d351f 100644 --- a/src/vnet/dpo/classify_dpo.h +++ b/src/vnet/dpo/classify_dpo.h @@ -25,6 +25,11 @@ */ typedef struct classify_dpo_t { + /** + * required for pool_get_aligned. + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + dpo_proto_t cd_proto; u32 cd_table_index; diff --git a/src/vnet/dpo/l3_proxy_dpo.h b/src/vnet/dpo/l3_proxy_dpo.h index f17ace50876..fcc28b3bf97 100644 --- a/src/vnet/dpo/l3_proxy_dpo.h +++ b/src/vnet/dpo/l3_proxy_dpo.h @@ -26,6 +26,12 @@ typedef struct l3_proxy_dpo_t_ { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * The Software interface index on which traffic is l3_proxyd */ diff --git a/src/vnet/dpo/load_balance.h b/src/vnet/dpo/load_balance.h index d37f07d579f..dd9589f9ee8 100644 --- a/src/vnet/dpo/load_balance.h +++ b/src/vnet/dpo/load_balance.h @@ -82,6 +82,12 @@ typedef struct load_balance_path_t_ { * - per-route counters */ typedef struct load_balance_t_ { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * number of buckets in the load-balance. always a power of 2. */ diff --git a/src/vnet/dpo/load_balance_map.h b/src/vnet/dpo/load_balance_map.h index f9344c01c1e..82dd36b41b1 100644 --- a/src/vnet/dpo/load_balance_map.h +++ b/src/vnet/dpo/load_balance_map.h @@ -28,6 +28,12 @@ struct load_balance_map_path_t_; /** */ typedef struct load_balance_map_t_ { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * The buckets of the map that provide the index to index translation. * In the first cacheline. diff --git a/src/vnet/dpo/lookup_dpo.h b/src/vnet/dpo/lookup_dpo.h index 4ebd6050fc6..21aecadc280 100644 --- a/src/vnet/dpo/lookup_dpo.h +++ b/src/vnet/dpo/lookup_dpo.h @@ -64,6 +64,12 @@ typedef enum lookup_cast_t_ { */ typedef struct lookup_dpo_t { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * The FIB, or interface from which to get a FIB, in which to perform * the next lookup; diff --git a/src/vnet/dpo/mpls_disposition.h b/src/vnet/dpo/mpls_disposition.h index 9c3cc46ff30..86dd60ae290 100644 --- a/src/vnet/dpo/mpls_disposition.h +++ b/src/vnet/dpo/mpls_disposition.h @@ -26,6 +26,12 @@ */ typedef struct mpls_disp_dpo_t { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * Next DPO in the graph */ diff --git a/src/vnet/dpo/mpls_label_dpo.h b/src/vnet/dpo/mpls_label_dpo.h index 98c88f7d812..4e032d33458 100644 --- a/src/vnet/dpo/mpls_label_dpo.h +++ b/src/vnet/dpo/mpls_label_dpo.h @@ -66,6 +66,12 @@ extern u8* format_mpls_label_dpo_flags(u8 *s, va_list *args); */ typedef struct mpls_label_dpo_t { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * The MPLS label header to impose. Outer most label first. * Each DPO will occupy one cache line, stuff that many labels in. diff --git a/src/vnet/dpo/receive_dpo.h b/src/vnet/dpo/receive_dpo.h index 2420fd7843c..9ab86a824c6 100644 --- a/src/vnet/dpo/receive_dpo.h +++ b/src/vnet/dpo/receive_dpo.h @@ -25,6 +25,12 @@ typedef struct receive_dpo_t_ { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * The Software interface index on which traffic is received */ diff --git a/src/vnet/dpo/replicate_dpo.h b/src/vnet/dpo/replicate_dpo.h index ccb25630e16..7b075394bc3 100644 --- a/src/vnet/dpo/replicate_dpo.h +++ b/src/vnet/dpo/replicate_dpo.h @@ -52,6 +52,12 @@ extern replicate_main_t replicate_main; * - per-route counters */ typedef struct replicate_t_ { + /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /** * number of buckets in the replicate. */ -- cgit 1.2.3-korg