get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 129318,
    "url": "http://patchwork.dpdk.org/api/patches/129318/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230705224805.286156-6-stephen@networkplumber.org/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230705224805.286156-6-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230705224805.286156-6-stephen@networkplumber.org",
    "date": "2023-07-05T22:48:05",
    "name": "[v7,5/5] eal: add option to put timestamp on console output",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cd6c91809783bbc55ad193d7eaafd5eb85d21112",
    "submitter": {
        "id": 27,
        "url": "http://patchwork.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230705224805.286156-6-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 28845,
            "url": "http://patchwork.dpdk.org/api/series/28845/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=28845",
            "date": "2023-07-05T22:48:00",
            "name": "Logging timetamp and related patches",
            "version": 7,
            "mbox": "http://patchwork.dpdk.org/series/28845/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/129318/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/129318/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C2B6242DDE;\n\tThu,  6 Jul 2023 00:48:40 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id AB88A42D67;\n\tThu,  6 Jul 2023 00:48:17 +0200 (CEST)",
            "from mail-oa1-f48.google.com (mail-oa1-f48.google.com\n [209.85.160.48]) by mails.dpdk.org (Postfix) with ESMTP id D26FC400D5\n for <dev@dpdk.org>; Thu,  6 Jul 2023 00:48:14 +0200 (CEST)",
            "by mail-oa1-f48.google.com with SMTP id\n 586e51a60fabf-1b06777596cso182577fac.2\n for <dev@dpdk.org>; Wed, 05 Jul 2023 15:48:14 -0700 (PDT)",
            "from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218])\n by smtp.gmail.com with ESMTPSA id\n bb16-20020a17090b009000b002630bfd35b0sm1906044pjb.7.2023.07.05.15.48.13\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 05 Jul 2023 15:48:13 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688597294;\n x=1691189294;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=qI1WWRT8YfEhxohquvQ6ZC1uXJ/QOhS6iNuG443ytYY=;\n b=CVrbIr1SKQcRb5vCor/bLmzV8PxK9sawyBhlXwJ/yoZP0LX2GqabZHxcG7TxNUnMjJ\n Z//kS2N+Wb+o45mVWoge2R/nW/AHBlGnM0XgS+diAPbikYyFeav6XfDonNnqu/VgGc/n\n Hmln/wp/en94Dtw+VZXOfKTbzDB46o304OsviSb1jAyEQQyeYbKECpe2Ol+yYLHKl4Ef\n WVQQsSaHeAbPRkurvN1Ci3Tm+l88cpfBw+yPdhtznWjEq0FxviTowX7zuo3sK+05Kyoe\n 8g9WTJ0pu3rqFZ9sF58SgLQKIus9hDyOGoMObnzjXsB9dBFyGV1UU4tW305Va/nhMtVc\n YWtw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20221208; t=1688597294; x=1691189294;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=qI1WWRT8YfEhxohquvQ6ZC1uXJ/QOhS6iNuG443ytYY=;\n b=G37cmzA7VGf21UY8k1+Wafi4qU1nreLJu3bCfC0von2Kwjw5sxkpBnLiTce2OL+OBt\n 3l2BPYJ10KjV1MfadXFoXi7VTkMIONFbXYJRDXvV4/Bj8bDUWThlcJoRy2QCS0TnOKA4\n GuLPhL1sOmzvmxj/KKMPPMScjz8JbMiLVw0qB0LP7Wj9a/6h1UUvKoxnTNaWTLhEAeAD\n EthPamheH0nYy1HL02RZH5GWsnXKohRjW8qvli0j2s7nHaqzpYST6WiCa1d+tF3JSYh5\n P3zkQh3+RVDHb0Np5MhCk2/2/jo56+EEB4UNzz57gFUVq5elfZ0rDKRK7dTRVHHOQ49o\n KS9Q==",
        "X-Gm-Message-State": "ABy/qLZ/HGatc8qPVG4m9lCgEOjnDcXfk4nE4wVei2779R9TPxdhgjYh\n jJnPag8QhttEknboch/oxCVaXHA8Uj2wCcL7+Jk=",
        "X-Google-Smtp-Source": "\n APBJJlED0koBf/eFwC7KLKB3TDh7XpgFmEsJf0ZNJ/+9L5PAJ/8ALZy/MJ6qlzVP2tibzl5fef3lBA==",
        "X-Received": "by 2002:a05:6870:4292:b0:1b0:657f:5047 with SMTP id\n y18-20020a056870429200b001b0657f5047mr388467oah.46.1688597293834;\n Wed, 05 Jul 2023 15:48:13 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Bruce Richardson <bruce.richardson@intel.com>,\n Anatoly Burakov <anatoly.burakov@intel.com>",
        "Subject": "[PATCH v7 5/5] eal: add option to put timestamp on console output",
        "Date": "Wed,  5 Jul 2023 15:48:05 -0700",
        "Message-Id": "<20230705224805.286156-6-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20230705224805.286156-1-stephen@networkplumber.org>",
        "References": "<20200814173441.23086-1-stephen@networkplumber.org>\n <20230705224805.286156-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "When debugging driver or startup issues, it is useful to have\na timestamp on each message printed. The messages in syslog\nalready have a timestamp, but often syslog is not available\nduring testing. The timestamp format is chosen to look\nlike the default Linux dmesg timestamp.\n\nThe first few lines are not timestamped because the flag is stored\nin internal configuration which is stored in shared memory\nwhich is not setup up until a little later in startup process.\n\nThis logging skips the unnecessary step of going through stdio,\nwhich makes it more robust against being called in interrupt\nhandlers etc.\n\nExample:\n$ dpdk-testpmd --log-timestamp -- -i\nEAL: Detected CPU lcores: 16\nEAL: Detected NUMA nodes: 1\nEAL: Detected static linkage of DPDK\nEAL: Multi-process socket /var/run/dpdk/rte/mp_socket\nEAL: Selected IOVA mode 'VA'\n[       0.112264] testpmd: No probed ethernet devices\nInteractive-mode selected\n[       0.184573] testpmd: create a new mbuf pool <mb_pool_0>: n=163456, size=2176, socket=0\n[       0.184612] testpmd: preferred mempool ops selected: ring_mp_mc\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n app/test/test_eal_flags.c                     |  9 ++++\n .../freebsd_gsg/freebsd_eal_parameters.rst    |  5 +++\n doc/guides/linux_gsg/linux_eal_parameters.rst |  5 +++\n lib/eal/common/eal_common_options.c           |  6 +++\n lib/eal/common/eal_internal_cfg.h             |  3 ++\n lib/eal/common/eal_options.h                  |  2 +\n lib/eal/unix/eal_log.c                        | 45 ++++++++++++++++---\n 7 files changed, 70 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c\nindex d2b91e20750e..57637728d811 100644\n--- a/app/test/test_eal_flags.c\n+++ b/app/test/test_eal_flags.c\n@@ -1055,6 +1055,10 @@ test_misc_flags(void)\n \tconst char * const argv22[] = {prgname, prefix, mp_flag,\n \t\t\t\t       \"--huge-worker-stack=512\"};\n \n+\t/* Try running with --log-timestamp */\n+\tconst char * const argv23[] = {prgname, prefix, mp_flag,\n+\t\t\t\t       \"--log-timestamp\" };\n+\n \t/* run all tests also applicable to FreeBSD first */\n \n \tif (launch_proc(argv0) == 0) {\n@@ -1162,6 +1166,11 @@ test_misc_flags(void)\n \t\tprintf(\"Error - process did not run ok with --huge-worker-stack=size parameter\\n\");\n \t\tgoto fail;\n \t}\n+\tif (launch_proc(argv23) != 0) {\n+\t\tprintf(\"Error - process did not run ok with --log-timestamp parameter\\n\");\n+\t\tgoto fail;\n+\t}\n+\n \n \trmdir(hugepath_dir3);\n \trmdir(hugepath_dir2);\ndiff --git a/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst b/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst\nindex 9270d9fa3bfc..99cff10e963c 100644\n--- a/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst\n+++ b/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst\n@@ -45,3 +45,8 @@ Other options\n         local5\n         local6\n         local7\n+\n+*   ``--log-timestamp``\n+\n+    Add a timestamp of seconds and microseconds to each log message\n+    written to standard output.\ndiff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/linux_gsg/linux_eal_parameters.rst\nindex ea8f38139119..719ca6851625 100644\n--- a/doc/guides/linux_gsg/linux_eal_parameters.rst\n+++ b/doc/guides/linux_gsg/linux_eal_parameters.rst\n@@ -135,3 +135,8 @@ Other options\n         local5\n         local6\n         local7\n+\n+*   ``--log-timestamp``\n+\n+    Add a timestamp of seconds and microseconds to each log message\n+    written to standard output.\ndiff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c\nindex 005da4d12001..67fe6efb4526 100644\n--- a/lib/eal/common/eal_common_options.c\n+++ b/lib/eal/common/eal_common_options.c\n@@ -76,6 +76,7 @@ eal_long_options[] = {\n \t{OPT_IOVA_MODE,\t        1, NULL, OPT_IOVA_MODE_NUM        },\n \t{OPT_LCORES,            1, NULL, OPT_LCORES_NUM           },\n \t{OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },\n+\t{OPT_LOG_TIMESTAMP,     0, NULL, OPT_LOG_TIMESTAMP_NUM    },\n \t{OPT_TRACE,             1, NULL, OPT_TRACE_NUM            },\n \t{OPT_TRACE_DIR,         1, NULL, OPT_TRACE_DIR_NUM        },\n \t{OPT_TRACE_BUF_SIZE,    1, NULL, OPT_TRACE_BUF_SIZE_NUM   },\n@@ -1835,6 +1836,10 @@ eal_parse_common_option(int opt, const char *optarg,\n \t}\n \n #ifndef RTE_EXEC_ENV_WINDOWS\n+\tcase OPT_LOG_TIMESTAMP_NUM:\n+\t\tconf->log_timestamp = 1;\n+\t\tbreak;\n+\n \tcase OPT_TRACE_NUM: {\n \t\tif (eal_trace_args_save(optarg) < 0) {\n \t\t\tRTE_LOG(ERR, EAL, \"invalid parameters for --\"\n@@ -2194,6 +2199,7 @@ eal_common_usage(void)\n \t       \"  --\"OPT_PROC_TYPE\"         Type of this process (primary|secondary|auto)\\n\"\n #ifndef RTE_EXEC_ENV_WINDOWS\n \t       \"  --\"OPT_SYSLOG\"=<facility> Set syslog facility\\n\"\n+\t       \"  --\"OPT_LOG_TIMESTAMP\"     Timestamp log output\\n\"\n #endif\n \t       \"  --\"OPT_LOG_LEVEL\"=<level> Set global log level\\n\"\n \t       \"  --\"OPT_LOG_LEVEL\"=<type-match>:<level>\\n\"\ndiff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h\nindex 167ec501fa79..ca502d5dd365 100644\n--- a/lib/eal/common/eal_internal_cfg.h\n+++ b/lib/eal/common/eal_internal_cfg.h\n@@ -84,7 +84,10 @@ struct internal_config {\n \t/**< true if storing all pages within single files (per-page-size,\n \t * per-node) non-legacy mode only.\n \t */\n+\tuint8_t log_timestamp;          /**< add timestamp to console output */\n+\tstruct timespec log_start_time; /**< monotonic clock when started */\n \tvolatile int syslog_facility;\t  /**< facility passed to openlog() */\n+\n \t/** default interrupt mode for VFIO */\n \tvolatile enum rte_intr_mode vfio_intr_mode;\n \t/** the shared VF token for VFIO-PCI bound PF and VFs devices */\ndiff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h\nindex 3cc9cb641284..cc9723868e3c 100644\n--- a/lib/eal/common/eal_options.h\n+++ b/lib/eal/common/eal_options.h\n@@ -35,6 +35,8 @@ enum {\n \tOPT_LCORES_NUM,\n #define OPT_LOG_LEVEL         \"log-level\"\n \tOPT_LOG_LEVEL_NUM,\n+#define OPT_LOG_TIMESTAMP     \"log-timestamp\"\n+\tOPT_LOG_TIMESTAMP_NUM,\n #define OPT_TRACE             \"trace\"\n \tOPT_TRACE_NUM,\n #define OPT_TRACE_DIR         \"trace-dir\"\ndiff --git a/lib/eal/unix/eal_log.c b/lib/eal/unix/eal_log.c\nindex e66bcc68d07f..1ee94a5ee1e6 100644\n--- a/lib/eal/unix/eal_log.c\n+++ b/lib/eal/unix/eal_log.c\n@@ -4,7 +4,10 @@\n \n #include <stdio.h>\n #include <sys/types.h>\n+#include <sys/uio.h>\n #include <syslog.h>\n+#include <time.h>\n+#include <unistd.h>\n \n #include <rte_log.h>\n \n@@ -16,13 +19,38 @@\n  * default log function\n  */\n static ssize_t\n-console_log_write(__rte_unused void *c, const char *buf, size_t size)\n+console_log_write(void *c, const char *buf, size_t size)\n {\n+\tconst struct internal_config *internal_conf = c;\n \tssize_t ret;\n \n-\t/* write on stderr */\n-\tret = fwrite(buf, 1, size, stderr);\n-\tfflush(stderr);\n+\t/* add optional timestamp for stderr */\n+\tif (internal_conf->log_timestamp) {\n+\t\tstruct iovec iov[2];\n+\t\tstruct timespec ts;\n+\t\tchar tbuf[64];\n+\n+\t\t/* format up monotonic timestamp */\n+\t\tclock_gettime(CLOCK_MONOTONIC, &ts);\n+\t\tts.tv_sec -= internal_conf->log_start_time.tv_sec;\n+\t\tts.tv_nsec -= internal_conf->log_start_time.tv_nsec;\n+\t\tif (ts.tv_nsec < 0) {\n+\t\t\t--ts.tv_sec;\n+\t\t\tts.tv_nsec += 1000000000ul;\n+\t\t}\n+\n+\t\t/* use writev to put timestamp and buf in single operation */\n+\t\tiov[0].iov_base = tbuf;\n+\t\tiov[0].iov_len  = snprintf(tbuf, sizeof(tbuf), \"[%8lu.%06lu] \",\n+\t\t\t\t\t   ts.tv_sec, ts.tv_nsec / 1000u);\n+\n+\t\t/* casts are to unconstify the buf */\n+\t\tiov[1].iov_base = (void *)(uintptr_t)buf;\n+\t\tiov[1].iov_len = size;\n+\t\tret = writev(STDERR_FILENO, iov, 2);\n+\t} else {\n+\t\tret = write(STDERR_FILENO, buf, size);\n+\t}\n \n \t/* Syslog error levels are from 0 to 7, so subtract 1 to convert */\n \tsyslog(rte_log_cur_msg_loglevel() - 1, \"%.*s\", (int)size, buf);\n@@ -58,13 +86,20 @@ static cookie_io_functions_t console_log_func = {\n int\n eal_log_init(const char *id, int facility)\n {\n+\tstruct internal_config *internal_conf = eal_get_internal_configuration();\n \tFILE *log_stream;\n \n \t/* has user has already setup a log stream */\n \tif (eal_log_get_default())\n \t\treturn 0;\n \n-\tlog_stream = fopencookie(NULL, \"w+\", console_log_func);\n+\tif (internal_conf->process_type == RTE_PROC_PRIMARY &&\n+\t    internal_conf->log_timestamp) {\n+\t\tif (clock_gettime(CLOCK_MONOTONIC, &internal_conf->log_start_time) < 0)\n+\t\t\treturn -1;\n+\t}\n+\n+\tlog_stream = fopencookie(internal_conf, \"w+\", console_log_func);\n \tif (log_stream == NULL)\n \t\treturn -1;\n \n",
    "prefixes": [
        "v7",
        "5/5"
    ]
}