From patchwork Tue Apr 9 13:11:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10891235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89E1F17EF for ; Tue, 9 Apr 2019 13:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7255028900 for ; Tue, 9 Apr 2019 13:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70A31288EF; Tue, 9 Apr 2019 13:11:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12CA628900 for ; Tue, 9 Apr 2019 13:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727169AbfDINLj (ORCPT ); Tue, 9 Apr 2019 09:11:39 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:44567 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbfDINLj (ORCPT ); Tue, 9 Apr 2019 09:11:39 -0400 Received: by mail-qt1-f196.google.com with SMTP id w5so19563545qtb.11 for ; Tue, 09 Apr 2019 06:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kwcpL0MhCq1jybPtNXVxNeHxbIPU3Ngc2q5bWO0Ro94=; b=YZJ6rXDYk6Lut9u3qKtAndzfjXzxTJrB5ulGv5RDjUh0cu6Bsu7Ui5mmWs9NVB7Q1V Fp36g03UTYhjOl8/jInpHv83ABZrG9je2hB8QfqQPCoXBthevOS0uO5SHmFG5CzdpyoE syElEuYIjFt/pdAmIu2At5v6igGmx8Gq7Beo1KydqdAK1Vz6GBLfvULOo2tLsEGzF5zi jL39niOyFqGfRXQthpzMnUegmsj0fBrUtnhWlp6sL6Ap796qDia7uoJ/TgLoFW+HGA5/ YjTsl+95UWARGQ2yB5/WzUGQ1SP78i47IQ1LLNggFFyPNP/MWLtGRITZSAmD4OTgD887 Ja2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kwcpL0MhCq1jybPtNXVxNeHxbIPU3Ngc2q5bWO0Ro94=; b=Cc7IIw6VpAa1a0I5dQCMA7nckaPA5/k9juxYg70MGao/3Bt1nvxStLyJMIkB2RQXpc oB3+LfSp3gSnZimX3k6FR989Uy0ouIPEZx6jk7qbXiuHvc22i/XoUHtek1ykotpw3gCj NSQlyAXrBDfWmLeBCp6HVv4PLi8xxu8tKi/G02T1m96NH2uNeIhG0Psk53O7FkGUD7GJ yx37C9iGVLubMDm+uNKcNms5udyHnyFn7oYYLX+YAjhz9UtZskCLh8JT7Q3qRX0utA+b OeL9S9nD6LLfXzArbXahHT9999KzUcge1JYFr5FxaBfo/dTRipJG32bjRFwks4Uaqe1R qymA== X-Gm-Message-State: APjAAAWhN6cUdySopWVSROWzzyNxn7cHH7REAwq0BU/3/S1ABrLZR7gZ 28Va0G1A7cr1KHVzdWbt1PurENPazlk= X-Google-Smtp-Source: APXvYqweBQtkM/Inw4YdIjE8VSxO6GhVLGx5ITuXDAOM6t6L5Nu+Ns0c3zpkFIC8j7vf27zIjJ2Xlw== X-Received: by 2002:ac8:7491:: with SMTP id v17mr28614492qtq.2.1554815498113; Tue, 09 Apr 2019 06:11:38 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-49-251.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.49.251]) by smtp.gmail.com with ESMTPSA id n10sm24905196qta.86.2019.04.09.06.11.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2019 06:11:37 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hDqXH-0004E6-K4; Tue, 09 Apr 2019 10:11:35 -0300 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH ibdiags 03/16] ibdiags/ibping: Use clock_gettime instead of complib Date: Tue, 9 Apr 2019 10:11:20 -0300 Message-Id: <20190409131133.16140-4-jgg@ziepe.ca> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190409131133.16140-1-jgg@ziepe.ca> References: <20190409131133.16140-1-jgg@ziepe.ca> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe No reason to use a library for such a simple calculation. Signed-off-by: Jason Gunthorpe --- src/ibping.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ibping.c b/src/ibping.c index ebcb581550f4f1..b463043ae73eb6 100644 --- a/src/ibping.c +++ b/src/ibping.c @@ -41,15 +41,23 @@ #include #include #include +#include #include #include -#include #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]; @@ -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; @@ -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); @@ -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); @@ -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++;