From patchwork Mon Nov 27 11:44:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 119684 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp133884qgn; Mon, 27 Nov 2017 03:45:36 -0800 (PST) X-Google-Smtp-Source: AGs4zMY3qJ8u6pllx3Z9rArteXE6/Y4qJl/cB0//P8gdBv/M/kH2/Gu0PM2G3NvAvlC2SrGWc37i X-Received: by 10.84.168.132 with SMTP id f4mr38303851plb.234.1511783136578; Mon, 27 Nov 2017 03:45:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511783136; cv=none; d=google.com; s=arc-20160816; b=OJjnqI2ba/m+17tpV7gZvcGu7RJaZfzmV8ZlZucwJRHoJ1IOZBNYHnNmBh1wGHEQGh jtl1SxmdrOHh2EGhnQ8In/h3ShfieviUiZYBcweaIGNnpCblhGmLwLgycni9nslIjtSo OOQ3RO2eiIpxHUfNr2wAjuN5B3vxWEcbtHpspZo7vHMJMJD31uVzz98gd/awAWt7Kv7+ fCbZUpqrwXdH3lJQMd7DvgLjFrhsDuECXRebAC1c5TOG1/csynEjDXd9pV1TYxbmW+wd mxjLrXMehZ3P5Au5dYtIpCD1nPCmDsODQAIOgoNoYhXSdM1ri5pxZabLmzMZHSY9DejJ GcLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NSJlUYanF/haKQj4w6M12lbeBa4zbAFMVL9uoodor5E=; b=uuPc7OMUeV58PBcZxIVNNzzdDR3PbFFqdxTC3bR+pYtJhLXtEi+znZOexPwagPZHe+ QDgqb9dP2IXsPB9y1ipgPyQLtsQhQsLaNnuZzff9uCzTbpsz0WGCqOsIgNqUbGg8Cr9c Nu+akA3nfBbeLHGk5nq+UDExJ7hFgxQw4qcmird25HbncJWJ/z6qjayr6vnAo7Cy2IRZ kyd5T8JziTeb3UQHYWXkJF21y1vt6FrhzQscqCC8ZKfQz4EMhJs6wVN8qRq2yZ0A/jbZ UUOmAPkKvTLGa3qJNZ3nVUa+WnxTHTO4/g5sKB7BRjOejqjLBQZLZPq6ip3Z2/e26QhZ viYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si23112426pgd.666.2017.11.27.03.45.36; Mon, 27 Nov 2017 03:45:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752060AbdK0Lpd (ORCPT + 28 others); Mon, 27 Nov 2017 06:45:33 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:57132 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751849AbdK0Lpb (ORCPT ); Mon, 27 Nov 2017 06:45:31 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LsyHC-1fFsh01NN4-012VV1; Mon, 27 Nov 2017 12:45:20 +0100 From: Arnd Bergmann To: Steve Wise , Doug Ledford , Jason Gunthorpe Cc: Arnd Bergmann , Bharat Potnuri , Leon Romanovsky , Ganesh Goudar , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] infiniband: cxgb4: use ktime_get for timestamps Date: Mon, 27 Nov 2017 12:44:53 +0100 Message-Id: <20171127114518.2662754-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:qmas+GpyWcB+gPixlDYU0VgIN52ZzeG5u3eBjhpkqjV16AUMPno 4kivgp/uuLlrenqikZM/hxfr/8NzRUISid4aMGPShl3dpGSdQMUmLEENg4hJhkdGhkSpTuR qGGAJWfdLEEFIP+NHnC/NcVy6YMuPgmqTjHxaJwIftwrJCaadieCPW7L4OaYK/ahAEj0PfQ oXNgoqadnygdeb5rKAiIQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:7T6FccwKpkI=:u9Nxkb2n0FdTa3uCKP36rX o1FYxkt7qyufyKAZ2UQ4NFgvf78I8RKJCog7JMAYTz9kXgrhsweo5lYqEDmLe3m2NSiXDtiEx cwAEQM/KuYmJnQNRv5472E2OYHZfJzgkEmjTup6nxaHwyekG+TJKmVMge7/NlDef48YyVg0SD MYinXqrvS/8cowp5PIuW2wFp55F1WJAu4jyH5do26uisIUBkMPJgV1tzdcDDJvsoLHwMIVy0c FYwi7dj92hh+ZpRrXwW+56QtMFh/J+Gmn61o+EDeqhwrxT8AgLb0BT3aOq8hHghLv27jpc+GX b6p2L8Gz8s93abSJKduwTi97yVrAESIWUONHGfj+n0iOlIMevieydmSP9vGDLo4Dhk3Yk5dDf QrRgHLcaPCFpy3qyx8HT0ompbwKa+PLUBamQliFGN897zFLgurX+gUTET2EZlmvALmz2JS98W BquJQ8zmAWlBNpTu/b8QEF2BQZuLnfIzW7nzu6VmLWA2zBkcdccpcrKdC2eh3zbQxUdDFaV9D rlXAZNUhC/8LquG6IM5kiTztRPx63sBAxmf4I0pG18AEdPJrfD+vF7AGRCZGb2lNR00zbXHWd /eo3yIxdrCd29NNtgGx4JIxIPOZU0oAy3crWuc2tw61tpO7dtSKzVeEkDKOzP+odP2zSz5agR P8W9I5C42lnbNxnfa0i6roSJCXFm2gULC7xG95QlnUvezp2tw0Ec2RuBzMGaCosKOJYgeP9A+ Tnm8MuIqPoCsvhvGCNRYJ92ZFc4fOdZduwIaIA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The debugfs file prints the difference between host timestamps as a seconds/nanoseconds tuple, along with a 64-bit nanoseconds hardware timestamp. The host time is read using getnstimeofday() which is deprecated because of the y2038 overflow, and it suffers from time jumps during settimeofday() and leap seconds. Converting to ktime_get_ts64() would solve those two, but I'm going a little further here by changing to ktime_get() and printing 64-bit nanoseconds on both host and hw timestamps. This simplifies the code further and makes the output easier to understand. The format of the debugfs file obviously changes here, but this should only be read by humans and not scripts, so I assume it's fine. Signed-off-by: Arnd Bergmann --- drivers/infiniband/hw/cxgb4/device.c | 34 +++++++++++++++------------------- drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 4 ++-- drivers/infiniband/hw/cxgb4/qp.c | 6 +++--- drivers/infiniband/hw/cxgb4/t4.h | 4 ++-- 4 files changed, 22 insertions(+), 26 deletions(-) -- 2.9.0 Acked-by: Steve Wise diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index af77d128d242..21566228b0ba 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c @@ -108,19 +108,19 @@ void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe) idx = (atomic_inc_return(&wq->rdev->wr_log_idx) - 1) & (wq->rdev->wr_log_size - 1); le.poll_sge_ts = cxgb4_read_sge_timestamp(wq->rdev->lldi.ports[0]); - getnstimeofday(&le.poll_host_ts); + le.poll_host_time = ktime_get(); le.valid = 1; le.cqe_sge_ts = CQE_TS(cqe); if (SQ_TYPE(cqe)) { le.qid = wq->sq.qid; le.opcode = CQE_OPCODE(cqe); - le.post_host_ts = wq->sq.sw_sq[wq->sq.cidx].host_ts; + le.post_host_time = wq->sq.sw_sq[wq->sq.cidx].host_time; le.post_sge_ts = wq->sq.sw_sq[wq->sq.cidx].sge_ts; le.wr_id = CQE_WRID_SQ_IDX(cqe); } else { le.qid = wq->rq.qid; le.opcode = FW_RI_RECEIVE; - le.post_host_ts = wq->rq.sw_rq[wq->rq.cidx].host_ts; + le.post_host_time = wq->rq.sw_rq[wq->rq.cidx].host_time; le.post_sge_ts = wq->rq.sw_rq[wq->rq.cidx].sge_ts; le.wr_id = CQE_WRID_MSN(cqe); } @@ -130,9 +130,9 @@ void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe) static int wr_log_show(struct seq_file *seq, void *v) { struct c4iw_dev *dev = seq->private; - struct timespec prev_ts = {0, 0}; + ktime_t prev_time; struct wr_log_entry *lep; - int prev_ts_set = 0; + int prev_time_set = 0; int idx, end; #define ts2ns(ts) div64_u64((ts) * dev->rdev.lldi.cclk_ps, 1000) @@ -145,33 +145,29 @@ static int wr_log_show(struct seq_file *seq, void *v) lep = &dev->rdev.wr_log[idx]; while (idx != end) { if (lep->valid) { - if (!prev_ts_set) { - prev_ts_set = 1; - prev_ts = lep->poll_host_ts; + if (!prev_time_set) { + prev_time_set = 1; + prev_time = lep->poll_host_time; } - seq_printf(seq, "%04u: sec %lu nsec %lu qid %u opcode " - "%u %s 0x%x host_wr_delta sec %lu nsec %lu " + seq_printf(seq, "%04u: nsec %llu qid %u opcode " + "%u %s 0x%x host_wr_delta nsec %llu " "post_sge_ts 0x%llx cqe_sge_ts 0x%llx " "poll_sge_ts 0x%llx post_poll_delta_ns %llu " "cqe_poll_delta_ns %llu\n", idx, - timespec_sub(lep->poll_host_ts, - prev_ts).tv_sec, - timespec_sub(lep->poll_host_ts, - prev_ts).tv_nsec, + ktime_to_ns(ktime_sub(lep->poll_host_time, + prev_time)), lep->qid, lep->opcode, lep->opcode == FW_RI_RECEIVE ? "msn" : "wrid", lep->wr_id, - timespec_sub(lep->poll_host_ts, - lep->post_host_ts).tv_sec, - timespec_sub(lep->poll_host_ts, - lep->post_host_ts).tv_nsec, + ktime_to_ns(ktime_sub(lep->poll_host_time, + lep->post_host_time)), lep->post_sge_ts, lep->cqe_sge_ts, lep->poll_sge_ts, ts2ns(lep->poll_sge_ts - lep->post_sge_ts), ts2ns(lep->poll_sge_ts - lep->cqe_sge_ts)); - prev_ts = lep->poll_host_ts; + prev_time = lep->poll_host_time; } idx++; if (idx > (dev->rdev.wr_log_size - 1)) diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h index 470f97a79ebb..37ff2ad8a3d4 100644 --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h @@ -153,8 +153,8 @@ struct c4iw_hw_queue { }; struct wr_log_entry { - struct timespec post_host_ts; - struct timespec poll_host_ts; + ktime_t post_host_time; + ktime_t poll_host_time; u64 post_sge_ts; u64 cqe_sge_ts; u64 poll_sge_ts; diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index 5ee7fe433136..8018533ab705 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c @@ -975,7 +975,7 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, if (c4iw_wr_log) { swsqe->sge_ts = cxgb4_read_sge_timestamp( qhp->rhp->rdev.lldi.ports[0]); - getnstimeofday(&swsqe->host_ts); + swsqe->host_time = ktime_get(); } init_wr_hdr(wqe, qhp->wq.sq.pidx, fw_opcode, fw_flags, len16); @@ -1045,8 +1045,8 @@ int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, qhp->wq.rq.sw_rq[qhp->wq.rq.pidx].sge_ts = cxgb4_read_sge_timestamp( qhp->rhp->rdev.lldi.ports[0]); - getnstimeofday( - &qhp->wq.rq.sw_rq[qhp->wq.rq.pidx].host_ts); + qhp->wq.rq.sw_rq[qhp->wq.rq.pidx].host_time = + ktime_get(); } wqe->recv.opcode = FW_RI_RECV_WR; diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h index e9ea94268d51..e12377cc024c 100644 --- a/drivers/infiniband/hw/cxgb4/t4.h +++ b/drivers/infiniband/hw/cxgb4/t4.h @@ -271,7 +271,7 @@ struct t4_swsqe { int signaled; u16 idx; int flushed; - struct timespec host_ts; + ktime_t host_time; u64 sge_ts; }; @@ -312,7 +312,7 @@ struct t4_sq { struct t4_swrqe { u64 wr_id; - struct timespec host_ts; + ktime_t host_time; u64 sge_ts; };