get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 138489,
    "url": "http://patches.dpdk.org/api/patches/138489/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240320105529.5626-2-lihuisong@huawei.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20240320105529.5626-2-lihuisong@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240320105529.5626-2-lihuisong@huawei.com",
    "date": "2024-03-20T10:55:28",
    "name": "[1/2] power: introduce PM QoS interface",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "09e56ad0eaf7b07592ec400947ac497fa67ef3ae",
    "submitter": {
        "id": 2085,
        "url": "http://patches.dpdk.org/api/people/2085/?format=api",
        "name": "lihuisong (C)",
        "email": "lihuisong@huawei.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240320105529.5626-2-lihuisong@huawei.com/mbox/",
    "series": [
        {
            "id": 31563,
            "url": "http://patches.dpdk.org/api/series/31563/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31563",
            "date": "2024-03-20T10:55:27",
            "name": "introduce PM QoS interface",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/31563/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/138489/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/138489/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 5F3D143CFF;\n\tWed, 20 Mar 2024 12:02:58 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5E9B241132;\n\tWed, 20 Mar 2024 12:02:47 +0100 (CET)",
            "from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])\n by mails.dpdk.org (Postfix) with ESMTP id 24A7B40298\n for <dev@dpdk.org>; Wed, 20 Mar 2024 12:02:44 +0100 (CET)",
            "from mail.maildlp.com (unknown [172.19.163.174])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4V05GF10fczXjP1;\n Wed, 20 Mar 2024 19:00:05 +0800 (CST)",
            "from kwepemm600004.china.huawei.com (unknown [7.193.23.242])\n by mail.maildlp.com (Postfix) with ESMTPS id B12A61404DB;\n Wed, 20 Mar 2024 19:02:41 +0800 (CST)",
            "from localhost.localdomain (10.28.79.22) by\n kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.1.2507.35; Wed, 20 Mar 2024 19:02:41 +0800"
        ],
        "From": "Huisong Li <lihuisong@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<thomas@monjalon.net>, <ferruh.yigit@amd.com>,\n <anatoly.burakov@intel.com>, <david.hunt@intel.com>,\n <sivaprasad.tummala@amd.com>, <liuyonglong@huawei.com>,\n <lihuisong@huawei.com>",
        "Subject": "[PATCH 1/2] power: introduce PM QoS interface",
        "Date": "Wed, 20 Mar 2024 18:55:28 +0800",
        "Message-ID": "<20240320105529.5626-2-lihuisong@huawei.com>",
        "X-Mailer": "git-send-email 2.22.0",
        "In-Reply-To": "<20240320105529.5626-1-lihuisong@huawei.com>",
        "References": "<20240320105529.5626-1-lihuisong@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"UTF-8\"",
        "Content-Transfer-Encoding": "8bit",
        "X-Originating-IP": "[10.28.79.22]",
        "X-ClientProxiedBy": "dggems706-chm.china.huawei.com (10.3.19.183) To\n kwepemm600004.china.huawei.com (7.193.23.242)",
        "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": "The system-wide CPU latency QoS limit has a positive impact on the idle\nstate selection in cpuidle governor.\n\nLinux creates a cpu_dma_latency device under '/dev' directory to obtain the\nCPU latency QoS limit on system and send the QoS request for userspace.\nPlease see the PM QoS framework in the following link:\nhttps://docs.kernel.org/power/pm_qos_interface.html?highlight=qos\nThis feature has beed supported by kernel-v2.6.25.\n\nThe deeper the idle state, the lower the power consumption, but the longer\nthe resume time. Some service are delay sensitive and very except the low\nresume time, like interrupt packet receiving mode.\n\nSo this PM QoS API make it easy to obtain the CPU latency limit on system\nand send the CPU latency QoS request for the application that need them.\n\nThe recommend usage method is as follows:\n1) an application process first creates QoS request.\n2) update the CPU latency request to zero when need.\n3) back to the default value when no need(this step is optional).\n4) release QoS request when process exit.\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\n---\n doc/guides/prog_guide/power_man.rst    |  16 ++++\n doc/guides/rel_notes/release_24_03.rst |   4 +\n lib/power/meson.build                  |   2 +\n lib/power/rte_power_qos.c              |  98 ++++++++++++++++++++++++\n lib/power/rte_power_qos.h              | 101 +++++++++++++++++++++++++\n lib/power/version.map                  |   4 +\n 6 files changed, 225 insertions(+)\n create mode 100644 lib/power/rte_power_qos.c\n create mode 100644 lib/power/rte_power_qos.h",
    "diff": "diff --git a/doc/guides/prog_guide/power_man.rst b/doc/guides/prog_guide/power_man.rst\nindex f6674efe2d..493c75bf9d 100644\n--- a/doc/guides/prog_guide/power_man.rst\n+++ b/doc/guides/prog_guide/power_man.rst\n@@ -249,6 +249,22 @@ Get Num Pkgs\n Get Num Dies\n   Get the number of die's on a given package.\n \n+PM QoS API\n+----------\n+The deeper the idle state, the lower the power consumption, but the longer\n+the resume time. Some service threads are delay sensitive and very except\n+the low resume time, like interrupt packet receiving mode.\n+\n+This PM QoS API is aimed to obtain the CPU latency limit on system and send the\n+CPU latency QoS request for the application that need them.\n+\n+* ``rte_power_qos_get_curr_cpu_latency()`` is used to get the current CPU\n+  latency limit on system.\n+* For sending CPU latency QoS request, first call ``rte_power_create_qos_request()``\n+  to create a QoS request, then update CPU latency value by calling\n+  ``rte_power_qos_update_request()``. The ``rte_power_release_qos_request()`` is\n+  used to release this QoS request when process exit.\n+\n References\n ----------\n \ndiff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst\nindex 14826ea08f..b5be724133 100644\n--- a/doc/guides/rel_notes/release_24_03.rst\n+++ b/doc/guides/rel_notes/release_24_03.rst\n@@ -196,6 +196,10 @@ New Features\n   Added DMA producer mode to measure performance of ``OP_FORWARD`` mode\n   of event DMA adapter.\n \n+* **Added CPU latency PM QoS support.**\n+\n+  Added the interface querying cpu latency PM QoS limit on system and\n+  the interface sending cpu latency QoS request in power lib.\n \n Removed Items\n -------------\ndiff --git a/lib/power/meson.build b/lib/power/meson.build\nindex b8426589b2..8222e178b0 100644\n--- a/lib/power/meson.build\n+++ b/lib/power/meson.build\n@@ -23,12 +23,14 @@ sources = files(\n         'rte_power.c',\n         'rte_power_uncore.c',\n         'rte_power_pmd_mgmt.c',\n+        'rte_power_qos.c',\n )\n headers = files(\n         'rte_power.h',\n         'rte_power_guest_channel.h',\n         'rte_power_pmd_mgmt.h',\n         'rte_power_uncore.h',\n+        'rte_power_qos.h',\n )\n if cc.has_argument('-Wno-cast-qual')\n     cflags += '-Wno-cast-qual'\ndiff --git a/lib/power/rte_power_qos.c b/lib/power/rte_power_qos.c\nnew file mode 100644\nindex 0000000000..d2b55923a0\n--- /dev/null\n+++ b/lib/power/rte_power_qos.c\n@@ -0,0 +1,98 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2024 HiSilicon Limited\n+ */\n+\n+#include <errno.h>\n+#include <fcntl.h>\n+#include <unistd.h>\n+\n+#include <rte_log.h>\n+\n+#include \"power_common.h\"\n+#include \"rte_power_qos.h\"\n+\n+#define QOS_CPU_DMA_LATENCY_DEV \"/dev/cpu_dma_latency\"\n+\n+struct rte_power_qos_info {\n+\t/*\n+\t * Keep file descriptor to update QoS request until there are no\n+\t * necessary anymore.\n+\t */\n+\tint fd;\n+\tint cur_cpu_latency; /* unit microseconds */\n+\t};\n+\n+struct rte_power_qos_info g_qos = {\n+\t.fd = -1,\n+\t.cur_cpu_latency = -1,\n+};\n+\n+int\n+rte_power_qos_get_curr_cpu_latency(int *latency)\n+{\n+\tint fd, ret;\n+\n+\tfd = open(QOS_CPU_DMA_LATENCY_DEV, O_RDONLY);\n+\tif (fd < 0) {\n+\t\tPOWER_LOG(ERR, \"Failed to open %s\", QOS_CPU_DMA_LATENCY_DEV);\n+\t\treturn -1;\n+\t}\n+\n+\tret = read(fd, latency, sizeof(*latency));\n+\tif (ret == 0) {\n+\t\tPOWER_LOG(ERR, \"Failed to read %s\", QOS_CPU_DMA_LATENCY_DEV);\n+\t\treturn -1;\n+\t}\n+\tclose(fd);\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_power_qos_update_request(int latency)\n+{\n+\tint ret;\n+\n+\tif (g_qos.fd == -1) {\n+\t\tPOWER_LOG(ERR, \"please create QoS request first.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (latency < 0) {\n+\t\tPOWER_LOG(ERR, \"latency should be non negative number.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (g_qos.cur_cpu_latency != -1 && latency == g_qos.cur_cpu_latency)\n+\t\treturn 0;\n+\n+\tret = write(g_qos.fd, &latency, sizeof(latency));\n+\tif (ret == 0) {\n+\t\tPOWER_LOG(ERR, \"Failed to write %s\", QOS_CPU_DMA_LATENCY_DEV);\n+\t\treturn -1;\n+\t}\n+\tg_qos.cur_cpu_latency = latency;\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_power_create_qos_request(void)\n+{\n+\tg_qos.fd = open(QOS_CPU_DMA_LATENCY_DEV, O_WRONLY);\n+\tif (g_qos.fd < 0) {\n+\t\tPOWER_LOG(ERR, \"Failed to open %s.\", QOS_CPU_DMA_LATENCY_DEV);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void\n+rte_power_release_qos_request(void)\n+{\n+\tif (g_qos.fd != -1) {\n+\t\tclose(g_qos.fd);\n+\t\tg_qos.fd = -1;\n+\t}\n+}\ndiff --git a/lib/power/rte_power_qos.h b/lib/power/rte_power_qos.h\nnew file mode 100644\nindex 0000000000..d39f5d0c0f\n--- /dev/null\n+++ b/lib/power/rte_power_qos.h\n@@ -0,0 +1,101 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2024 HiSilicon Limited\n+ */\n+\n+#ifndef RTE_POWER_QOS_H\n+#define RTE_POWER_QOS_H\n+\n+#include <rte_compat.h>\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * @file rte_power_qos.h\n+ *\n+ * PM QoS API.\n+ *\n+ * The system-wide CPU latency QoS limit has a positive impact on the idle\n+ * state selection in cpuidle governor.\n+ *\n+ * Linux creates a cpu_dma_latency device under '/dev' directory to obtain the\n+ * CPU latency QoS limit on system and send the QoS request for userspace.\n+ * Please see the PM QoS framework in the following link:\n+ * https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos\n+ *\n+ * The deeper the idle state, the lower the power consumption, but the longer\n+ * the resume time. Some service are delay sensitive and very except the\n+ * low resume time, like interrupt packet receiving mode.\n+ *\n+ * So this PM QoS API make it easy to obtain the CPU latency limit on system and\n+ * send the CPU latency QoS request for the application that need them.\n+ *\n+ * The recommend usage method is as follows:\n+ * 1) an application process first creates QoS request.\n+ * 2) update the CPU latency request to zero when need.\n+ * 3) back to the default value @see PM_QOS_CPU_LATENCY_DEFAULT_VALUE when\n+ *    no need (this step is optional).\n+ * 4)release QoS request when process exit.\n+ */\n+\n+#define QOS_USEC_PER_SEC                        1000000\n+#define PM_QOS_CPU_LATENCY_DEFAULT_VALUE        (2000 * QOS_USEC_PER_SEC)\n+#define PM_QOS_STRICT_LATENCY_VALUE             0\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Create CPU latency QoS request and release this request by\n+ * @see rte_power_release_qos_request.\n+ *\n+ * @return\n+ *   0 on success. Otherwise negative value is returned.\n+ */\n+__rte_experimental\n+int rte_power_create_qos_request(void);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * release CPU latency QoS request.\n+ */\n+__rte_experimental\n+void rte_power_release_qos_request(void);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Get the current CPU latency QoS limit on system.\n+ * The default value in kernel is @see PM_QOS_CPU_LATENCY_DEFAULT_VALUE.\n+ *\n+ * @return\n+ *   0 on success. Otherwise negative value is returned.\n+ */\n+__rte_experimental\n+int rte_power_qos_get_curr_cpu_latency(int *latency);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Update the CPU latency QoS request.\n+ * Note: need to create QoS request first and then call this API.\n+ *\n+ * @param latency\n+ *   The latency should be greater than and equal to zero.\n+ *\n+ * @return\n+ *   0 on success. Otherwise negative value is returned.\n+ */\n+__rte_experimental\n+int rte_power_qos_update_request(int latency);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* RTE_POWER_QOS_H */\ndiff --git a/lib/power/version.map b/lib/power/version.map\nindex ad92a65f91..42770762b1 100644\n--- a/lib/power/version.map\n+++ b/lib/power/version.map\n@@ -51,4 +51,8 @@ EXPERIMENTAL {\n \trte_power_set_uncore_env;\n \trte_power_uncore_freqs;\n \trte_power_unset_uncore_env;\n+\trte_power_create_qos_request;\n+\trte_power_release_qos_request;\n+\trte_power_qos_get_curr_cpu_latency;\n+\trte_power_qos_update_request;\n };\n",
    "prefixes": [
        "1/2"
    ]
}