From: Jin Cai Date: Thu, 10 Aug 2017 12:36:05 +0000 (+0800) Subject: msg: get the time increment by rdstc inscturtion to decrease the cpu usage X-Git-Tag: v13.0.0~139^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e42414530fa59fc4b719ed1ede1038f65363eed2;p=ceph-ci.git msg: get the time increment by rdstc inscturtion to decrease the cpu usage in RDMADispatcher polling thread Signed-off-by: Jin Cai --- diff --git a/src/msg/async/rdma/RDMAStack.cc b/src/msg/async/rdma/RDMAStack.cc index 94b0fd31681..63659dcce1a 100644 --- a/src/msg/async/rdma/RDMAStack.cc +++ b/src/msg/async/rdma/RDMAStack.cc @@ -19,6 +19,7 @@ #include #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 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; }