diff options
| -rw-r--r-- | core/src/buffer.c | 3 | ||||
| -rw-r--r-- | runtime/src/event.c | 34 | ||||
| -rw-r--r-- | runtime/src/runtime.c | 4 | ||||
| -rw-r--r-- | service/include/sc_common.h | 5 | ||||
| -rw-r--r-- | service/src/config.c | 11 | ||||
| -rw-r--r-- | service/src/core.c | 15 | ||||
| -rw-r--r-- | service/src/register.c | 20 | ||||
| -rw-r--r-- | service/src/rxtx.c | 9 |
8 files changed, 97 insertions, 4 deletions
diff --git a/core/src/buffer.c b/core/src/buffer.c index 3038e6c..f4a83a2 100644 --- a/core/src/buffer.c +++ b/core/src/buffer.c @@ -278,6 +278,8 @@ void * marsio_buff_ctrlzone_data(marsio_buff_t *mr_buff, uint8_t id, uint8_t *si void marsio_buff_ctrlzone_set(marsio_buff_t *mr_buff, uint8_t id, void* ptr_data, uint8_t size) { struct mrb_zone_idx_t* cz = mrbuf_cz(mr_buff, id); + RTE_SET_USED(cz); + assert(id < mrbuf_cz_num(mr_buff)); assert(size <= cz->size); memcpy(mrbuf_cz_data(mr_buff, id), ptr_data, size); @@ -290,7 +292,6 @@ void * mr_buffer_ctrlzone(struct rte_mbuf * mr_buff, uint8_t id) return mrbuf_cz_data(mr_buff, id); } - int marsio_buff_malloc(marsio_buff_t *marsio_buff[], unsigned int nb_buff, __attribute__((unused))unsigned int flags, __attribute__((unused))int thread_seq) diff --git a/runtime/src/event.c b/runtime/src/event.c index 3e05a65..c13c7b0 100644 --- a/runtime/src/event.c +++ b/runtime/src/event.c @@ -93,6 +93,32 @@ int app_crash_cb_register(struct app_ev_manager * object, app_event_cb_t cb, return 0; } +/* ��������̣��������˳��������ӽ����˳� */ +void * app_crash_thread_monitor_service(void * arg) +{ + intptr_t conn_fd = (intptr_t)arg; + int ret = 0; + + char buf[MR_STRING_MAX]; + + // �ȴ����ӽ���
+ do {
+ ret = recv(conn_fd, buf, sizeof(buf), 0);
+ } while (ret == -1 && (errno == EINTR));
+ + // �������ӽ������������˳��� + if (ret == 0) + { + MR_LOG(ERR, BASE, "Service crashed, Exit the program.\n"); + close(conn_fd); + exit(EXIT_FAILURE); + } + + assert(0); + MR_LOG(ERR, BASE, "Crash monitor thread is exited. This is an error. \n"); + return (void *)NULL; +} + /* ע������¼�Դ */ int app_crash_raiser_register(struct app_ev_manager * object, const char * appsym) { @@ -113,6 +139,14 @@ int app_crash_raiser_register(struct app_ev_manager * object, const char * appsy return -2; } + pthread_t monitor; + ret = pthread_create(&monitor, NULL, app_crash_thread_monitor_service, (void *)(intptr_t)conn_fd); + if(ret < 0) + { + MR_LOG(ERR, BASE, "Create crash monitor thread failed : %s", strerror(errno)); + return -3; + } + struct crash_raiser_reg_cmd reg_cmd; snprintf(reg_cmd.appsym, sizeof(reg_cmd.appsym), "%s", appsym); reg_cmd.symlen = strlen(reg_cmd.appsym); diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 9472438..ac40178 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -67,7 +67,9 @@ void mr_runtime_slave_init() struct mr_global_ctx * g_ctx = mr_global_ctx_get(); assert(g_ctx != NULL); - struct mr_runtime_ctx * rt_ctx = (struct mr_runtime_ctx *)g_ctx->ctx_runtime; + struct mr_runtime_ctx * rt_ctx = (struct mr_runtime_ctx *)g_ctx->ctx_runtime; + RTE_SET_USED(rt_ctx); + assert(g_ctx->ctx_runtime != NULL); assert(rt_ctx->app_ctx != NULL); assert(rt_ctx->hwinfo_ctx != NULL); diff --git a/service/include/sc_common.h b/service/include/sc_common.h index d2254f3..eefa5c9 100644 --- a/service/include/sc_common.h +++ b/service/include/sc_common.h @@ -8,6 +8,7 @@ #include <mr_core.h> #include <mr_rtdev.h> #include <sk_stack.h> +#include <rte_keepalive.h> //TODO: �����豸��Ϣ�����ع������豸��Ϣ������һ���ṹ�� struct sc_device @@ -83,6 +84,8 @@ struct sc_param unsigned int distmode; /* Ӳ��RSS��ʽ */ unsigned int rssmode; + /* Keepalive �߳�������� */ + unsigned int keepalive; }; struct sc_ctrlzone @@ -124,4 +127,6 @@ struct sc_instance struct sk_instance * sk_instance; /* Э��ջ����Ӧ�þ�� */ struct sk_app_instance * sk_serv_instance; + /* keepalive��� */ + struct rte_keepalive * keepalive; };
\ No newline at end of file diff --git a/service/src/config.c b/service/src/config.c index 6ae17fe..09e26ea 100644 --- a/service/src/config.c +++ b/service/src/config.c @@ -368,6 +368,13 @@ int sc_config_burst_info(const char * cfg, struct sc_instance * instance) return 0; } +int sc_config_keeplive_info(const char * cfg, struct sc_instance * instance) +{ + struct sc_param * sc_param = &instance->sc_param; + MESA_load_profile_uint_def(cfg, "keepalive", "check_spinlock", &sc_param->keepalive, 0); + return 0; +} + int sc_config_ldbc_dist_mode(const char * cfgfile, struct sc_instance * instance) { struct sc_param * sc_param = &instance->sc_param; @@ -407,6 +414,8 @@ void sc_stage_config(struct sc_instance * instance) "Please check configure file %s, Failed. ", cfgfile); MR_CHECK(sc_config_ctrlzone(cfgfile, instance) >= 0, "Please check configure file %s, Failed. ", cfgfile); - + MR_CHECK(sc_config_keeplive_info(cfgfile, instance) >= 0, + "Please check configure file %s, Failed. ", cfgfile); + return; }
\ No newline at end of file diff --git a/service/src/core.c b/service/src/core.c index 8572a8a..a0393ef 100644 --- a/service/src/core.c +++ b/service/src/core.c @@ -231,6 +231,20 @@ void sc_stage_init(struct sc_instance * instance) extern int sc_monit_loop(struct sc_instance * sc_instance); +int sc_keepalive_loop(struct sc_instance * sc_instance) +{ + if (sc_instance->keepalive == NULL) return 0; + rte_keepalive_dispatch_pings(NULL, sc_instance->keepalive); + return 0; +} + +void sc_keepalive_failure_handler(void *data, const int id_core) +{ + MR_LOG(ERR, SERVICE, "Thread %d is dead, Exit service. \n", id_core); + exit(EXIT_FAILURE); + return; +} + void * sc_loop_thread(void * args) { struct sc_instance * instance = (struct sc_instance *)args; @@ -239,6 +253,7 @@ void * sc_loop_thread(void * args) while(1) { sc_monit_loop(instance); + sc_keepalive_loop(instance); sleep(1); } } diff --git a/service/src/register.c b/service/src/register.c index c0d48b9..63b3d07 100644 --- a/service/src/register.c +++ b/service/src/register.c @@ -280,6 +280,23 @@ int sc_app_register(struct sc_instance * instance) return 0; } +extern void sc_keepalive_failure_handler(void *data, const int id_core); + +int sc_keepalive_register(struct sc_instance * instance) +{ + if (!instance->sc_param.keepalive) return 0; + + instance->keepalive = rte_keepalive_create(sc_keepalive_failure_handler, instance); + if(instance->keepalive == NULL) + { + MR_LOG(ERR, SERVICE, "Cannot register spinlock check info. \n"); + return -1; + } + + MR_LOG(INFO, SERVICE, "Spinlock check registerd.\n"); + return 0; +} + void sc_stage_register(struct sc_instance * instance) { MR_CHECK(sc_core_instance_register(instance) >= 0, @@ -294,5 +311,8 @@ void sc_stage_register(struct sc_instance * instance) "Cannot register process, Failed. Please recheck runtime log. "); MR_CHECK(sc_device_register(instance) >= 0, "Cannot register device, Failed. Please recheck runtime log. "); + MR_CHECK(sc_keepalive_register(instance) >= 0, + "Cannot register device, Failed. Please recheck runtime log. "); + return; }
\ No newline at end of file diff --git a/service/src/rxtx.c b/service/src/rxtx.c index ca28dbe..ac114d0 100644 --- a/service/src/rxtx.c +++ b/service/src/rxtx.c @@ -138,10 +138,14 @@ clean: } void sc_thread_rxtx_loop(struct sc_instance * instance, thread_id_t tid) -{ +{ PERF_BEGIN(PERF_SC_LOOP); unsigned int sz_burst = instance->sc_param.sz_burst; + // �߳�������� + if (instance->keepalive) + rte_keepalive_mark_alive(instance->keepalive); + struct sc_device * device_iter; TAILQ_FOREACH(device_iter, &instance->device_list, next) { @@ -163,6 +167,9 @@ void * sc_runtime_thread(void * args) mr_app_manager_thread_register(); struct sc_instance * instance = (struct sc_instance *)args; thread_id_t tid = mr_thread_id(); + + if (instance->keepalive) + rte_keepalive_register_core(instance->keepalive, tid); MR_LOG(INFO, SERVICE, "Thread %d Running...\n", mr_thread_id()); |
