diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index 88a3c9db6..71dba9db1 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -99,10 +99,10 @@ static uint16_t rss_reta_size[RTE_MAX_ETHPORTS]; static inline int send_single_packet(struct rte_mbuf *m, uint8_t port); struct ff_msg_ring { - char ring_name[FF_MAX][RTE_RING_NAMESIZE]; + char ring_name[FF_MSG_NUM][RTE_RING_NAMESIZE]; /* ring[0] for lcore recv msg, other send */ /* ring[1] for lcore send msg, other read */ - struct rte_ring *ring[FF_MAX]; + struct rte_ring *ring[FF_MSG_NUM]; } __rte_cache_aligned; static struct ff_msg_ring msg_ring[RTE_MAX_LCORE]; @@ -447,7 +447,7 @@ init_msg_ring(void) if (msg_ring[i].ring[0] == NULL) rte_panic("create ring::%s failed!\n", msg_ring[i].ring_name[0]); - for (j = FF_SYSCTL; j < FF_MAX; j++) { + for (j = FF_SYSCTL; j < FF_MSG_NUM; j++) { snprintf(msg_ring[i].ring_name[j], RTE_RING_NAMESIZE, "%s%u_%u", FF_MSG_RING_OUT, i, j); msg_ring[i].ring[j] = create_ring(msg_ring[i].ring_name[j], diff --git a/lib/ff_msg.h b/lib/ff_msg.h index 0216d73c6..d9a7cfa7f 100644 --- a/lib/ff_msg.h +++ b/lib/ff_msg.h @@ -46,9 +46,9 @@ enum FF_MSG_TYPE { FF_TRAFFIC, /* - * to add other msg type before FF_MAX + * to add other msg type before FF_MSG_NUM */ - FF_MAX, + FF_MSG_NUM, }; struct ff_sysctl_args { diff --git a/tools/README.md b/tools/README.md index baef7e97f..72337d7c7 100644 --- a/tools/README.md +++ b/tools/README.md @@ -110,23 +110,23 @@ Examples: |---------|---------|---------|---------|---------------| | proc_id| idle| sys| usr| loop| |---------|---------|---------|---------|---------------| -| total| 99.89%| 0.00%| 0.11%| 26384| -| 0| 99.88%| 0.00%| 0.11%| 6597| -| 1| 99.89%| 0.00%| 0.11%| 6598| -| 2| 99.89%| 0.00%| 0.11%| 6593| -| 3| 99.89%| 0.00%| 0.11%| 6596| +| 0| 92.44%| 4.00%| 3.56%| 13427| +| 1| 92.18%| 4.21%| 3.61%| 14035| +| 2| 92.19%| 4.19%| 3.62%| 13929| +| 3| 92.33%| 4.14%| 3.53%| 13938| +| total| 369.14%| 16.54%| 14.32%| 55329| | | | | | | -| total| 99.89%| 0.00%| 0.11%| 26385| -| 0| 99.89%| 0.00%| 0.11%| 6597| -| 1| 99.89%| 0.00%| 0.11%| 6596| -| 2| 99.89%| 0.00%| 0.11%| 6597| -| 3| 99.88%| 0.00%| 0.12%| 6595| +| 0| 92.27%| 4.10%| 3.63%| 13438| +| 1| 92.03%| 4.27%| 3.70%| 13906| +| 2| 92.08%| 4.24%| 3.68%| 13817| +| 3| 92.28%| 4.15%| 3.57%| 13759| +| total| 368.65%| 16.77%| 14.58%| 54920| | | | | | | -| total| 99.89%| 0.00%| 0.11%| 26390| -| 0| 99.89%| 0.00%| 0.11%| 6599| -| 1| 99.89%| 0.00%| 0.11%| 6597| -| 2| 99.89%| 0.00%| 0.11%| 6598| -| 3| 99.89%| 0.00%| 0.11%| 6596| +| 0| 91.88%| 4.30%| 3.81%| 13802| +| 1| 91.94%| 4.32%| 3.74%| 13928| +| 2| 92.10%| 4.24%| 3.66%| 13856| +| 3| 92.30%| 4.14%| 3.56%| 13708| +| total| 368.22%| 17.00%| 14.77%| 55294| | | | | | | ``` diff --git a/tools/top/top.c b/tools/top/top.c index fd721a8e3..7433868c3 100644 --- a/tools/top/top.c +++ b/tools/top/top.c @@ -5,7 +5,8 @@ void usage(void) { printf("Usage:\n"); - printf(" top [-p ] [-P ] [-d ] [-n \n"); + printf(" top [-p ] [-P ] " + "[-d ] [-n ]\n"); } int cpu_status(struct ff_top_args *top) @@ -51,15 +52,16 @@ int main(int argc, char **argv) { int ch, delay = 1, n = 0; unsigned int i, j; - struct ff_top_args top = {0, 0, 0, 0, 0}, otop; - struct ff_top_args ptop[RTE_MAX_LCORE], potop[RTE_MAX_LCORE];; + struct ff_top_args top, otop; + struct ff_top_args ptop[RTE_MAX_LCORE], potop[RTE_MAX_LCORE]; int proc_id = 0, max_proc_id = -1; + float sys, usr, idle; float psys, pusr, pidle; + unsigned long loops, ploops; ff_ipc_init(); #define TOP_DIFF(member) (top.member - otop.member) -#define TOP_ADD_P(member) (top.member += ptop[j].member - potop[j].member) #define TOP_DIFF_P(member) (ptop[j].member - potop[j].member) while ((ch = getopt(argc, argv, "hp:P:d:n:")) != -1) { @@ -102,53 +104,59 @@ int main(int argc, char **argv) } if (i) { - psys = TOP_DIFF(sys_tsc) / (TOP_DIFF(work_tsc) / 100.0); - pusr = TOP_DIFF(usr_tsc) / (TOP_DIFF(work_tsc) / 100.0); - pidle = TOP_DIFF(idle_tsc) / (TOP_DIFF(work_tsc) / 100.0); + sys = TOP_DIFF(sys_tsc) / (TOP_DIFF(work_tsc) / 100.0); + usr = TOP_DIFF(usr_tsc) / (TOP_DIFF(work_tsc) / 100.0); + idle = TOP_DIFF(idle_tsc) / (TOP_DIFF(work_tsc) / 100.0); - printf("|%8.2f%%|%8.2f%%|%8.2f%%|%15lu|\n", pidle, psys, pusr, TOP_DIFF(loops)); + printf("|%8.2f%%|%8.2f%%|%8.2f%%|%15lu|\n", + idle, sys, usr, TOP_DIFF(loops)); } }else { /* * get and show cpu usage from proc_id to max_proc_id. */ + if (i % (40 / (max_proc_id - proc_id + 2)) == 0) { + printf("|---------|---------|---------|" + "---------|---------------|\n"); + printf("|%9s|%9s|%9s|%9s|%15s|\n", + "proc_id", "idle", "sys", "usr", "loop"); + printf("|---------|---------|---------|" + "---------|---------------|\n"); + } + + sys = usr = idle = loops = 0; for (j = proc_id; j <= max_proc_id; j++) { + potop[j] = ptop[j]; + ff_set_proc_id(j); if (cpu_status(&ptop[j])) { printf("fstack ipc message error, proc id:%d!\n", j); return -1; } - TOP_ADD_P(idle_tsc); - TOP_ADD_P(loops); - TOP_ADD_P(sys_tsc); - TOP_ADD_P(usr_tsc); - TOP_ADD_P(work_tsc); - } + if (i) { + psys = TOP_DIFF_P(sys_tsc) / \ + (TOP_DIFF_P(work_tsc) / 100.0); + pusr = TOP_DIFF_P(usr_tsc) / \ + (TOP_DIFF_P(work_tsc) / 100.0); + pidle = TOP_DIFF_P(idle_tsc) / \ + (TOP_DIFF_P(work_tsc) / 100.0); + ploops = TOP_DIFF_P(loops); + printf("|%9d|%8.2f%%|%8.2f%%|%8.2f%%|%15lu|\n", + j, pidle, psys, pusr, ploops); - if (i % (40 / (max_proc_id - proc_id + 2)) == 0) { - printf("|---------|---------|---------|---------|---------------|\n"); - printf("|%9s|%9s|%9s|%9s|%15s|\n", "proc_id", "idle", "sys", "usr", "loop"); - printf("|---------|---------|---------|---------|---------------|\n"); - } + sys += psys; + usr += pusr; + idle += pidle; + loops += ploops; - if (i) { - psys = TOP_DIFF(sys_tsc) / (TOP_DIFF(work_tsc) / 100.0); - pusr = TOP_DIFF(usr_tsc) / (TOP_DIFF(work_tsc) / 100.0); - pidle = TOP_DIFF(idle_tsc) / (TOP_DIFF(work_tsc) / 100.0); - printf("|%9s|%8.2f%%|%8.2f%%|%8.2f%%|%15lu|\n", "total", pidle, psys, pusr, TOP_DIFF(loops)); - - for (j = proc_id; j <= max_proc_id; j++) { - psys = TOP_DIFF_P(sys_tsc) / (TOP_DIFF_P(work_tsc) / 100.0); - pusr = TOP_DIFF_P(usr_tsc) / (TOP_DIFF_P(work_tsc) / 100.0); - pidle = TOP_DIFF_P(idle_tsc) / (TOP_DIFF_P(work_tsc) / 100.0); - printf("|%9d|%8.2f%%|%8.2f%%|%8.2f%%|%15lu|\n", j, pidle, psys, pusr, TOP_DIFF_P(loops)); + if (j == max_proc_id) { + printf("|%9s|%8.2f%%|%8.2f%%|%8.2f%%|%15lu|\n", + "total", idle, sys, usr, loops); + printf("| | | |" + " | |\n"); + } } - printf("| | | | | |\n"); - } - - for (j = proc_id; j <= max_proc_id; j++) { - potop[j] = ptop[j]; } }