summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/bp_sim.cpp5
-rwxr-xr-xsrc/bp_sim.h2
-rw-r--r--src/latency.cpp14
-rw-r--r--src/latency.h2
-rw-r--r--src/main_dpdk.cpp11
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.cpp14
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.h2
-rwxr-xr-xsrc/utl_cpuu.cpp28
-rwxr-xr-xsrc/utl_cpuu.h26
9 files changed, 55 insertions, 49 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index f9cb3220..ccd62f0e 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -3727,6 +3727,9 @@ inline int CNodeGenerator::teardown(CFlowGenListPerThread * thread,
bool always,
double &old_offset,
double offset){
+
+ thread->m_cpu_dp_u.commit1();
+
/* to do */
if ( thread->is_terminated_by_master() ) {
return (0);
@@ -4511,7 +4514,7 @@ double CFlowGenList::GetCpuUtil(){
}
-void CFlowGenList::Update(){
+void CFlowGenList::UpdateFast(){
int i;
for (i=0; i<(int)m_threads_info.size(); i++) {
diff --git a/src/bp_sim.h b/src/bp_sim.h
index bdca7703..6c8911e5 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -3831,7 +3831,7 @@ public:
void Dump(FILE *fd);
void DumpCsv(FILE *fd);
void DumpPktSize();
- void Update();
+ void UpdateFast();
double GetCpuUtil();
public:
diff --git a/src/latency.cpp b/src/latency.cpp
index fff7935d..0303e89a 100644
--- a/src/latency.cpp
+++ b/src/latency.cpp
@@ -689,17 +689,17 @@ void CLatencyManager::try_rx(){
for (i=0; i<m_max_ports; i++) {
CLatencyManagerPerPort * lp=&m_ports[i];
rte_mbuf_t * m;
- m_cpu_dp_u.start_work();
/* try to read 64 packets clean up the queue */
uint16_t cnt_p = lp->m_io->rx_burst(rx_pkts, 64);
if (cnt_p) {
+ m_cpu_dp_u.start_work1();
int j;
for (j=0; j<cnt_p; j++) {
m=rx_pkts[j] ;
handle_rx_pkt(lp,m);
}
/* commit only if there was work to do ! */
- m_cpu_dp_u.commit();
+ m_cpu_dp_u.commit1();
}/* if work */
}// all ports
}
@@ -762,12 +762,12 @@ void CLatencyManager::start(int iter) {
break;
case CGenNode::FLOW_PKT:
- m_cpu_dp_u.start_work();
+ m_cpu_dp_u.start_work1();
send_pkt_all_ports();
m_p_queue.pop();
node->m_time += m_delta_sec;
m_p_queue.push(node);
- m_cpu_dp_u.commit();
+ m_cpu_dp_u.commit1();
break;
}
@@ -911,8 +911,12 @@ void CLatencyManager::rx_check_dump_json(std::string & json){
}
}
-void CLatencyManager::update(){
+
+void CLatencyManager::update_fast(){
m_cpu_cp_u.Update() ;
+}
+
+void CLatencyManager::update(){
for (int i=0; i<m_max_ports; i++) {
CLatencyManagerPerPort * lp=&m_ports[i];
lp->m_port.m_hist.update();
diff --git a/src/latency.h b/src/latency.h
index f5f90cf9..259bb221 100644
--- a/src/latency.h
+++ b/src/latency.h
@@ -356,6 +356,8 @@ public:
return ( m_pkt_gen.get_payload_offset() );
}
void update();
+ void update_fast();
+
void dump_json(std::string & json ); // dump to json
void dump_json_v2(std::string & json );
void DumpRxCheckVerification(FILE *fd,uint64_t total_tx_rx_check);
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 092bd133..fd5a1de8 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -3424,7 +3424,6 @@ void CGlobalTRex::update_stats(){
total_open_flows += lpt->m_stats.m_total_open_flows ;
}
m_last_total_cps = m_cps.add(total_open_flows);
- m_fl.Update();
}
@@ -3841,6 +3840,14 @@ bool
CGlobalTRex::handle_fast_path() {
/* check from messages from DP */
check_for_dp_messages();
+ // update CPU%
+ m_fl.UpdateFast();
+
+ if (get_is_stateless()) {
+ m_rx_sl.update_cpu_util();
+ }else{
+ m_mg.update_fast();
+ }
if ( is_all_cores_finished() ) {
return false;
@@ -3861,7 +3868,7 @@ int CGlobalTRex::run_in_master() {
uint32_t slow_path_counter = 0;
- const int FASTPATH_DELAY_MS = 20;
+ const int FASTPATH_DELAY_MS = 10;
const int SLOWPATH_DELAY_MS = 500;
while ( true ) {
diff --git a/src/stateless/rx/trex_stateless_rx_core.cpp b/src/stateless/rx/trex_stateless_rx_core.cpp
index 2132fe9f..f7658e53 100644
--- a/src/stateless/rx/trex_stateless_rx_core.cpp
+++ b/src/stateless/rx/trex_stateless_rx_core.cpp
@@ -178,18 +178,18 @@ void CRxCoreStateless::flush_rx() {
for (i = 0; i < m_max_ports; i++) {
CLatencyManagerPerPort * lp = &m_ports[i];
rte_mbuf_t * m;
- m_cpu_dp_u.start_work();
/* try to read 64 packets clean up the queue */
uint16_t cnt_p = lp->m_io->rx_burst(rx_pkts, 64);
total_pkts += cnt_p;
if (cnt_p) {
+ m_cpu_dp_u.start_work1();
int j;
for (j = 0; j < cnt_p; j++) {
m = rx_pkts[j];
rte_pktmbuf_free(m);
}
/* commit only if there was work to do ! */
- m_cpu_dp_u.commit();
+ m_cpu_dp_u.commit1();
}/* if work */
}// all ports
}
@@ -200,11 +200,11 @@ int CRxCoreStateless::try_rx() {
for (i = 0; i < m_max_ports; i++) {
CLatencyManagerPerPort * lp = &m_ports[i];
rte_mbuf_t * m;
- m_cpu_dp_u.start_work();
/* try to read 64 packets clean up the queue */
uint16_t cnt_p = lp->m_io->rx_burst(rx_pkts, 64);
total_pkts += cnt_p;
if (cnt_p) {
+ m_cpu_dp_u.start_work1();
int j;
for (j = 0; j < cnt_p; j++) {
m = rx_pkts[j];
@@ -212,7 +212,7 @@ int CRxCoreStateless::try_rx() {
rte_pktmbuf_free(m);
}
/* commit only if there was work to do ! */
- m_cpu_dp_u.commit();
+ m_cpu_dp_u.commit1();
}/* if work */
}// all ports
return total_pkts;
@@ -249,7 +249,11 @@ void CRxCoreStateless::set_working_msg_ack(bool val) {
sanb_smp_memory_barrier();
}
-double CRxCoreStateless::get_cpu_util() {
+
+void CRxCoreStateless::update_cpu_util(){
m_cpu_cp_u.Update();
+}
+
+double CRxCoreStateless::get_cpu_util() {
return m_cpu_cp_u.GetVal();
}
diff --git a/src/stateless/rx/trex_stateless_rx_core.h b/src/stateless/rx/trex_stateless_rx_core.h
index b78256c2..a372a578 100644
--- a/src/stateless/rx/trex_stateless_rx_core.h
+++ b/src/stateless/rx/trex_stateless_rx_core.h
@@ -57,6 +57,8 @@ class CRxCoreStateless {
bool is_working() const {return (m_ack_start_work_msg == true);}
void set_working_msg_ack(bool val);
double get_cpu_util();
+ void update_cpu_util();
+
private:
void handle_cp_msg(TrexStatelessCpToRxMsgBase *msg);
diff --git a/src/utl_cpuu.cpp b/src/utl_cpuu.cpp
index 0701b845..4d75cf6f 100755
--- a/src/utl_cpuu.cpp
+++ b/src/utl_cpuu.cpp
@@ -26,8 +26,8 @@ limitations under the License.
void CCpuUtlCp::Create(CCpuUtlDp * cdp){
m_dpcpu=cdp;
m_cpu_util=0.0;
- m_last_total_cycles=m_dpcpu->get_total_cycles();
- m_last_work_cycles =m_dpcpu->get_work_cycles();
+ m_ticks=0;
+ m_work=0;
}
void CCpuUtlCp::Delete(){
@@ -36,18 +36,18 @@ void CCpuUtlCp::Delete(){
void CCpuUtlCp::Update(){
- uint64_t t=m_dpcpu->get_total_cycles();
- uint64_t w=m_dpcpu->get_work_cycles();
- uint32_t acc_total_cycles = (uint32_t)(t - m_last_total_cycles);
- uint32_t acc_work_cycles = (uint32_t)(w - m_last_work_cycles);
-
- m_last_total_cycles = t ;
- m_last_work_cycles = w;
-
- double window_cpu_u = ((double)acc_work_cycles/(double)acc_total_cycles);
-
- /* LPF*/
- m_cpu_util = (m_cpu_util*0.75)+(window_cpu_u*0.25);
+ m_ticks++ ;
+ if ( m_dpcpu->sample_data() ) {
+ m_work++;
+ }
+ if (m_ticks==100) {
+ double window_cpu_u = ((double)m_work/(double)m_ticks);
+ /* LPF*/
+ m_cpu_util = (m_cpu_util*0.75)+(window_cpu_u*0.25);
+ m_ticks=0;
+ m_work=0;
+
+ }
}
/* return cpu % */
diff --git a/src/utl_cpuu.h b/src/utl_cpuu.h
index bb3fe67c..e5305783 100755
--- a/src/utl_cpuu.h
+++ b/src/utl_cpuu.h
@@ -29,7 +29,6 @@ class CCpuUtlDp {
public:
CCpuUtlDp(){
- m_total_cycles=0;
m_data=0;
}
inline void start_work1(){
@@ -40,26 +39,13 @@ public:
m_data=0;
}
- inline void start_work(){
- m_data=os_get_hr_tick_64();
- }
- inline void revert(){
- }
- inline void commit(){
- m_total_cycles+=(os_get_hr_tick_64()-m_data);
- }
- inline uint64_t get_total_cycles(void){
- return ( os_get_hr_tick_64());
+ inline uint8_t sample_data(){
+ return (m_data);
}
- inline uint64_t get_work_cycles(void){
- return ( m_total_cycles );
- }
private:
- uint64_t m_total_cycles;
uint8_t m_data;
-
} __rte_cache_aligned;
class CCpuUtlCp {
@@ -73,12 +59,10 @@ public:
private:
CCpuUtlDp * m_dpcpu;
- double m_cpu_util;
- uint64_t m_last_total_cycles;
- uint64_t m_last_work_cycles;
+ uint16_t m_ticks;
+ uint16_t m_work;
-
- // add filter
+ double m_cpu_util;
};
#endif