diff options
| author | Qiuwen Lu <[email protected]> | 2016-12-14 16:48:07 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2016-12-14 16:48:07 +0800 |
| commit | 11c55eb43967852d93c49e3020c4ddad67354c44 (patch) | |
| tree | 116fc8d3a7185523f091799ededf0675f8e1ab18 | |
| parent | 43a0b9d9d71f4c884d05b931029c88d08e4f50a3 (diff) | |
调整vnode动态增删时的逻辑,调整统计计数方法,修正epoll线程sys高的问题。
| -rw-r--r-- | core/include/mr_stat.h | 113 | ||||
| -rw-r--r-- | core/src/stat.c | 35 | ||||
| -rw-r--r-- | core/src/vnode.c | 11 | ||||
| -rw-r--r-- | runtime/src/event.c | 2 | ||||
| -rw-r--r-- | runtime/src/runtime.c | 18 | ||||
| -rw-r--r-- | service/src/rxtx.c | 23 | ||||
| -rw-r--r-- | tools/stat/event_stat.c | 4 |
7 files changed, 70 insertions, 136 deletions
diff --git a/core/include/mr_stat.h b/core/include/mr_stat.h index 66eec40..49d1366 100644 --- a/core/include/mr_stat.h +++ b/core/include/mr_stat.h @@ -6,52 +6,18 @@ #include <rte_mbuf.h> #include <mr_common.h> -#include <mr_runtime.h> -#define MR_STAT_MAX_DEVICE RTE_MAX_ETHPORTS #define MR_STAT_MAX_THREAD MR_MAX_GSID +#define MR_PERF_ITEM_MAX 128 -#ifndef MR_STAT_OPT_DEV_STAT_ENABLE -#define MR_STAT_OPT_DEV_STAT_ENABLE 1 -#endif - -struct mr_device_stat -{ - struct - { - volatile uint64_t dev_rx_frame[RTE_MAX_ETHPORTS]; - volatile uint64_t dev_rx_bit[RTE_MAX_ETHPORTS]; - volatile uint64_t dev_tx_frame[RTE_MAX_ETHPORTS]; - volatile uint64_t dev_tx_bit[RTE_MAX_ETHPORTS]; - } __rte_cache_aligned _per_thread[MR_GSID_MAX]; -}; - -struct mr_vnode_stat +enum { - struct - { - volatile uint64_t object_enqueue; - volatile uint64_t object_dup_success; - volatile uint64_t object_dup_fail; - volatile uint64_t block_enqueue; - volatile uint64_t tunnel_enqueue; - volatile uint64_t tunnel_enqueue_fail; - } __rte_cache_aligned _per_thread[MR_GSID_MAX]; -}; - -struct mr_app_stat -{ - struct - { - struct - { - volatile uint64_t rx_frame; - volatile uint64_t tx_frame; - volatile uint64_t rx_byte; - volatile uint64_t tx_byte; - volatile uint64_t drop_frame; - } __rte_cache_aligned _per_thread[MR_GSID_MAX]; - } __per_app[MR_APP_MAX]; + PERF_SC_LOOP, + PERF_MR_RAW_RECV, + PERF_MR_RAW_SEND, + PERF_PAG_GET, + PERF_ITER_PAG_GET, + PERF_MAX }; struct mr_perf_item @@ -62,68 +28,45 @@ struct mr_perf_item }; struct mr_perf_stat -{ +{ struct { - struct mr_perf_item sc_rx_loop_all; - struct mr_perf_item sc_rx_loop_eth_rx_burst; - struct mr_perf_item sc_rx_loop_hash_calc; - struct mr_perf_item sc_rx_loop_dispatch; - struct mr_perf_item pag_get_frame; - struct mr_perf_item pag_get; + struct mr_perf_item _perf[PERF_MAX]; } __rte_cache_aligned _per_thread[MR_GSID_MAX]; }; -struct mr_event_stat +enum +{ + TRACE_MBUF_DUP_FAILED, + TRACE_MBUF_INNORMAL_FREE, + TRACE_RTE_RX_BURST_RT_IS_ZERO, + TRACE_MAX +}; + +struct mr_trace_stat { struct { - volatile uint64_t ev_rx_dup_failed; - volatile uint64_t ev_rx_entunnel_failed; - + volatile uint64_t _trace[TRACE_MAX]; } __rte_cache_aligned _per_thread[MR_GSID_MAX]; }; -extern struct mr_vnode_stat * mr_vnode_stat_get(); -extern struct mr_device_stat * mr_device_stat_get(); extern struct mr_perf_stat * mr_perf_stat_get(); -extern struct mr_app_stat * mr_app_stat_get(); -extern struct mr_event_stat * mr_event_stat_get(); - -#define UPDATE_DEV_STAT(_s, _p, _n) \ -do { \ - struct mr_device_stat * st = mr_device_stat_get(); \ - if(st) st->_per_thread[mr_thread_id()]._s[_p] += _n; \ -}while(0) \ +extern struct mr_trace_stat * mr_trace_stat_get(); -#define UPDATE_VNODE_STAT(_s, _n) \ +#define TRACE(_s, _n) \ do { \ - struct mr_vnode_stat * st = mr_vnode_stat_get(); \ - if(st) st->_per_thread[mr_thread_id()]._s += _n; \ + struct mr_trace_stat * st = mr_trace_stat_get(); \ + if(st) st->_per_thread[mr_thread_id()]._trace[_s] += _n; \ }while(0) \ -#define UPDATE_EVENT_STAT(_s, _n) \ -do { \ - struct mr_event_stat * st = mr_event_stat_get(); \ - if(st) st->_per_thread[mr_thread_id()]._s += _n; \ -}while(0) \ - -#define UPDATE_APP_STAT(_s, _n) \ -do { \ - struct mr_app_stat * st = mr_app_stat_get(); \ - if(st) \ - st->__per_app[mr_app_id()]. \ - _per_thread[mr_thread_id()]._s += _n; \ -}while(0) - #define PERF_BEGIN(_s) \ do { \ struct mr_perf_stat * st = mr_perf_stat_get(); \ uint64_t _tsc = rte_rdtsc(); \ - if(st) st->_per_thread[mr_thread_id()]._s.begin = _tsc; \ + if(st) st->_per_thread[mr_thread_id()]._perf[_s].begin = _tsc; \ }while(0) \ - #define PERF_END(_s) \ do { \ struct mr_perf_stat * st = mr_perf_stat_get(); \ @@ -131,10 +74,10 @@ do { \ { \ thread_id_t _tid = mr_thread_id(); \ uint64_t _tsc = rte_rdtsc(); \ - uint64_t _begin = st->_per_thread[_tid]._s.begin; \ + uint64_t _begin = st->_per_thread[_tid]._perf[_s].begin; \ uint64_t _delta = _tsc - _begin; \ - st->_per_thread[_tid]._s.runtime += _delta; \ - st->_per_thread[_tid]._s.cycles++; \ + st->_per_thread[_tid]._perf[_s].runtime += _delta; \ + st->_per_thread[_tid]._perf[_s].cycles++; \ } \ } while(0) \ diff --git a/core/src/stat.c b/core/src/stat.c index f81361d..a4fe471 100644 --- a/core/src/stat.c +++ b/core/src/stat.c @@ -14,33 +14,13 @@ struct stat_ctx { - unsigned int device_stat_enable; - unsigned int vnode_stat_enable; unsigned int perf_stat_enable; - unsigned int app_stat_enable; - unsigned int event_stat_enable; + unsigned int trace_stat_enable; - struct mr_device_stat device_stat_handle; - struct mr_vnode_stat vnode_stat_handle; struct mr_perf_stat perf_stat_handle; - struct mr_app_stat app_stat_handle; - struct mr_event_stat event_stat_handle; + struct mr_trace_stat trace_stat_handle; }; -struct mr_device_stat * mr_device_stat_get() -{ - struct stat_ctx * module_ctx = mr_core_default_instance_get()->stat_ctx; - if (module_ctx->device_stat_enable) return &module_ctx->device_stat_handle; - return NULL; -} - -struct mr_vnode_stat * mr_vnode_stat_get() -{ - struct stat_ctx * module_ctx = mr_core_default_instance_get()->stat_ctx; - if (module_ctx->vnode_stat_enable) return &module_ctx->vnode_stat_handle; - return NULL; -} - struct mr_perf_stat * mr_perf_stat_get() { struct stat_ctx * module_ctx = mr_core_default_instance_get()->stat_ctx; @@ -48,17 +28,10 @@ struct mr_perf_stat * mr_perf_stat_get() return NULL; } -struct mr_app_stat * mr_app_stat_get() -{ - struct stat_ctx * module_ctx = mr_core_default_instance_get()->stat_ctx; - if(module_ctx->app_stat_enable) return &module_ctx->app_stat_handle; - return NULL; -} - -struct mr_event_stat * mr_event_stat_get() +struct mr_trace_stat * mr_trace_stat_get() { struct stat_ctx * module_ctx = mr_core_default_instance_get()->stat_ctx; - if(module_ctx->event_stat_enable) return &module_ctx->event_stat_handle; + if(module_ctx->trace_stat_enable) return &module_ctx->trace_stat_handle; return NULL; } diff --git a/core/src/vnode.c b/core/src/vnode.c index d408b4a..8fa9fca 100644 --- a/core/src/vnode.c +++ b/core/src/vnode.c @@ -422,10 +422,12 @@ int renew_max_id(struct tunnel_block** list, int size) int i = 0, cnt = 0; for (i = 0; i < size; i++) { - if (list[i] != NULL) + if (list[i] == NULL || list[i]->deleted == 1) { - cnt++; + continue; } + + cnt=i; } return cnt; } @@ -619,7 +621,7 @@ struct vnode_cons * vnode_create_cons(struct vnode * vnode, struct vnode_ops * o // cons description init assert(symbol != NULL); - strncpy(cons->symbol, symbol, sizeof(vnode->symbol)); + strncpy(cons->symbol, symbol, sizeof(cons->symbol)); cons->vnode = vnode; cons->nr_consq = nr_consq; cons->nr_block = 0; @@ -802,10 +804,12 @@ int vnode_delete_cons(struct vnode_cons * cons, struct vnode_ops * ops) } tunnel_block_try_delete(block, ops); } + TAILQ_FOREACH(prod_iter, &vnode->prod_list, next) { prod_iter->max_idx=renew_max_id(prod_iter->block_list, RTE_DIM(prod_iter->block_list)); } + rte_mb(); synchronize_dataplane(); @@ -873,6 +877,7 @@ int vnode_enqueue_burst_with_hash(struct vnode_prod * prod, struct vnode_ops * o continue; } + assert(block != NULL && block->deleted == 0); void * dup_objects[MR_LIBVNODE_MAX_SZ_BURST]; unsigned int nr_dup_objects = 0; diff --git a/runtime/src/event.c b/runtime/src/event.c index adabe4e..3e05a65 100644 --- a/runtime/src/event.c +++ b/runtime/src/event.c @@ -412,7 +412,7 @@ void * app_thread_crash_monitor(void * arg) while(1) { - int ret = epoll_wait(epoll_fd, evlist, __EV_MAX_EVENTS, 0); + int ret = epoll_wait(epoll_fd, evlist, __EV_MAX_EVENTS, -1); if (ret == -1 && errno == EINTR) continue; else if(ret == -1) { diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 88e912e..9472438 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -99,6 +99,8 @@ sigset_t __autoexit_sigmask; /* 处理运行时异常退出的情况。该模块保证应用触发异常,收到退出信号时, * 调用退出处理函数,释放资源,保证内存的一致性。*/ + +#if 0 static void __autoexit_raise(int status __rte_unused, void * arg __rte_unused) { void * rtvalue; @@ -131,6 +133,9 @@ static void __autoexit_raise(int status __rte_unused, void * arg __rte_unused) return; } +#endif + +#if 0 static void __autoexit_thread_setup() { // 记录线程ID @@ -189,6 +194,9 @@ void * __autoexit_thread(void * arg) } } +#endif + +#if 0 static void __autoexit_setup() { sigemptyset(&__autoexit_sigmask); @@ -214,19 +222,21 @@ static void __autoexit_setup() autoexit = 1; } +#endif + int mr_app_register(const char * appsym, cpu_mask_t cpumask, - unsigned int autoexit) + unsigned int autoexit __rte_unused) { - if (autoexit) __autoexit_setup(); + //if (autoexit) __autoexit_setup(); mr_runtime_slave_init(); mr_app_manager_appinfo_register(appsym, cpumask); - on_exit(__autoexit_raise, NULL); + //on_exit(__autoexit_raise, NULL); return 0; } int mr_thread_register() { - if (autoexit) __autoexit_thread_setup(); + //if (autoexit) __autoexit_thread_setup(); mr_app_manager_thread_register(); return 0; } diff --git a/service/src/rxtx.c b/service/src/rxtx.c index 5a5a581..ca28dbe 100644 --- a/service/src/rxtx.c +++ b/service/src/rxtx.c @@ -101,13 +101,11 @@ static inline void __rx_loop_one_device(struct sc_instance * instance, thread_id assert(devq != NULL); nr_rx_bufs_in = rte_eth_rx_burst(devq->port_id, devq->queue_id, rx_bufs_in, nr_rx_burst); - if (unlikely(nr_rx_bufs_in == 0)) return; - - int nr_rx_bufs_len = pktslen(rx_bufs_in, nr_rx_bufs_in); - UPDATE_DEV_STAT(dev_rx_frame, devq->port_id, nr_rx_bufs_in); - UPDATE_DEV_STAT(dev_rx_bit, devq->port_id, nr_rx_bufs_len); - UPDATE_APP_STAT(rx_frame, nr_rx_bufs_in); - UPDATE_APP_STAT(rx_byte, nr_rx_bufs_len); + if (unlikely(nr_rx_bufs_in == 0)) + { + TRACE(TRACE_RTE_RX_BURST_RT_IS_ZERO, 1); + return; + } int ret = distributer_hash_caculate(instance->sc_param.distmode, rx_bufs_in, nr_rx_bufs_in, hash_result); @@ -126,9 +124,14 @@ static inline void __rx_loop_one_device(struct sc_instance * instance, thread_id } clean: + for (int i = 0; i < nr_rx_bufs_in; i++) { - if (rx_bufs_in[i] != NULL) rte_pktmbuf_free(rx_bufs_in[i]); + if (rx_bufs_in[i] != NULL) + { + rte_pktmbuf_free(rx_bufs_in[i]); + TRACE(TRACE_MBUF_INNORMAL_FREE, 1); + } } return; @@ -136,7 +139,7 @@ clean: void sc_thread_rxtx_loop(struct sc_instance * instance, thread_id_t tid) { - PERF_BEGIN(sc_rx_loop_all); + PERF_BEGIN(PERF_SC_LOOP); unsigned int sz_burst = instance->sc_param.sz_burst; struct sc_device * device_iter; @@ -146,7 +149,7 @@ void sc_thread_rxtx_loop(struct sc_instance * instance, thread_id_t tid) __tx_loop_one_device(instance, tid, device_iter, sz_burst); } - PERF_END(sc_rx_loop_all); + PERF_END(PERF_SC_LOOP); return; } diff --git a/tools/stat/event_stat.c b/tools/stat/event_stat.c index 1521b54..fb39d13 100644 --- a/tools/stat/event_stat.c +++ b/tools/stat/event_stat.c @@ -45,8 +45,8 @@ static void write_event_item(FILE * stream, const char * ev_symbol, uint64_t val static void event_stat_loop(FILE * stream) { - struct mr_event_stat * stat_handle; - stat_handle = mr_event_stat_get(); + struct mr_trace_stat * stat_handle; + stat_handle = mr_trace_stat_get(); if(stat_handle == NULL) { fprintf(stderr, "Master(serivce) is not run or event stat " |
