diff options
author | 2017-01-23 14:06:52 +0200 | |
---|---|---|
committer | 2017-01-23 14:07:49 +0200 | |
commit | aee39c9dd61944b3be3c20b4e3f9ec4d57602d01 (patch) | |
tree | 46727bcb8dbc26ac64b80cee1ad7c07159890055 | |
parent | 193013a82048fe62319208e26fbaa4fb101a431c (diff) |
enable TRex to run with --rt : real time priority for DP and RX cores
Signed-off-by: imarom <imarom@cisco.com>
-rwxr-xr-x | scripts/trex_show_threads.py | 6 | ||||
-rwxr-xr-x | src/bp_sim.h | 8 | ||||
-rw-r--r-- | src/main_dpdk.cpp | 37 |
3 files changed, 45 insertions, 6 deletions
diff --git a/scripts/trex_show_threads.py b/scripts/trex_show_threads.py index 1824d073..d0e34fe9 100755 --- a/scripts/trex_show_threads.py +++ b/scripts/trex_show_threads.py @@ -17,7 +17,8 @@ def read_task_stats (task_path): stat_data = open(stat, 'r').readline().split() stats_dict['last_sched_cpu'] = stat_data[-14] - + stats_dict['priority'] = stat_data[17] if stat_data[43] == '0' else 'RT' + return stats_dict @@ -26,7 +27,7 @@ def show_threads (pid): task_paths = ["{0}/{1}".format(process_dir, task) for task in os.listdir(process_dir)] - header = [ 'Task Name', 'PID', 'Allowed CPU', 'Last Sched CPU', 'Asked Ctx Switch', 'Forced Ctx Switch'] + header = [ 'Task Name', 'PID', 'Priority', 'Allowed CPU', 'Last Sched CPU', 'Asked Ctx Switch', 'Forced Ctx Switch'] for x in header: print('{:^20}'.format(x)), print("") @@ -41,6 +42,7 @@ def show_threads (pid): # name print("{:<20}".format(task['name'])), print("{:^20}".format(task['pid'])), + print("{:^20}".format(task['priority'])), print("{:^20}".format(task['cpus_allowed_list'])), print("{:^20}".format(task['last_sched_cpu'])), print("{:^20}".format(task['voluntary_ctxt_switches'])), diff --git a/src/bp_sim.h b/src/bp_sim.h index 282e7fe4..217446ed 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -628,6 +628,14 @@ public: return (btGetMaskBit32(m_flags1, 9, 9) ? true : false); } + void set_rt_prio_mode(bool enable) { + btSetMaskBit32(m_flags1, 10, 10, (enable ? 1 : 0) ); + } + + bool get_rt_prio_mode() { + return (btGetMaskBit32(m_flags1, 10, 10) ? true : false); + } + public: void Dump(FILE *fd); diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index aa31cf0b..f58e403f 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -713,7 +713,8 @@ enum { OPT_HELP, OPT_ARP_REF_PER, OPT_NO_OFED_CHECK, OPT_NO_SCAPY_SERVER, - OPT_ACTIVE_FLOW + OPT_ACTIVE_FLOW, + OPT_RT }; /* these are the argument types: @@ -774,6 +775,7 @@ static CSimpleOpt::SOption parser_options[] = { OPT_ARP_REF_PER, "--arp-refresh-period", SO_REQ_SEP }, { OPT_NO_OFED_CHECK, "--no-ofed-check", SO_NONE }, { OPT_NO_SCAPY_SERVER, "--no-scapy-server", SO_NONE }, + { OPT_RT, "--rt", SO_NONE }, SO_END_OF_OPTIONS }; @@ -828,6 +830,7 @@ static int usage(){ printf(" --no-ofed-check : Disable the check of OFED version \n"); printf(" --no-scapy-server : Disable Scapy server implicit start at stateless \n"); printf(" --no-watchdog : Disable watchdog \n"); + printf(" --rt : Run TRex DP/RX cores in realtime priority \n"); printf(" -p : Send all flow packets from the same interface (choosed randomly between client ad server ports) without changing their src/dst IP \n"); printf(" -pm : Platform factor. If you have splitter in the setup, you can multiply the total results by this factor \n"); printf(" e.g --pm 2.0 will multiply all the results bps in this factor \n"); @@ -956,6 +959,9 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t po->preview.set_ipv6_mode_enable(true); break; + case OPT_RT: + po->preview.set_rt_prio_mode(true); + break; case OPT_LEARN : po->m_learn_mode = CParserOption::LEARN_MODE_IP_OPTION; @@ -4845,8 +4851,20 @@ int CGlobalTRex::run_in_master() { int CGlobalTRex::run_in_rx_core(void){ + CPreviewMode *lp = &CGlobalInfo::m_options.preview; + rte_thread_setname(pthread_self(), "TRex RX"); - + + /* set RT mode if set */ + if (lp->get_rt_prio_mode()) { + struct sched_param param; + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) != 0) { + perror("setting RT priroity mode on RX core failed with error"); + exit(EXIT_FAILURE); + } + } + if (get_is_stateless()) { m_sl_rx_running = true; m_rx_sl.start(); @@ -4863,11 +4881,22 @@ int CGlobalTRex::run_in_rx_core(void){ int CGlobalTRex::run_in_core(virtual_thread_id_t virt_core_id){ std::stringstream ss; - + CPreviewMode *lp = &CGlobalInfo::m_options.preview; + ss << "Trex DP core " << int(virt_core_id); rte_thread_setname(pthread_self(), ss.str().c_str()); + + /* set RT mode if set */ + if (lp->get_rt_prio_mode()) { + struct sched_param param; + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) != 0) { + perror("setting RT priroity mode on DP core failed with error"); + exit(EXIT_FAILURE); + } + } - CPreviewMode *lp=&CGlobalInfo::m_options.preview; + if ( lp->getSingleCore() && (virt_core_id==2 ) && (lp-> getCores() ==1) ){ |