summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQiuwen Lu <[email protected]>2016-12-14 16:50:56 +0800
committerQiuwen Lu <[email protected]>2016-12-14 16:50:56 +0800
commit7c6adef9371b899ff9428bd8c74adcfc43a2063a (patch)
tree116fc8d3a7185523f091799ededf0675f8e1ab18
parent797b8fcb516d64edabbe11033a352f2df1c09457 (diff)
parent3110087d8bf169249a2c0d0c889bb1a013f26761 (diff)
Merge branch 'rel-4.X.X' of 10.0.6.226:mesa_platform/marsio into rel-4.X.Xv4.0.10-20161214
-rw-r--r--core/include/mr_stat.h113
-rw-r--r--core/src/stat.c35
-rw-r--r--core/src/vnode.c48
-rw-r--r--runtime/src/event.c2
-rw-r--r--runtime/src/runtime.c18
-rw-r--r--service/src/rxtx.c23
-rw-r--r--tools/stat/event_stat.c4
7 files changed, 90 insertions, 153 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 66a1420..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;
}
@@ -461,8 +463,8 @@ int vnode_prod_increase_unsafe(struct vnode * vnode, struct vnode_ops * ops,
}
// insert block into prod block list and cons block list
- add_block_to_list(prod->block_list, block, MR_CONS_MAX, &(prod->max_idx));
- add_block_to_list(cons->block_list, block, MR_PROD_MAX, &(cons->max_idx));
+ add_block_to_list(prod->block_list, block, RTE_DIM(prod->block_list), &(prod->max_idx));
+ add_block_to_list(cons->block_list, block, RTE_DIM(cons->block_list), &(cons->max_idx));
prod->nr_block++;
cons->nr_block++;
@@ -505,8 +507,8 @@ int vnode_cons_increase_unsafe(struct vnode * vnode, struct vnode_ops * ops,
return -1;
}
// insert block into prod block list and cons block list
- add_block_to_list(prod->block_list, block, MR_CONS_MAX, &(prod->max_idx));
- add_block_to_list(cons->block_list, block, MR_PROD_MAX, &(cons->max_idx));
+ add_block_to_list(prod->block_list, block, RTE_DIM(prod->block_list), &(prod->max_idx));
+ add_block_to_list(cons->block_list, block, RTE_DIM(cons->block_list), &(cons->max_idx));
prod->nr_block++;
cons->nr_block++;
@@ -527,7 +529,7 @@ void vnode_cons_block_gc_unsafe(struct vnode_cons * cons, struct vnode_ops * ops
{
struct tunnel_block* block = NULL;
int i = 0, ret = 0;
- for (i = 0; i < cons->max_idx + 1; i++)
+ for (i = 0; i < RTE_DIM(cons->block_list); i++)
{
block = cons->block_list[i];
if (block == NULL)
@@ -545,11 +547,6 @@ void vnode_cons_block_gc_unsafe(struct vnode_cons * cons, struct vnode_ops * ops
cons->nr_block--;
rte_mb();
}
-
- if (i == cons->max_idx)
- {
- cons->max_idx = renew_max_id(cons->block_list, MR_PROD_MAX);
- }
return;
}
@@ -558,7 +555,7 @@ void vnode_prod_block_gc_unsafe(struct vnode_prod * prod, struct vnode_ops * ops
{
struct tunnel_block* block = NULL;
int i = 0, ret = 0;
- for (i = 0; i < prod->max_idx + 1; i++)
+ for (i = 0; i < RTE_DIM(prod->block_list); i++)
{
block = prod->block_list[i];
if (block == NULL)
@@ -624,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;
@@ -750,10 +747,11 @@ int vnode_delete_prod(struct vnode_prod * prod, struct vnode_ops * ops)
struct tunnel_block* block = NULL;
struct vnode * vnode = prod->vnode;
+ struct vnode_cons * cons_iter;
__write_lock(&prod->vnode->rwlock);
// 删除引用的Block
- for (i = 0; i < prod->max_idx + 1; i++)
+ for (i = 0; i < RTE_DIM(prod->block_list); i++)
{
block = prod->block_list[i];
if (block == NULL)
@@ -765,7 +763,10 @@ int vnode_delete_prod(struct vnode_prod * prod, struct vnode_ops * ops)
prod->block_list[i] = NULL;
}
-
+ TAILQ_FOREACH(cons_iter, &vnode->prod_list, next)
+ {
+ cons_iter->max_idx=renew_max_id(cons_iter->block_list, RTE_DIM(cons_iter->block_list));
+ }
//remove Producer from VNode
struct vnode_prod_list * prod_list_head = &prod->vnode->prod_list;
TAILQ_REMOVE(prod_list_head, prod, next);
@@ -774,7 +775,7 @@ int vnode_delete_prod(struct vnode_prod * prod, struct vnode_ops * ops)
rte_mb();
synchronize_dataplane();
- struct vnode_cons * cons_iter;
+
TAILQ_FOREACH(cons_iter, &vnode->cons_list, next)
{
vnode_cons_block_gc_unsafe(cons_iter, ops);
@@ -791,9 +792,10 @@ int vnode_delete_cons(struct vnode_cons * cons, struct vnode_ops * ops)
struct vnode * vnode = cons->vnode;
struct tunnel_block* block = NULL;
-
+ struct vnode_prod * prod_iter;
+
// 删除引用的Block
- for (int i = 0; i < cons->max_idx + 1; i++)
+ for (int i = 0; i < RTE_DIM(cons->block_list); i++)
{
block = cons->block_list[i];
if (block == NULL)
@@ -803,6 +805,11 @@ 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();
@@ -812,7 +819,7 @@ int vnode_delete_cons(struct vnode_cons * cons, struct vnode_ops * ops)
cons->vnode->nr_cons--;
// 执行GC,移除所有生产者描述符中引用的Block
- struct vnode_prod * prod_iter;
+
TAILQ_FOREACH(prod_iter, &vnode->prod_list, next)
{
vnode_prod_block_gc_unsafe(prod_iter, ops);
@@ -870,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 "