diff options
| author | Qiuwen Lu <[email protected]> | 2017-11-06 16:17:34 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2017-11-06 16:17:34 +0800 |
| commit | 58db7c979a7b8899600c5d7c758e5a32d9eefa9f (patch) | |
| tree | f41ff8b405adcee2e108b0ccab8b93c9fdae0ced | |
| parent | 3b1b53e49d84a42132e6f502ba900b59e56ea657 (diff) | |
配合WY项目调试,增加多种Debug功能:v4.2.31-20171106
- MRB申请、释放计数,直接计入本线程申请、释放情况计数,不根据外部提交的线程号、SOCKET号统计;
- 增加SERVICE进程接管SIGSEGV信号功能,打印栈;
- 增加monit_stream输出应用申请、释放MBUF情况记录,以便外部脚本记录历史情况;
- 增加service进程、tunnat进程崩溃时输出coredump的设置。
| -rw-r--r-- | app/src/mrb.c | 11 | ||||
| -rw-r--r-- | service/include/sc_common.h | 2 | ||||
| -rw-r--r-- | service/src/core.c | 28 | ||||
| -rw-r--r-- | tools/monit_stream/monit_stream.py | 43 | ||||
| -rw-r--r-- | tools/systemd/mrtunnat.service.in | 6 | ||||
| -rw-r--r-- | tools/systemd/mrzcpd.service.in | 1 |
6 files changed, 84 insertions, 7 deletions
diff --git a/app/src/mrb.c b/app/src/mrb.c index 0b86419..2adcfb7 100644 --- a/app/src/mrb.c +++ b/app/src/mrb.c @@ -64,9 +64,7 @@ int marsio_buff_malloc_device(struct mr_vdev * vdev, marsio_buff_t *marsio_buff[ for(int i = 0; i < nr_mbufs; i++) marsio_buff_reset(marsio_buff[i]); - if (thread_id == LCORE_ID_ANY) - thread_id = thread_info.thread_id; - + thread_id = thread_info.thread_id; vdev->instance->stat[thread_id].mbuf_alloc_count += nr_mbufs; return ret; } @@ -87,7 +85,7 @@ void marsio_buff_free(struct mr_instance * instance, marsio_buff_t *marsio_buff[ rte_pktmbuf_free((struct rte_mbuf *)marsio_buff[i]); } - if (thread_id == LCORE_ID_ANY) thread_id = thread_info.thread_id; + thread_id = thread_info.thread_id; instance->stat[thread_id].mbuf_free_count += nr_mbufs; return; } @@ -403,7 +401,10 @@ static inline struct rte_mbuf * __copy_on_write_common( assert(__cloned_mbuf != NULL); /* 对于传入的报文,释放所有权,外面用户不应该再使用传入的MBUF */ - rte_pktmbuf_free(__mbuf); + unsigned int thread_id = thread_info.thread_id; + instance->stat[thread_id].mbuf_free_count += 1; + + rte_pktmbuf_free(__mbuf); return __cloned_mbuf; } diff --git a/service/include/sc_common.h b/service/include/sc_common.h index 4208e77..add2141 100644 --- a/service/include/sc_common.h +++ b/service/include/sc_common.h @@ -65,6 +65,8 @@ struct sc_main /* 数据面:IDLE操作门限 */ unsigned int idle_threshold; + /* SIGSEGV状态接管 */ + unsigned int en_sig_segv_takeover; /* 异常状态检测标志位,死锁检测 */ unsigned int en_spinlock_check; /* 异常状态检测标志位,控制死锁检测 */ diff --git a/service/src/core.c b/service/src/core.c index 065bb18..9dbaaa2 100644 --- a/service/src/core.c +++ b/service/src/core.c @@ -102,6 +102,10 @@ const char service_git_version[] = ""; #define MR_SERVICE_DEFAULT_PKT_LATENCY_LCORE_ID 0 #endif +#ifndef MR_SERVICE_DEFAULT_SIGSEGV_TAKEOVER +#define MR_SERVICE_DEFAULT_SIGSEGV_TAKEOVER 0 +#endif + unsigned int g_logger_to_stdout = 1; unsigned int g_logger_level = LOG_DEBUG; unsigned int g_monit_interval = 1; @@ -509,6 +513,10 @@ static int sc_g_config_init(struct sc_main * sc) MESA_load_profile_uint_def(sc->local_cfgfile, "debug", "pkt_latency_lcore_id", &sc->pkt_latency_lcore_id, MR_SERVICE_DEFAULT_PKT_LATENCY); + /* SIGSERV接管选项 */ + MESA_load_profile_uint_def(sc->local_cfgfile, "debug", "sigsegv_takeover", + &sc->en_sig_segv_takeover, MR_SERVICE_DEFAULT_SIGSEGV_TAKEOVER); + return RT_SUCCESS; } @@ -611,6 +619,12 @@ static void signal_handler(int signum) return; } +static void signal_handler_sigsegv() +{ + rte_panic("SIGSERV happens, MRZCPD is abort. \n"); + return; +} + extern int hwinfo_init(struct sc_main * sc); extern int phydev_init(struct sc_main * sc); extern int phydev_early_init(struct sc_main * sc); @@ -702,6 +716,11 @@ int main(int argc, char * argv[]) ret = EXIT_FAILURE; goto quit; } +#if MR_TEST_SIGSEGV + char * __ptr_null = NULL; + *__ptr_null = 0; +#endif + /* 加载EAL选项 */ sc_eal_init(sc, argv[0]); if (sc_g_config_init(sc) != RT_SUCCESS) @@ -710,6 +729,15 @@ int main(int argc, char * argv[]) ret = EXIT_FAILURE; goto quit; } + /* SIGSERV signal takeover + if the options is opened, the program will print the backtrace while + handle the signal. + */ + if (sc->en_sig_segv_takeover) + { + signal(SIGSEGV, signal_handler_sigsegv); + } + if (sc_ctrlmsg_init(sc) != RT_SUCCESS) { MR_ERROR("Ctrlmsg module initialization failed. "); diff --git a/tools/monit_stream/monit_stream.py b/tools/monit_stream/monit_stream.py index 9c3571d..d0ff239 100644 --- a/tools/monit_stream/monit_stream.py +++ b/tools/monit_stream/monit_stream.py @@ -24,6 +24,16 @@ TITLE_VECTOR_RX = ['RxPkts', 'RxBits', 'RxDrops'] TITLE_VECTOR_TX = ['TxPkts', 'TxBits', 'TxDrops'] TITLE_VECTOR_FTX = ['FTxPkts', 'FTxBits', 'FTxDrops'] +TITLE_APP_STAT = ['PKTRx', 'PKTTx', 'MbufAlloc', 'MbufFree', 'MbufInUse'] + +TITLE_APP_MAP = { + 'PKTRx' : 'packet_recv_count', + 'PKTTx' : 'packet_send_count', + 'MbufAlloc' : 'mbuf_alloc_count', + 'MbufFree' : 'mbuf_free_count', + 'MbufInUse' : 'mbuf_in_use_count'
+ } + TITLE_MAP = { 'RxOnline' : 'rx_on_line', 'RxPkts' : 'rx_deliver', 'RxDrops' : 'rx_missed', @@ -180,6 +190,33 @@ def dump_human_table(json_fp, appsym, devsym, title_vector_rx, title_vector_tx, print(table_phydev) +def dump_status_table(json_fp, appsym): + json_fp_appstat = json_fp['appstat'] + nr_stream = len(json_fp['appstat']['packet_recv_count']) + + print('\nTime: %s, App: %s' % (time.strftime('%c'), appsym)) + table_phydev = prettytable.PrettyTable(['TID'] + TITLE_APP_STAT, + vertical_char=' ',horizontal_char = '-', junction_char=' ') + + for item in['TID'] + TITLE_APP_STAT: + table_phydev.align[item] = 'r' + + ValueListSum = [0] * len(TITLE_APP_STAT) + + for tid in range(nr_stream): + ValueList = [] + for item in TITLE_APP_STAT: + value = json_fp_appstat[TITLE_APP_MAP[item]][tid] + ValueList.append(value) + + table_phydev.add_row([tid] + ValueList) + for i,v in enumerate(ValueList): + ValueListSum[i] += v + + table_phydev.add_row(['Total'] + ValueListSum) + print(table_phydev) + + def setup_argv_parser(applist): parser = argparse.ArgumentParser(description='Marsio ZeroCopy Tools -- Monitor stream information', @@ -201,6 +238,8 @@ def setup_argv_parser(applist): action='store_true', default = 0) parser.add_argument('--per-stream', help = 'print per thread/stream value', action='store_true', default = 0) + parser.add_argument('--status', help = 'print application running status', + action='store_true', default = 0) parser.add_argument('app', metavar='APP', help = 'the name of slave application', nargs = '*', default=applist) @@ -272,6 +311,10 @@ def main(): check_vdev_options(json_fp, r_option) user_interface = r_option.interface if r_option.interface != None else list_all_vdev(json_fp) + if r_option.status: + dump_status_table(json_fp, appsym) + continue + if not r_option.per_stream: dump_summary_table(json_fp, appsym, user_interface, title_vector_rx, title_vector_tx, r_option.human_readable, r_option.speed) diff --git a/tools/systemd/mrtunnat.service.in b/tools/systemd/mrtunnat.service.in index 6990543..c0af476 100644 --- a/tools/systemd/mrtunnat.service.in +++ b/tools/systemd/mrtunnat.service.in @@ -1,14 +1,16 @@ [Unit] Description=Marsio ZeroCopy Tunnel NAT Daemon -Requires=mrzcpd.service -After=mrzcpd.service +Requires=mrenv.service +After=mrenv.service [Service] EnvironmentFile=/etc/sysconfig/mrzcpd +ExecStartPre=/usr/bin/systemctl is-active mrzcpd ExecStart=@MR_INSTALL_BINDIR@/mrtunnat -c @MR_INSTALL_SYSCONFDIR@/mrtunnat.conf Restart=always RestartSec=5s Type=notify +LimitCORE=infinity [Install] WantedBy=multi-user.target
\ No newline at end of file diff --git a/tools/systemd/mrzcpd.service.in b/tools/systemd/mrzcpd.service.in index 1952b3c..9b836fb 100644 --- a/tools/systemd/mrzcpd.service.in +++ b/tools/systemd/mrzcpd.service.in @@ -17,6 +17,7 @@ Restart=always RestartSec=5s WatchdogSec=5s Type=notify +LimitCORE=infinity [Install] WantedBy=multi-user.target
\ No newline at end of file |
