Show a patch.

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

{
    "id": 44112,
    "url": "http://patches.dpdk.org/api/patches/44112/",
    "web_url": "http://patches.dpdk.org/patch/44112/",
    "project": {
        "id": 1,
        "url": "http://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": "<20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771~P_LI1zFBt2959529595eucas1p1H@eucas1p1.samsung.com>",
    "date": "2018-08-31T12:45:16",
    "name": "[RFC,1/2] eal: add nanosleep based delay function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b63324737b331af13b77b8ee75b31b1964e92ab3",
    "submitter": {
        "id": 323,
        "url": "http://patches.dpdk.org/api/people/323/",
        "name": "Ilya Maximets",
        "email": "i.maximets@samsung.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/44112/mbox/",
    "series": [
        {
            "id": 1137,
            "url": "http://patches.dpdk.org/api/series/1137/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1137",
            "date": "2018-08-31T12:45:15",
            "name": "CPU non-blocking delay",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1137/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44112/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44112/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "In-Reply-To": "<20180831124517.27619-1-i.maximets@samsung.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Mailer": "git-send-email 2.17.1",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id C46585B2E;\n\tFri, 31 Aug 2018 14:44:06 +0200 (CEST)",
            "from mailout2.w1.samsung.com (mailout2.w1.samsung.com\n\t[210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 6B0405B2E\n\tfor <dev@dpdk.org>; Fri, 31 Aug 2018 14:44:05 +0200 (CEST)",
            "from eucas1p1.samsung.com (unknown [182.198.249.206])\n\tby mailout2.w1.samsung.com (KnoxPortal) with ESMTP id\n\t20180831124403euoutp02b9e4ee57af5e90da70f5e9347fbccc5d~P_LKFkrns0968909689euoutp02w\n\tfor <dev@dpdk.org>; Fri, 31 Aug 2018 12:44:03 +0000 (GMT)",
            "from eusmges3new.samsung.com (unknown [203.254.199.245]) by\n\teucas1p2.samsung.com (KnoxPortal) with ESMTP id\n\t20180831124403eucas1p26542eca12413f738a903426e83e93ada~P_LJpYSg12420224202eucas1p2g;\n\tFri, 31 Aug 2018 12:44:03 +0000 (GMT)",
            "from eucas1p2.samsung.com ( [182.198.249.207]) by\n\teusmges3new.samsung.com (EUCPMTA) with SMTP id A9.EC.04806.218398B5;\n\tFri, 31 Aug 2018 13:44:02 +0100 (BST)",
            "from eusmtrp2.samsung.com (unknown [182.198.249.139]) by\n\teucas1p1.samsung.com (KnoxPortal) with ESMTPA id\n\t20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771~P_LI1zFBt2959529595eucas1p1H;\n\tFri, 31 Aug 2018 12:44:02 +0000 (GMT)",
            "from eusmgms2.samsung.com (unknown [182.198.249.180]) by\n\teusmtrp2.samsung.com (KnoxPortal) with ESMTP id\n\t20180831124401eusmtrp221faf92d5294b19d9c1f8db282ebac75~P_LIkkm0-2459624596eusmtrp2J;\n\tFri, 31 Aug 2018 12:44:01 +0000 (GMT)",
            "from eusmtip2.samsung.com ( [203.254.199.222]) by\n\teusmgms2.samsung.com (EUCPMTA) with SMTP id 6F.DF.04128.118398B5;\n\tFri, 31 Aug 2018 13:44:01 +0100 (BST)",
            "from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by\n\teusmtip2.samsung.com (KnoxPortal) with ESMTPA id\n\t20180831124401eusmtip2afc5aecbd516a8038958acf1041cc444~P_LHuDPPy2110821108eusmtip2a;\n\tFri, 31 Aug 2018 12:44:00 +0000 (GMT)"
        ],
        "X-Brightmail-Tracker": [
            "H4sIAAAAAAAAA+NgFvrFIsWRmVeSWpSXmKPExsWy7djP87pCFp3RBgtXGVp0f2hhsrixyt7i\n\t3aftTBZX2n+yW8xc8JnR4v2fRSwW0zf0s1lsPfOX0WL/88PsDpwevxYsZfVYvOclk0ffllWM\n\tAcxRXDYpqTmZZalF+nYJXBmbny1hLbiiU/Fv/znGBsZWlS5GTg4JAROJn/ufMXUxcnEICaxg\n\tlHh7/Co7hPOFUeLbqTZGCOczo8TBV8uByjjAWu4+zYWIL2eUeP/uOlTRD0aJW+vPsIHMZRPQ\n\tkTi1+ggjiC0iICDxuXMxG0gRs8BRJolrXdOZQRLCAlYSe052soBMZRFQlfj0VgHiJnmJ1RsO\n\tgJVwCthILDneAHafhMBnNonJd/eCDeUVKJNYc/sOK0SDi8TMn/+hbGGJV8e3sEPYMhL/d85n\n\tgrDrJe63vGSEGNTBKDH90D+ohL3Eltfn2EGOYBbQlFi/Sx8i7Cjx8k4TC8THfBI33gqChJmB\n\tzEnbQM4HCfNKdLQJQVSrSPw+uJwZwpaSuPnuMztEiYfExbOckODpZ5T4vG410wRG+VkIuxYw\n\tMq5iFE8tLc5NTy02zkst1ytOzC0uzUvXS87P3cQITBGn/x3/uoNx35+kQ4wCHIxKPLwRH9uj\n\thVgTy4orcw8xSnAwK4nwcmZ0RAvxpiRWVqUW5ccXleakFh9ilOZgURLn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zPKXquUWIozEg21mIuKEwF8ePTgbwIAAA=="
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;\n\ts=mail20170921; t=1535719443;\n\tbh=AHXkTKWAMEGt6H5X0LCekT+rZUu+9Rd/UFakd5yqq6E=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=PWoR+DvrTGlCxehh9xvhMkPVrQao2uhBHswP2f0uMgB7cTj6aZ3YiTW/RkjJDIib/\n\t8FIh6Lk1KxXl3Q3wrH5G8c0pPUFzIXXDD0l3Ook1yRvucyoIEVUvS0esd2uNKEOGS5\n\tU8j+sKj5IMjyYfmD9bgUGsfQBaW1eGPINr5/A1y0=",
        "X-BeenThere": "dev@dpdk.org",
        "X-CMS-RootMailID": "20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771",
        "Message-Id": "<20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771~P_LI1zFBt2959529595eucas1p1H@eucas1p1.samsung.com>",
        "References": "<20180831124517.27619-1-i.maximets@samsung.com>\n\t<CGME20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771@eucas1p1.samsung.com>",
        "X-RootMTR": "20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771",
        "X-Msg-Generator": "CA",
        "Delivered-To": "patchwork@dpdk.org",
        "X-AuditID": "cbfec7f5-367ff700000012c6-a7-5b89381202f9",
        "From": "Ilya Maximets <i.maximets@samsung.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Cc": "Jingjing Wu <jingjing.wu@intel.com>, Konstantin Ananyev\n\t<konstantin.ananyev@intel.com>, Wenzhuo Lu <wenzhuo.lu@intel.com>, Beilei\n\tXing <beilei.xing@intel.com>, Qi Zhang <qi.z.zhang@intel.com>, Xiao Wang\n\t<xiao.w.wang@intel.com>, Bruce Richardson <bruce.richardson@intel.com>,\n\tIlya Maximets <i.maximets@samsung.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-EPHeader": "CA",
        "To": "dev@dpdk.org",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-CMS-MailID": "20180831124402eucas1p120ba1cdc8c3f6bc6c5bd09b5d3ede771",
        "Subject": "[dpdk-dev] [RFC 1/2] eal: add nanosleep based delay function",
        "CMS-TYPE": "201P",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com\n\t20180831124403euoutp02b9e4ee57af5e90da70f5e9347fbccc5d~P_LKFkrns0968909689euoutp02w",
        "Date": "Fri, 31 Aug 2018 15:45:16 +0300"
    },
    "content": "Add a new rte_delay_us_sleep() function that uses nanosleep().\nThis function can be used by applications to not implement\ntheir own nanosleep() based callback and by internal DPDK\ncode if CPU non-blocking delay needed.\n\nSigned-off-by: Ilya Maximets <i.maximets@samsung.com>\n---\n lib/librte_eal/common/eal_common_timer.c      | 19 +++++++\n .../common/include/generic/rte_cycles.h       | 11 ++++\n lib/librte_eal/rte_eal_version.map            |  1 +\n test/test/autotest_data.py                    |  6 +++\n test/test/meson.build                         |  1 +\n test/test/test_cycles.c                       | 51 ++++++++++++++-----\n 6 files changed, 75 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c\nindex 2e2b770fb..4a00525ca 100644\n--- a/lib/librte_eal/common/eal_common_timer.c\n+++ b/lib/librte_eal/common/eal_common_timer.c\n@@ -7,9 +7,11 @@\n #include <unistd.h>\n #include <inttypes.h>\n #include <sys/types.h>\n+#include <time.h>\n #include <errno.h>\n \n #include <rte_common.h>\n+#include <rte_compat.h>\n #include <rte_log.h>\n #include <rte_cycles.h>\n #include <rte_pause.h>\n@@ -31,6 +33,23 @@ rte_delay_us_block(unsigned int us)\n \t\trte_pause();\n }\n \n+void __rte_experimental\n+rte_delay_us_sleep(unsigned int us)\n+{\n+\tstruct timespec wait[2];\n+\tint ind = 0;\n+\n+\twait[0].tv_sec = 0;\n+\tif (us >= US_PER_S) {\n+\t\twait[0].tv_sec = us / US_PER_S;\n+\t\tus -= wait[0].tv_sec * US_PER_S;\n+\t}\n+\twait[0].tv_nsec = 1000 * us;\n+\n+\twhile (nanosleep(&wait[ind], &wait[1 - ind]) == EINTR)\n+\t\tind = 1 - ind;\n+}\n+\n uint64_t\n rte_get_tsc_hz(void)\n {\ndiff --git a/lib/librte_eal/common/include/generic/rte_cycles.h b/lib/librte_eal/common/include/generic/rte_cycles.h\nindex 0ff1af504..ac379e878 100644\n--- a/lib/librte_eal/common/include/generic/rte_cycles.h\n+++ b/lib/librte_eal/common/include/generic/rte_cycles.h\n@@ -13,6 +13,7 @@\n  */\n \n #include <stdint.h>\n+#include <rte_compat.h>\n #include <rte_debug.h>\n #include <rte_atomic.h>\n \n@@ -157,6 +158,16 @@ rte_delay_ms(unsigned ms)\n  */\n void rte_delay_us_block(unsigned int us);\n \n+/**\n+ * Delay function that uses system sleep.\n+ * Does not block the CPU core.\n+ *\n+ * @param us\n+ *   Number of microseconds to wait.\n+ */\n+void __rte_experimental\n+rte_delay_us_sleep(unsigned int us);\n+\n /**\n  * Replace rte_delay_us with user defined function.\n  *\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 344a43d32..d68777ce0 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -270,6 +270,7 @@ EXPERIMENTAL {\n \trte_class_register;\n \trte_class_unregister;\n \trte_ctrl_thread_create;\n+\trte_delay_us_sleep;\n \trte_dev_event_callback_register;\n \trte_dev_event_callback_unregister;\n \trte_dev_event_monitor_start;\ndiff --git a/test/test/autotest_data.py b/test/test/autotest_data.py\nindex f68d9b111..874d0cb53 100644\n--- a/test/test/autotest_data.py\n+++ b/test/test/autotest_data.py\n@@ -278,6 +278,12 @@\n         \"Func\":    default_autotest,\n         \"Report\":  None,\n     },\n+    {\n+        \"Name\":    \"Sleep delay\",\n+        \"Command\": \"delay_us_sleep_autotest\",\n+        \"Func\":    default_autotest,\n+        \"Report\":  None,\n+    },\n     {\n         \"Name\":    \"Rawdev autotest\",\n         \"Command\": \"rawdev_autotest\",\ndiff --git a/test/test/meson.build b/test/test/meson.build\nindex b1dd6eca2..0078aea30 100644\n--- a/test/test/meson.build\n+++ b/test/test/meson.build\n@@ -143,6 +143,7 @@ test_names = [\n \t'cryptodev_dpaa_sec_autotest',\n \t'cycles_autotest',\n \t'debug_autotest',\n+\t'delay_us_sleep_autotest',\n \t'devargs_autotest',\n \t'distributor_autotest',\n \t'distributor_perf_autotest',\ndiff --git a/test/test/test_cycles.c b/test/test/test_cycles.c\nindex 149f60b07..c78e6a5b1 100644\n--- a/test/test/test_cycles.c\n+++ b/test/test/test_cycles.c\n@@ -23,6 +23,30 @@\n  *   of cycles is correct with regard to the frequency of the timer.\n  */\n \n+static int\n+check_wait_one_second(void)\n+{\n+\tuint64_t cycles, prev_cycles;\n+\tuint64_t hz = rte_get_timer_hz();\n+\tuint64_t max_inc = (hz / 100); /* 10 ms max between 2 reads */\n+\n+\t/* check that waiting 1 second is precise */\n+\tprev_cycles = rte_get_timer_cycles();\n+\trte_delay_us(1000000);\n+\tcycles = rte_get_timer_cycles();\n+\n+\tif ((uint64_t)(cycles - prev_cycles) > (hz + max_inc)) {\n+\t\tprintf(\"delay_us is not accurate: too long\\n\");\n+\t\treturn -1;\n+\t}\n+\tif ((uint64_t)(cycles - prev_cycles) < (hz - max_inc)) {\n+\t\tprintf(\"delay_us is not accurate: too short\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int\n test_cycles(void)\n {\n@@ -43,24 +67,23 @@ test_cycles(void)\n \t\tprev_cycles = cycles;\n \t}\n \n-\t/* check that waiting 1 second is precise */\n-\tprev_cycles = rte_get_timer_cycles();\n-\trte_delay_us(1000000);\n-\tcycles = rte_get_timer_cycles();\n+\treturn check_wait_one_second();\n+}\n \n-\tif ((uint64_t)(cycles - prev_cycles) > (hz + max_inc)) {\n-\t\tprintf(\"delay_us is not accurate: too long\\n\");\n-\t\treturn -1;\n-\t}\n-\tif ((uint64_t)(cycles - prev_cycles) < (hz - max_inc)) {\n-\t\tprintf(\"delay_us is not accurate: too short\\n\");\n-\t\treturn -1;\n-\t}\n+REGISTER_TEST_COMMAND(cycles_autotest, test_cycles);\n \n-\treturn 0;\n+/*\n+ * One second precision test with rte_delay_us_sleep.\n+ */\n+\n+static int\n+test_delay_us_sleep(void)\n+{\n+\trte_delay_us_callback_register(rte_delay_us_sleep);\n+\treturn check_wait_one_second();\n }\n \n-REGISTER_TEST_COMMAND(cycles_autotest, test_cycles);\n+REGISTER_TEST_COMMAND(delay_us_sleep_autotest, test_delay_us_sleep);\n \n /*\n  * rte_delay_us_callback test\n",
    "prefixes": [
        "RFC",
        "1/2"
    ]
}