diff options
| author | Lu Qiuwen <[email protected]> | 2024-07-25 11:16:49 +0800 |
|---|---|---|
| committer | Lu Qiuwen <[email protected]> | 2024-07-25 11:16:49 +0800 |
| commit | cb4c34cf1904910b622b36454f378630e11731b3 (patch) | |
| tree | 01fb570a417080bdbb92ce0b1ae4e043e6e6a9f6 | |
| parent | 38039049b6896bf1fdb151062838a723f2b24e8a (diff) | |
rearrange the vnode_prod and vnode_cons to avoid false sharing.v4.8.18-20240725
| -rw-r--r-- | infra/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | infra/src/vnode_common.c | 6 | ||||
| -rw-r--r-- | infra/src/vnode_common.h | 11 |
3 files changed, 11 insertions, 7 deletions
diff --git a/infra/CMakeLists.txt b/infra/CMakeLists.txt index 1674b97..e61bc49 100644 --- a/infra/CMakeLists.txt +++ b/infra/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories(../service/include) add_library(infra src/cJSON.c src/vnode_common.c src/vnode_mirror.c src/pkt_classifier_engine.c src/port_adapter_mapping.c src/link_db.c src/ldbc.c src/version.c src/rpc.c src/dp_trace.c) target_link_libraries(infra rt libevent-static libevent-static-pthreads pthread dl MESA_prof_load_static libdpdk) target_include_directories(infra INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/") +set_target_properties(infra PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) add_executable(TestPacketParser test/TestPacketParser.cc) target_link_libraries(TestPacketParser gtest_main infra z elf ibverbs libevent-static libdpdk ${SYSTEMD_LIBRARIES}) diff --git a/infra/src/vnode_common.c b/infra/src/vnode_common.c index 0dd413a..d85b524 100644 --- a/infra/src/vnode_common.c +++ b/infra/src/vnode_common.c @@ -252,7 +252,7 @@ static void synchronize_dataplane() struct vnode * __vnode_common_create(const char * sym, unsigned int sz_tunnel, unsigned int sz_tunnel_buffer, unsigned int notify_cons_when_rx) { - struct vnode * object = (struct vnode *)rte_zmalloc(NULL, sizeof(struct vnode), 0); + struct vnode * object = (struct vnode *)rte_zmalloc(NULL, sizeof(struct vnode), RTE_CACHE_LINE_SIZE); MR_VERIFY_MALLOC(object); snprintf(object->symbol, sizeof(object->symbol), "%s", sym); @@ -269,7 +269,7 @@ struct vnode * __vnode_common_create(const char * sym, unsigned int sz_tunnel, u /* VNode的生产者、消费者注册 */ struct vnode_prod * __vnode_common_create_prod(struct vnode * vnode, const char * symbol, int nr_prodq) { - struct vnode_prod * prod = ZMALLOC(sizeof(struct vnode_prod)); + struct vnode_prod * prod = rte_zmalloc(NULL, sizeof(struct vnode_prod), RTE_CACHE_LINE_SIZE); MR_VERIFY_MALLOC(prod); snprintf(prod->symbol, sizeof(vnode->symbol), "%s", symbol); @@ -295,7 +295,7 @@ err: struct vnode_cons * __vnode_common_create_cons(struct vnode * vnode, const char * symbol, int nr_consq) { - struct vnode_cons * cons = ZMALLOC(sizeof(struct vnode_cons)); + struct vnode_cons * cons = rte_zmalloc(NULL, sizeof(struct vnode_cons), RTE_CACHE_LINE_SIZE); MR_VERIFY_MALLOC(cons); // cons description init diff --git a/infra/src/vnode_common.h b/infra/src/vnode_common.h index 4dc35b9..94a6a12 100644 --- a/infra/src/vnode_common.h +++ b/infra/src/vnode_common.h @@ -88,12 +88,13 @@ struct vnode_mem_alloc_hints struct vnode_cons { TAILQ_ENTRY(vnode_cons) next; - char symbol[MR_SYMBOL_MAX]; struct vnode * vnode; - unsigned int nr_consq; struct tunnel_block * block; + unsigned int nr_consq; unsigned int cur_attach; + char symbol[MR_SYMBOL_MAX]; + RTE_MARKER cacheline_mark __rte_cache_min_aligned; struct vnode_cons_stat stat[MR_SID_MAX]; struct vnode_cons_notify notify[MR_SID_MAX]; }; @@ -102,11 +103,13 @@ struct vnode_cons struct vnode_prod { TAILQ_ENTRY(vnode_prod) next; - char symbol[MR_SYMBOL_MAX]; struct vnode * vnode; + struct tunnel_block * block; unsigned int nr_prodq; unsigned int cur_attach; - struct tunnel_block * block; + char symbol[MR_SYMBOL_MAX]; + + RTE_MARKER cacheline_mark __rte_cache_min_aligned; struct vnode_prod_stat stat[MR_SID_MAX]; }; |
