Show a patch.

GET /api/patches/73350/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 73350,
    "url": "https://patches.dpdk.org/api/patches/73350/",
    "web_url": "https://patches.dpdk.org/patch/73350/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<20200706233231.25881-1-honnappa.nagarahalli@arm.com>",
    "date": "2020-07-06T23:32:29",
    "name": "[v3,1/3] app/testpmd: clock gettime call in throughput calculation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "e23072bfcdd506bd6e91f21b5e152679986b9081",
    "submitter": {
        "id": 1045,
        "url": "https://patches.dpdk.org/api/people/1045/",
        "name": "Honnappa Nagarahalli",
        "email": "honnappa.nagarahalli@arm.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@intel.com"
    },
    "mbox": "https://patches.dpdk.org/patch/73350/mbox/",
    "series": [
        {
            "id": 10827,
            "url": "https://patches.dpdk.org/api/series/10827/",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=10827",
            "date": "2020-07-06T23:32:29",
            "name": "[v3,1/3] app/testpmd: clock gettime call in throughput calculation",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/10827/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/73350/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/73350/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Message-Id": "<20200706233231.25881-1-honnappa.nagarahalli@arm.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "To": "dev@dpdk.org, honnappa.nagarahalli@arm.com, alialnu@mellanox.com,\n orgerlitz@mellanox.com, wenzhuo.lu@intel.com, beilei.xing@intel.com,\n bernard.iremonger@intel.com, ferruh.yigit@intel.com",
        "Cc": "hemant.agrawal@nxp.com, jerinj@marvell.com, viacheslavo@mellanox.com,\n thomas@monjalon.net, ruifeng.wang@arm.com, phil.yang@arm.com, nd@arm.com,\n zhihong.wang@intel.com, stable@dpdk.org",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 0599DA00C5;\n\tTue,  7 Jul 2020 01:32:41 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 131CF1DC33;\n\tTue,  7 Jul 2020 01:32:41 +0200 (CEST)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by dpdk.org (Postfix) with ESMTP id 886DA1DC0F;\n Tue,  7 Jul 2020 01:32:39 +0200 (CEST)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EF3BCC0A;\n Mon,  6 Jul 2020 16:32:38 -0700 (PDT)",
            "from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com\n [10.118.12.27])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E18BA3F718;\n Mon,  6 Jul 2020 16:32:38 -0700 (PDT)"
        ],
        "Subject": "[dpdk-dev] [PATCH v3 1/3] app/testpmd: clock gettime call in\n\tthroughput calculation",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "In-Reply-To": "<20200617144307.9961-1-honnappa.nagarahalli@arm.com>",
        "Precedence": "list",
        "From": "Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>",
        "References": "<20200617144307.9961-1-honnappa.nagarahalli@arm.com>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Date": "Mon,  6 Jul 2020 18:32:29 -0500",
        "X-Mailman-Version": "2.1.15",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>"
    },
    "content": "The throughput calculation requires a counter that measures\npassing of time. However, the kernel saves and restores the PMU\nstate when a thread is unscheduled and scheduled. This ensures\nthat the PMU cycles are not counted towards a thread that is\nnot scheduled. Hence, when RTE_ARM_EAL_RDTSC_USE_PMU is enabled,\nthe PMU cycles do not represent the passing of time.\nThis results in incorrect calculation of throughput numbers.\nUse clock_gettime system call to calculate the time passed since\nlast call.\n\nBugzilla ID: 450\nFixes: 0e106980301d (\"app/testpmd: show throughput in port stats\")\nCc: zhihong.wang@intel.com\nCc: stable@dpdk.org\n\nSigned-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>\nReviewed-by: Phil Yang <phil.yang@arm.com>\nReviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>\nReviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>\nTested-by: Phil Yang <phil.yang@arm.com>\nTested-by: Ali Alnubani <alialnu@mellanox.com>\n---\nv3:\n1) Dropped 'noisy vnf' patch, will add with future Dharmik's patch\n2) Dropped flow gen patch, send out a separate one if there is\n   consensus on the mailing list\n3) Changed the logic to display burst stats to make it easier\n   to understand (Ferruh)\n\nv2: Updated commit log in 1/5 (Jerin)\n\n app/test-pmd/config.c | 44 +++++++++++++++++++++++++++++--------------\n 1 file changed, 30 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c\nindex 016bcb09c..91fbf99f8 100644\n--- a/app/test-pmd/config.c\n+++ b/app/test-pmd/config.c\n@@ -54,6 +54,14 @@\n \n #define ETHDEV_FWVERS_LEN 32\n \n+#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */\n+#define CLOCK_TYPE_ID CLOCK_MONOTONIC_RAW\n+#else\n+#define CLOCK_TYPE_ID CLOCK_MONOTONIC\n+#endif\n+\n+#define NS_PER_SEC 1E9\n+\n static char *flowtype_to_str(uint16_t flow_type);\n \n static const struct {\n@@ -136,9 +144,10 @@ nic_stats_display(portid_t port_id)\n \tstatic uint64_t prev_pkts_tx[RTE_MAX_ETHPORTS];\n \tstatic uint64_t prev_bytes_rx[RTE_MAX_ETHPORTS];\n \tstatic uint64_t prev_bytes_tx[RTE_MAX_ETHPORTS];\n-\tstatic uint64_t prev_cycles[RTE_MAX_ETHPORTS];\n+\tstatic uint64_t prev_ns[RTE_MAX_ETHPORTS];\n+\tstruct timespec cur_time;\n \tuint64_t diff_pkts_rx, diff_pkts_tx, diff_bytes_rx, diff_bytes_tx,\n-\t\t\t\t\t\t\t\tdiff_cycles;\n+\t\t\t\t\t\t\t\tdiff_ns;\n \tuint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx;\n \tstruct rte_eth_stats stats;\n \tstruct rte_port *port = &ports[port_id];\n@@ -195,10 +204,17 @@ nic_stats_display(portid_t port_id)\n \t\t}\n \t}\n \n-\tdiff_cycles = prev_cycles[port_id];\n-\tprev_cycles[port_id] = rte_rdtsc();\n-\tif (diff_cycles > 0)\n-\t\tdiff_cycles = prev_cycles[port_id] - diff_cycles;\n+\tdiff_ns = 0;\n+\tif (clock_gettime(CLOCK_TYPE_ID, &cur_time) == 0) {\n+\t\tuint64_t ns;\n+\n+\t\tns = cur_time.tv_sec * NS_PER_SEC;\n+\t\tns += cur_time.tv_nsec;\n+\n+\t\tif (prev_ns[port_id] != 0)\n+\t\t\tdiff_ns = ns - prev_ns[port_id];\n+\t\tprev_ns[port_id] = ns;\n+\t}\n \n \tdiff_pkts_rx = (stats.ipackets > prev_pkts_rx[port_id]) ?\n \t\t(stats.ipackets - prev_pkts_rx[port_id]) : 0;\n@@ -206,10 +222,10 @@ nic_stats_display(portid_t port_id)\n \t\t(stats.opackets - prev_pkts_tx[port_id]) : 0;\n \tprev_pkts_rx[port_id] = stats.ipackets;\n \tprev_pkts_tx[port_id] = stats.opackets;\n-\tmpps_rx = diff_cycles > 0 ?\n-\t\tdiff_pkts_rx * rte_get_tsc_hz() / diff_cycles : 0;\n-\tmpps_tx = diff_cycles > 0 ?\n-\t\tdiff_pkts_tx * rte_get_tsc_hz() / diff_cycles : 0;\n+\tmpps_rx = diff_ns > 0 ?\n+\t\t(double)diff_pkts_rx / diff_ns * NS_PER_SEC : 0;\n+\tmpps_tx = diff_ns > 0 ?\n+\t\t(double)diff_pkts_tx / diff_ns * NS_PER_SEC : 0;\n \n \tdiff_bytes_rx = (stats.ibytes > prev_bytes_rx[port_id]) ?\n \t\t(stats.ibytes - prev_bytes_rx[port_id]) : 0;\n@@ -217,10 +233,10 @@ nic_stats_display(portid_t port_id)\n \t\t(stats.obytes - prev_bytes_tx[port_id]) : 0;\n \tprev_bytes_rx[port_id] = stats.ibytes;\n \tprev_bytes_tx[port_id] = stats.obytes;\n-\tmbps_rx = diff_cycles > 0 ?\n-\t\tdiff_bytes_rx * rte_get_tsc_hz() / diff_cycles : 0;\n-\tmbps_tx = diff_cycles > 0 ?\n-\t\tdiff_bytes_tx * rte_get_tsc_hz() / diff_cycles : 0;\n+\tmbps_rx = diff_ns > 0 ?\n+\t\t(double)diff_bytes_rx / diff_ns * NS_PER_SEC : 0;\n+\tmbps_tx = diff_ns > 0 ?\n+\t\t(double)diff_bytes_tx / diff_ns * NS_PER_SEC : 0;\n \n \tprintf(\"\\n  Throughput (since last show)\\n\");\n \tprintf(\"  Rx-pps: %12\"PRIu64\"          Rx-bps: %12\"PRIu64\"\\n  Tx-pps: %12\"\n",
    "prefixes": [
        "v3",
        "1/3"
    ]
}