Skip to content

Commit

Permalink
ibdiags/ibping: Use clock_gettime instead of complib
Browse files Browse the repository at this point in the history
No reason to use a library for such a simple calculation.

Reviewed-by: Nicolas Morey-Chaisemartin <NMoreyChaisemartin@suse.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
  • Loading branch information
jgunthorpe authored and weiny2 committed Apr 15, 2019
1 parent b7fb37e commit 176d9de
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/ibping.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@
#include <string.h>
#include <signal.h>
#include <getopt.h>
#include <time.h>

#include <infiniband/umad.h>
#include <infiniband/mad.h>
#include <complib/cl_timer.h>

#include "ibdiag_common.h"

struct ibmad_port *srcport;

static uint64_t time_stamp(void)
{
struct timespec ts;

clock_gettime(CLOCK_MONOTONIC, &ts);
return ((uint64_t)ts.tv_sec * 1000000ULL) + ts.tv_nsec / 10000ULL;
}

static char host_and_domain[IB_VENDOR_RANGE2_DATA_SIZE];
static char last_host[IB_VENDOR_RANGE2_DATA_SIZE];

Expand Down Expand Up @@ -113,7 +121,7 @@ static uint64_t ibping(ib_portid_t * portid, int quiet)

DEBUG("Ping..");

start = cl_get_time_stamp();
start = time_stamp();

call.method = IB_MAD_METHOD_GET;
call.mgmt_class = IB_VENDOR_OPENIB_PING_CLASS;
Expand All @@ -126,7 +134,7 @@ static uint64_t ibping(ib_portid_t * portid, int quiet)
if (!ib_vendor_call_via(data, portid, &call, srcport))
return ~0ull;

rtt = cl_get_time_stamp() - start;
rtt = time_stamp() - start;

if (!last_host[0])
memcpy(last_host, data, sizeof last_host);
Expand All @@ -144,7 +152,7 @@ static ib_portid_t portid = { 0 };

static void report(int sig)
{
total_time = cl_get_time_stamp() - start;
total_time = time_stamp() - start;

DEBUG("out due signal %d", sig);

Expand Down Expand Up @@ -240,7 +248,7 @@ int main(int argc, char **argv)
signal(SIGINT, report);
signal(SIGTERM, report);

start = cl_get_time_stamp();
start = time_stamp();

while (count-- > 0) {
ntrans++;
Expand Down

0 comments on commit 176d9de

Please sign in to comment.