]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: get the time increment by rdstc inscturtion to decrease the cpu usage 16965/head
authorJin Cai <caijin.caij@alibaba-inc.com>
Thu, 10 Aug 2017 12:36:05 +0000 (20:36 +0800)
committerJin Cai <caijin.caij@alibaba-inc.com>
Thu, 10 Aug 2017 13:10:24 +0000 (21:10 +0800)
     in RDMADispatcher polling thread

Signed-off-by: Jin Cai <caijin.caij@alibaba-inc.com>
src/msg/async/rdma/RDMAStack.cc

index 94b0fd31681173e15adc4c1336a2530b38261cb5..63659dcce1a4dc7247985e585565ba1685a84a52 100644 (file)
@@ -19,6 +19,7 @@
 #include <sys/resource.h>
 
 #include "include/str_list.h"
+#include "common/Cycles.h"
 #include "common/deleter.h"
 #include "common/Tub.h"
 #include "RDMAStack.h"
@@ -95,6 +96,7 @@ RDMADispatcher::RDMADispatcher(CephContext* c, RDMAStack* s, Infiniband *i)
 
   perf_logger = plb.create_perf_counters();
   cct->get_perfcounters_collection()->add(perf_logger);
+  Cycles::init();
 }
 
 void RDMADispatcher::polling_start()
@@ -169,7 +171,7 @@ void RDMADispatcher::polling()
   std::vector<ibv_wc> tx_cqe;
   ldout(cct, 20) << __func__ << " going to poll tx cq: " << tx_cq << " rx cq: " << rx_cq << dendl;
   RDMAConnectedSocketImpl *conn = nullptr;
-  utime_t last_inactive = ceph_clock_now();
+  uint64_t last_inactive = Cycles::rdtsc();
   bool rearmed = false;
   int r = 0;
 
@@ -245,7 +247,8 @@ void RDMADispatcher::polling()
       if (!num_qp_conn && done)
         break;
 
-      if ((ceph_clock_now() - last_inactive).to_nsec() / 1000 > cct->_conf->ms_async_rdma_polling_us) {
+      uint64_t now = Cycles::rdtsc();
+      if (Cycles::to_microseconds(now - last_inactive) > cct->_conf->ms_async_rdma_polling_us) {
         handle_async_event();
         if (!rearmed) {
           // Clean up cq events after rearm notify ensure no new incoming event
@@ -277,7 +280,7 @@ void RDMADispatcher::polling()
           ldout(cct, 20) << __func__ << " got tx cq event." << dendl;
         if (r > 0 && rx_cc->get_cq_event())
           ldout(cct, 20) << __func__ << " got rx cq event." << dendl;
-        last_inactive = ceph_clock_now();
+        last_inactive = Cycles::rdtsc();
         perf_logger->set(l_msgr_rdma_polling, 1);
         rearmed = false;
       }