get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 815651,
    "url": "http://patchwork.ozlabs.org/api/patches/815651/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/CFF8EF42F1132E4CBE2BF0AB6C21C58D78813F22@ESESSMB107.ericsson.se/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<CFF8EF42F1132E4CBE2BF0AB6C21C58D78813F22@ESESSMB107.ericsson.se>",
    "list_archive_url": null,
    "date": "2017-09-19T16:30:27",
    "name": "[ovs-dev,3/3] dpif-netdev: Detection and logging of suspicious PMD iterations",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "1b4c73925e3cd4aa29d2b94bf43dc5d5dc2ca832",
    "submitter": {
        "id": 68449,
        "url": "http://patchwork.ozlabs.org/api/people/68449/?format=api",
        "name": "Jan Scheurich",
        "email": "jan.scheurich@ericsson.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/CFF8EF42F1132E4CBE2BF0AB6C21C58D78813F22@ESESSMB107.ericsson.se/mbox/",
    "series": [
        {
            "id": 3922,
            "url": "http://patchwork.ozlabs.org/api/series/3922/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=3922",
            "date": "2017-09-19T16:29:52",
            "name": ": dpif-netdev: Detailed PMD performance metrics and supervision",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/3922/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/815651/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/815651/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "ovs-dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@mail.linuxfoundation.org"
        ],
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxT1v0CbQz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 02:32:51 +1000 (AEST)",
            "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id D020EBC3;\n\tTue, 19 Sep 2017 16:30:32 +0000 (UTC)",
            "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id D0D8EB93\n\tfor <ovs-dev@openvswitch.org>; Tue, 19 Sep 2017 16:30:30 +0000 (UTC)",
            "from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1DF36488\n\tfor <ovs-dev@openvswitch.org>; Tue, 19 Sep 2017 16:30:28 +0000 (UTC)",
            "from ESESSHC023.ericsson.se (Unknown_Domain [153.88.183.87])\n\tby sessmg22.ericsson.net (Symantec Mail Security) with SMTP id\n\t47.9D.20899.32641C95; Tue, 19 Sep 2017 18:30:27 +0200 (CEST)",
            "from ESESSMB107.ericsson.se ([169.254.7.166]) by\n\tESESSHC023.ericsson.se ([153.88.183.87]) with mapi id 14.03.0352.000; \n\tTue, 19 Sep 2017 18:30:26 +0200"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-AuditID": "c1b4fb3a-617ff700000051a3-4d-59c14623d2fd",
        "From": "Jan Scheurich <jan.scheurich@ericsson.com>",
        "To": "\"ovs-dev@openvswitch.org\" <ovs-dev@openvswitch.org>",
        "Thread-Topic": "[PATCH 3/3] dpif-netdev: Detection and logging of suspicious\n\tPMD iterations",
        "Thread-Index": "AdMxY83pheq0qsKGRxu971k7jpFOGA==",
        "Date": "Tue, 19 Sep 2017 16:30:27 +0000",
        "Message-ID": "<CFF8EF42F1132E4CBE2BF0AB6C21C58D78813F22@ESESSMB107.ericsson.se>",
        "Accept-Language": "en-US",
        "Content-Language": "en-US",
        "X-MS-Has-Attach": "",
        "X-MS-TNEF-Correlator": "",
        "x-originating-ip": "[153.88.183.17]",
        "MIME-Version": "1.0",
        "X-Brightmail-Tracker": "H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsUyM2J7uK6y28FIg7+dwhZzPz1ndGD0eHbz\n\tP2MAYxSXTUpqTmZZapG+XQJXxuIN01kKDi9nqlj/9jRbA+PtP4xdjJwcEgImEh1f3rF0MXJx\n\tCAkcYZTYfeAuE4SzhFFi3uodQFUcHGwCBhKzdzuANIgImEuc+HCOHcQWFgiTuNy/mhkiHi3x\n\t9vx0VghbT+L2lQdgC1gEVCWWvF4GFucV8JW43DSFCcRmFBCT+H5qDZjNLCAucevJfCaIgwQk\n\tluw5zwxhi0q8fPyPFeQECQFFieX9chDl+RLbplxnhxgpKHFy5hOWCYyCs5BMmoWkbBaSMoi4\n\tjsSC3Z/YIGxtiWULXzPD2GcOPGZCFl/AyL6KUbQ4tbg4N93ISC+1KDO5uDg/Ty8vtWQTIzD4\n\tD275bbWD8eBzx0OMAhyMSjy8Ii4HI4VYE8uKK3MPMUpwMCuJ8L52AgrxpiRWVqUW5ccXleak\n\tFh9ilOZgURLnddh3IUJIID2xJDU7NbUgtQgmy8TBKdXA6Br1Z6nfEm539TenaywvXJnTIfW7\n\tSu5jxN6zkUEp/xjKuW46uv+r71l9KsR/4/0WjqZchhm83PNrzT/Ol9aLf8vx6fbvBXVc/gUO\n\t3RxON2skO99b5PzcObGhWzD35Munbn+mScisLHCfFdFzhy/sY/n9nbY6LaH7j66ye+DyQH1m\n\tUMOTllnpSizFGYmGWsxFxYkAJ8z4i3oCAAA=",
        "X-Spam-Status": "No, score=-2.3 required=5.0 tests=HTML_MESSAGE,\n\tRCVD_IN_DNSWL_MED autolearn=disabled version=3.3.1",
        "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org",
        "X-Content-Filtered-By": "Mailman/MimeDel 2.1.12",
        "Subject": "[ovs-dev] [PATCH 3/3] dpif-netdev: Detection and logging of\n\tsuspicious PMD iterations",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.12",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "ovs-dev-bounces@openvswitch.org",
        "Errors-To": "ovs-dev-bounces@openvswitch.org"
    },
    "content": "This patch enhances dpif-netdev-perf to detect iterations with\nsuspicious statistics according to the following criteria:\n\n- iteration lasts longer than US_THR microseconds (default 250).\n  This can be used to capture events where a PMD is blocked or\n  interrupted for such a period of time that there is a risk for\n  dropped packets on any of its Rx queues.\n\n- max vhost qlen exceeds a threshold Q_THR (default 128). This can\n  be used to infer virtio queue overruns and dropped packets inside\n  a VM, which are not visible in OVS otherwise.\n\nSuch suspicious iterations can be logged together with their iteration\nstatistics to be able to correlate them to packet drop or other events\noutside OVS.\n\nA new command is introduced to enable/disable logging at run-time and\nto adjust the above thresholds for suspicious iterations:\n\novs-appctl dpif-netdev/pmd-perf-log-set [on|off]\n    [-b before] [-a after] [-us usec] [-q qlen]\n\nTurn logging on or off at run-time (on|off).\n\n-b before:  The number of iterations before the suspicious iteration to\n            be logged (default 5).\n-a after:   The number of iterations after the suspicious iteration to\n            be logged (default 5).\n-q qlen:    Suspicious vhost queue fill level threshold. Increase this\n            to 512 if the Qemu supports 1024 virtio queue length.\n            (default 128).\n-us usec:   change the duration threshold for a suspicious iteration\n            (default 250 us).\n\nIf more than 100 iterations before or after a suspicious iteration have\nbeen looged once, OVS falls back to the safe default values (5/5) to\navoid that logging itself causes continuos further logging.\n\nSigned-off-by: Jan Scheurich <jan.scheurich@ericsson.com>\n---\n lib/dpif-netdev-perf.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++\n lib/dpif-netdev-perf.h |  32 +++++++++++\n lib/dpif-netdev.c      |   5 ++\n 3 files changed, 178 insertions(+)\n\n--\n1.9.1",
    "diff": "diff --git a/lib/dpif-netdev-perf.c b/lib/dpif-netdev-perf.c\nindex 42d93a2..455c4b5 100644\n--- a/lib/dpif-netdev-perf.c\n+++ b/lib/dpif-netdev-perf.c\n@@ -28,6 +28,23 @@\n\n VLOG_DEFINE_THIS_MODULE(pmd_perf);\n\n+#define ITER_US_THRESHOLD 250   /* Warning threshold for iteration duration\n+                                   in microseconds. */\n+#define VHOST_QUEUE_FULL 128    /* Size of the virtio TX queue. */\n+#define LOG_IT_BEFORE 5         /* Number of iteration to log before\n+                                   suspicious iteration. */\n+#define LOG_IT_AFTER 5          /* Number of iteration to log after\n+                                   suspicious iteration. */\n+\n+bool log_on = false;\n+static uint32_t log_it_before = LOG_IT_BEFORE;\n+static uint32_t log_it_after = LOG_IT_AFTER;\n+static uint32_t log_us_thr = ITER_US_THRESHOLD;\n+uint32_t log_q_thr = VHOST_QUEUE_FULL;\n+uint64_t iter_cycle_threshold;\n+\n+static struct vlog_rate_limit latency_rl = VLOG_RATE_LIMIT_INIT(600, 600);\n+\n #ifdef DPDK_NETDEV\n static uint64_t\n get_tsc_hz(void)\n@@ -133,6 +150,8 @@ pmd_perf_stats_init(struct pmd_perf_stats *s) {\n     histogram_walls_set_log(&s->cycles_per_upcall, 1000, 1000000);\n     histogram_walls_set_log(&s->max_vhost_qfill, 0, 512);\n     s->start_ms = time_msec();\n+    s->log_begin_it = UINT64_MAX;\n+    s->log_end_it = UINT64_MAX;\n }\n\n void\n@@ -365,7 +384,129 @@ pmd_perf_stats_clear(struct pmd_perf_stats *s)\n     histogram_clear(&s->max_vhost_qfill);\n     history_init(&s->iterations);\n     history_init(&s->milliseconds);\n+    s->log_begin_it = UINT64_MAX;\n+    s->log_end_it = UINT64_MAX;\n     s->start_ms = time_msec(); /* Clearing finished. */\n     s->milliseconds.sample[0].timestamp = s->start_ms;\n }\n\n+void\n+pmd_perf_log_suspicious_iteration(struct pmd_perf_stats *s,\n+                                     uint64_t cycles,\n+                                     char *reason)\n+{\n+    VLOG_WARN_RL(&latency_rl,\n+                 \"Suspicious iteration (%s): tsc=%\"PRIu64\n+                 \" duration=%\"PRIu64\" us\\n\",\n+                 reason, s->current.timestamp,\n+                 (1000000L * cycles) / get_tsc_hz());\n+    if (log_it_before + log_it_after > 0) {\n+        if (s->log_begin_it == UINT64_MAX) {\n+            s->log_begin_it =\n+                    (s->iterations.idx + HISTORY_LEN - log_it_before)\n+                        % HISTORY_LEN;\n+        }\n+        s->log_end_it =\n+                (s->iterations.idx + log_it_after) % HISTORY_LEN;\n+    }\n+}\n+\n+void\n+pmd_perf_log_iteration_neighborhood(struct pmd_perf_stats *s)\n+{\n+    struct ds log = DS_EMPTY_INITIALIZER;\n+    pmd_perf_format_iteration_history(&log, s,\n+            (s->log_end_it + HISTORY_LEN - s->log_begin_it) % HISTORY_LEN);\n+    VLOG_WARN_RL(&latency_rl,\n+                 \"Neighborhood of suspicious iteration:\\n\"\n+                 \"%s\", ds_cstr(&log));\n+    ds_destroy(&log);\n+    s->log_end_it = s->log_begin_it = UINT64_MAX;\n+    if (log_it_before > 100 || log_it_after > 100) {\n+        /* Reset to safe default values to avoid disturbance. */\n+        log_it_before = LOG_IT_BEFORE;\n+        log_it_after = LOG_IT_AFTER;\n+    }\n+}\n+\n+void\n+pmd_perf_log_set_cmd(struct unixctl_conn *conn,\n+                 int argc, const char *argv[],\n+                 void *aux OVS_UNUSED)\n+{\n+    int it_before, it_after, us_thr, q_thr;\n+    bool on;\n+    bool usage = false;\n+\n+    on = log_on;\n+    it_before = log_it_before;\n+    it_after = log_it_after;\n+    q_thr = log_q_thr;\n+    us_thr = log_us_thr;\n+\n+    while (argc > 1) {\n+        if (!strcmp(argv[1], \"on\")) {\n+            on = true;\n+            argc--;\n+            argv++;\n+        } else if (!strcmp(argv[1], \"off\")) {\n+            on = false;\n+            argc--;\n+            argv++;\n+        } else if (!strcmp(argv[1], \"-a\")) {\n+            it_after = strtol(argv[2], NULL, 10);\n+            if (it_after < 0) {\n+                it_after = 0;\n+            } else if (it_before + it_after > HISTORY_LEN-1) {\n+                it_after = HISTORY_LEN-1 - it_before;\n+            }\n+            argc -= 2;\n+            argv += 2;\n+        } else if (!strcmp(argv[1], \"-b\")) {\n+            it_before = strtol(argv[2], NULL, 10);\n+            if (it_before < 0) {\n+                it_before = 0;\n+            } else if (it_before > HISTORY_LEN-10) {\n+                it_before = HISTORY_LEN-10;\n+            }\n+            argc -= 2;\n+            argv += 2;\n+        } else if (!strcmp(argv[1], \"-q\")) {\n+            q_thr = strtol(argv[2], NULL, 10);\n+            if (q_thr < 0) {\n+                q_thr = 0;\n+            }\n+            argc -= 2;\n+            argv += 2;\n+        } else if (!strcmp(argv[1], \"-us\")) {\n+            us_thr = strtol(argv[2], NULL, 10);\n+            if (us_thr < 0) {\n+                us_thr = 0;\n+            }\n+            argc -= 2;\n+            argv += 2;\n+        } else {\n+            usage = true;\n+            break;\n+        }\n+    }\n+\n+    if (usage) {\n+        unixctl_command_reply_error(conn,\n+                \"Usage: ovs-appctl dpif-netdev/pmd-perf-log-set \"\n+                \"[on|off] [-b before] [-a after] [-us usec] [-q qlen]\");\n+        return;\n+    }\n+\n+    VLOG_INFO(\"pmd-perf-log-set: %s, before=%d, after=%d, us_thr=%d,\"\n+              \" q_thr=%d\\n\",\n+              on ? \"on\" : \"off\", it_before, it_after, us_thr, q_thr);\n+    log_on = on;\n+    log_it_before = it_before;\n+    log_it_after = it_after;\n+    log_q_thr = q_thr;\n+    log_us_thr = us_thr;\n+    iter_cycle_threshold = (log_us_thr * get_tsc_hz()) / 1000000L;\n+\n+    unixctl_command_reply(conn, \"\");\n+}\ndiff --git a/lib/dpif-netdev-perf.h b/lib/dpif-netdev-perf.h\nindex 01fde8d..442c94b 100644\n--- a/lib/dpif-netdev-perf.h\n+++ b/lib/dpif-netdev-perf.h\n@@ -107,6 +107,8 @@ struct pmd_perf_stats {\n     struct histogram max_vhost_qfill;\n     struct history iterations;\n     struct history milliseconds;\n+    uint64_t log_begin_it;\n+    uint64_t log_end_it;\n };\n\n enum pmd_info_type;\n@@ -119,6 +121,10 @@ struct pmd_perf_params {\n     size_t ms_hist_len;\n };\n\n+extern bool log_on;\n+extern uint32_t log_q_thr;\n+extern uint64_t iter_cycle_threshold;\n+\n void pmd_perf_stats_init(struct pmd_perf_stats *s);\n void pmd_perf_stats_clear(struct pmd_perf_stats *s);\n void pmd_perf_read_counters(struct pmd_perf_stats *s,\n@@ -143,9 +149,17 @@ void pmd_perf_format_iteration_history(struct ds *str,\n void pmd_perf_format_ms_history(struct ds *str, struct pmd_perf_stats *s,\n                                 int n_ms);\n\n+void pmd_perf_log_suspicious_iteration(struct pmd_perf_stats *s,\n+                                       uint64_t cycles,\n+                                       char *reason);\n+void pmd_perf_log_iteration_neighborhood(struct pmd_perf_stats *s);\n void pmd_perf_show(struct unixctl_conn *conn, int argc,\n                    const char *argv[],\n                    void *aux OVS_UNUSED);\n+void pmd_perf_log_set_cmd(struct unixctl_conn *conn,\n+                      int argc, const char *argv[],\n+                      void *aux OVS_UNUSED);\n+\n static inline void\n histogram_add_sample(struct histogram *hist, uint32_t val)\n {\n@@ -208,6 +222,7 @@ pmd_perf_end_iteration(struct pmd_perf_stats *s, uint64_t now_tsc,\n {\n     struct iter_stats *cum_ms;\n     uint64_t cycles, cycles_per_pkt = 0;\n+    char *reason = NULL;\n\n     if (OVS_UNLIKELY(s->current.timestamp == 0)) {\n         /* Stats were cleared during the ongoing iteration. */\n@@ -256,6 +271,23 @@ pmd_perf_end_iteration(struct pmd_perf_stats *s, uint64_t now_tsc,\n     cum_ms->batches += s->current.batches;\n     cum_ms->max_vhost_qfill += s->current.max_vhost_qfill;\n\n+    if (log_on) {\n+        /* Log suspicious iterations. */\n+        if (cycles > iter_cycle_threshold) {\n+            reason = \"Excessive total cycles\";\n+        } else if (s->current.max_vhost_qfill >= log_q_thr) {\n+            reason = \"Vhost RX queue full\";\n+        }\n+        if (OVS_UNLIKELY(reason)) {\n+            pmd_perf_log_suspicious_iteration(s, cycles, reason);\n+        }\n+\n+        /* Log iteration stats interval when required. */\n+        if (OVS_UNLIKELY(s->log_end_it == s->iterations.idx)) {\n+            pmd_perf_log_iteration_neighborhood(s);\n+        }\n+    }\n+\n     /* Store in iteration history. */\n     history_store(&s->iterations, &s->current);\n     if (now_tsc - s->last_tsc > 10000) {\ndiff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c\nindex db294ea..059e5dc 100644\n--- a/lib/dpif-netdev.c\n+++ b/lib/dpif-netdev.c\n@@ -1147,6 +1147,11 @@ dpif_netdev_init(void)\n     unixctl_command_register(\"dpif-netdev/pmd-rxq-rebalance\", \"[dp]\",\n                              0, 1, dpif_netdev_pmd_rebalance,\n                              NULL);\n+    unixctl_command_register(\"dpif-netdev/pmd-perf-log-set\",\n+                             \"[on|off] [-b before] [-a after] \"\n+                             \"[-us usec] [-q qlen]\",\n+                             0, 10, pmd_perf_log_set_cmd,\n+                             NULL);\n     return 0;\n }\n\n",
    "prefixes": [
        "ovs-dev",
        "3/3"
    ]
}