get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 40771,
    "url": "http://patches.dpdk.org/api/patches/40771/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180607073705.32895-3-david.hunt@intel.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": "<20180607073705.32895-3-david.hunt@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180607073705.32895-3-david.hunt@intel.com",
    "date": "2018-06-07T07:37:01",
    "name": "[dpdk-dev,v1,2/6] examples/vm_power: add core list parameter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "dd48467c75be82c95fe3abd1ac770c40ed20864e",
    "submitter": {
        "id": 342,
        "url": "http://patches.dpdk.org/api/people/342/?format=api",
        "name": "Hunt, David",
        "email": "david.hunt@intel.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/20180607073705.32895-3-david.hunt@intel.com/mbox/",
    "series": [
        {
            "id": 33,
            "url": "http://patches.dpdk.org/api/series/33/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=33",
            "date": "2018-06-07T07:36:59",
            "name": "examples/vm_power: 100% Busy Polling",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/33/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/40771/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/40771/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 234331B3FF;\n\tThu,  7 Jun 2018 16:39:57 +0200 (CEST)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id BC1AE1B1E3\n\tfor <dev@dpdk.org>; Thu,  7 Jun 2018 16:39:53 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Jun 2018 07:39:52 -0700",
            "from silpixa00399952.ir.intel.com (HELO\n\tsilpixa00399952.ger.corp.intel.com) ([10.237.223.64])\n\tby fmsmga001.fm.intel.com with ESMTP; 07 Jun 2018 07:39:52 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.49,486,1520924400\"; d=\"scan'208\";a=\"62111500\"",
        "From": "David Hunt <david.hunt@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "david.hunt@intel.com",
        "Date": "Thu,  7 Jun 2018 08:37:01 +0100",
        "Message-Id": "<20180607073705.32895-3-david.hunt@intel.com>",
        "X-Mailer": "git-send-email 2.17.0",
        "In-Reply-To": "<20180607073705.32895-1-david.hunt@intel.com>",
        "References": "<20180607073705.32895-1-david.hunt@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 2/6] examples/vm_power: add core list parameter",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add in the '-l' command line parameter (also --core-list)\nSo the user can now pass --corelist=4,6,8-10 and it will\nexpand out to 4,6,8,9,10 using the parse function provided\nin parse.c (parse_set).\n\nThis list of cores is then used to enable out-of-band monitoring\nto scale up and down these cores based on the ratio of branch\nhits versus branch misses. The ratio will be low when a poll\nloop is spinning with no packets being received, so the frequency\nwill be scaled down.\n\nAlso , as part of this change, we introduce a core_info struct\nwhich keeps information on each core in the system, and whether\nwe're doing out of band monitoring on them.\n\nSigned-off-by: David Hunt <david.hunt@intel.com>\n---\n examples/vm_power_manager/Makefile        |  2 +-\n examples/vm_power_manager/main.c          | 34 ++++++++-\n examples/vm_power_manager/parse.c         | 93 +++++++++++++++++++++++\n examples/vm_power_manager/parse.h         | 20 +++++\n examples/vm_power_manager/power_manager.c | 31 ++++++++\n examples/vm_power_manager/power_manager.h | 20 +++++\n 6 files changed, 197 insertions(+), 3 deletions(-)\n create mode 100644 examples/vm_power_manager/parse.c\n create mode 100644 examples/vm_power_manager/parse.h",
    "diff": "diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile\nindex ef2a9f959..0c925967c 100644\n--- a/examples/vm_power_manager/Makefile\n+++ b/examples/vm_power_manager/Makefile\n@@ -19,7 +19,7 @@ APP = vm_power_mgr\n \n # all source are stored in SRCS-y\n SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c\n-SRCS-y += channel_monitor.c\n+SRCS-y += channel_monitor.c parse.c\n \n CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/\n CFLAGS += $(WERROR_FLAGS)\ndiff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c\nindex 043b374bc..cc2a1289c 100644\n--- a/examples/vm_power_manager/main.c\n+++ b/examples/vm_power_manager/main.c\n@@ -29,6 +29,7 @@\n #include \"channel_monitor.h\"\n #include \"power_manager.h\"\n #include \"vm_power_cli.h\"\n+#include \"parse.h\"\n #include <rte_pmd_ixgbe.h>\n #include <rte_pmd_i40e.h>\n #include <rte_pmd_bnxt.h>\n@@ -135,18 +136,22 @@ parse_portmask(const char *portmask)\n static int\n parse_args(int argc, char **argv)\n {\n-\tint opt, ret;\n+\tint opt, ret, cnt, i;\n \tchar **argvopt;\n+\tuint16_t *oob_enable;\n \tint option_index;\n \tchar *prgname = argv[0];\n+\tstruct core_info *ci;\n \tstatic struct option lgopts[] = {\n \t\t{ \"mac-updating\", no_argument, 0, 1},\n \t\t{ \"no-mac-updating\", no_argument, 0, 0},\n+\t\t{ \"core-list\", optional_argument, 0, 'l'},\n \t\t{NULL, 0, 0, 0}\n \t};\n \targvopt = argv;\n+\tci = get_core_info();\n \n-\twhile ((opt = getopt_long(argc, argvopt, \"p:q:T:\",\n+\twhile ((opt = getopt_long(argc, argvopt, \"l:p:q:T:\",\n \t\t\t\t  lgopts, &option_index)) != EOF) {\n \n \t\tswitch (opt) {\n@@ -158,6 +163,27 @@ parse_args(int argc, char **argv)\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t\tbreak;\n+\t\tcase 'l':\n+\t\t\toob_enable = malloc(ci->core_count * sizeof(uint16_t));\n+\t\t\tif (oob_enable == NULL) {\n+\t\t\t\tprintf(\"Error - Unable to allocate memory\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tcnt = parse_set(optarg, oob_enable, ci->core_count);\n+\t\t\tif (cnt < 0) {\n+\t\t\t\tprintf(\"Invalid core-list - [%s]\\n\",\n+\t\t\t\t\t\toptarg);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tfor (i = 0; i < ci->core_count; i++) {\n+\t\t\t\tif (oob_enable[i]) {\n+\t\t\t\t\tprintf(\"***Using core %d\\n\", i);\n+\t\t\t\t\tci->cd[i].oob_enabled = 1;\n+\t\t\t\t\tci->cd[i].global_enabled_cpus = 1;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tfree(oob_enable);\n+\t\t\tbreak;\n \t\t/* long options */\n \t\tcase 0:\n \t\t\tbreak;\n@@ -263,6 +289,10 @@ main(int argc, char **argv)\n \tuint16_t portid;\n \n \n+\tret = core_info_init();\n+\tif (ret < 0)\n+\t\trte_panic(\"Cannot allocate core info\\n\");\n+\n \tret = rte_eal_init(argc, argv);\n \tif (ret < 0)\n \t\trte_panic(\"Cannot init EAL\\n\");\ndiff --git a/examples/vm_power_manager/parse.c b/examples/vm_power_manager/parse.c\nnew file mode 100644\nindex 000000000..9de15c4a7\n--- /dev/null\n+++ b/examples/vm_power_manager/parse.c\n@@ -0,0 +1,93 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2014 Intel Corporation.\n+ * Copyright(c) 2014 6WIND S.A.\n+ */\n+\n+#include <stdlib.h>\n+#include <unistd.h>\n+#include <string.h>\n+#include <syslog.h>\n+#include <ctype.h>\n+#include <limits.h>\n+#include <errno.h>\n+#include <getopt.h>\n+#include <dlfcn.h>\n+#include <sys/types.h>\n+#include <sys/stat.h>\n+#include <dirent.h>\n+#include <rte_eal.h>\n+#include <rte_log.h>\n+#include \"parse.h\"\n+\n+/*\n+ * Parse elem, the elem could be single number/range or group\n+ * 1) A single number elem, it's just a simple digit. e.g. 9\n+ * 2) A single range elem, two digits with a '-' between. e.g. 2-6\n+ * 3) A group elem, combines multiple 1) or 2) e.g 0,2-4,6\n+ *    Within group, '-' used for a range separator;\n+ *                       ',' used for a single number.\n+ */\n+int\n+parse_set(const char *input, uint16_t set[], unsigned int num)\n+{\n+\tunsigned int idx;\n+\tconst char *str = input;\n+\tchar *end = NULL;\n+\tunsigned int min, max;\n+\n+\tmemset(set, 0, num * sizeof(uint16_t));\n+\n+\twhile (isblank(*str))\n+\t\tstr++;\n+\n+\t/* only digit or left bracket is qualify for start point */\n+\tif (!isdigit(*str) || *str == '\\0')\n+\t\treturn -1;\n+\n+\twhile (isblank(*str))\n+\t\tstr++;\n+\tif (*str == '\\0')\n+\t\treturn -1;\n+\n+\tmin = num;\n+\tdo {\n+\n+\t\t/* go ahead to the first digit */\n+\t\twhile (isblank(*str))\n+\t\t\tstr++;\n+\t\tif (!isdigit(*str))\n+\t\t\treturn -1;\n+\n+\t\t/* get the digit value */\n+\t\terrno = 0;\n+\t\tidx = strtoul(str, &end, 10);\n+\t\tif (errno || end == NULL || idx >= num)\n+\t\t\treturn -1;\n+\n+\t\t/* go ahead to separator '-' and ',' */\n+\t\twhile (isblank(*end))\n+\t\t\tend++;\n+\t\tif (*end == '-') {\n+\t\t\tif (min == num)\n+\t\t\t\tmin = idx;\n+\t\t\telse /* avoid continuous '-' */\n+\t\t\t\treturn -1;\n+\t\t} else if ((*end == ',') || (*end == '\\0')) {\n+\t\t\tmax = idx;\n+\n+\t\t\tif (min == num)\n+\t\t\t\tmin = idx;\n+\n+\t\t\tfor (idx = RTE_MIN(min, max);\n+\t\t\t\t\tidx <= RTE_MAX(min, max); idx++) {\n+\t\t\t\tset[idx] = 1;\n+\t\t\t}\n+\t\t\tmin = num;\n+\t\t} else\n+\t\t\treturn -1;\n+\n+\t\tstr = end + 1;\n+\t} while (*end != '\\0');\n+\n+\treturn str - input;\n+}\ndiff --git a/examples/vm_power_manager/parse.h b/examples/vm_power_manager/parse.h\nnew file mode 100644\nindex 000000000..a5971e9a2\n--- /dev/null\n+++ b/examples/vm_power_manager/parse.h\n@@ -0,0 +1,20 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#ifndef PARSE_H_\n+#define PARSE_H_\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+int\n+parse_set(const char *, uint16_t [], unsigned int);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+\n+#endif /* PARSE_H_ */\ndiff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c\nindex 35db25591..a7849e48a 100644\n--- a/examples/vm_power_manager/power_manager.c\n+++ b/examples/vm_power_manager/power_manager.c\n@@ -12,6 +12,7 @@\n #include <dirent.h>\n #include <errno.h>\n \n+#include <sys/sysinfo.h>\n #include <sys/types.h>\n \n #include <rte_log.h>\n@@ -54,6 +55,7 @@ struct freq_info {\n \n static struct freq_info global_core_freq_info[POWER_MGR_MAX_CPUS];\n \n+struct core_info ci;\n static uint64_t global_enabled_cpus;\n \n #define SYSFS_CPU_PATH \"/sys/devices/system/cpu/cpu%u/topology/core_id\"\n@@ -76,6 +78,35 @@ set_host_cpus_mask(void)\n \treturn num_cpus;\n }\n \n+struct core_info *\n+get_core_info(void)\n+{\n+\treturn &ci;\n+}\n+\n+int\n+core_info_init(void)\n+{\n+\tstruct core_info *ci;\n+\tint i;\n+\n+\tci = get_core_info();\n+\n+\tci->core_count = get_nprocs_conf();\n+\tci->cd = malloc(ci->core_count * sizeof(struct core_details));\n+\tif (!ci->cd) {\n+\t\tRTE_LOG(ERR, POWER_MANAGER, \"Failed to allocate memory for core info.\");\n+\t\treturn -1;\n+\t}\n+\tfor (i = 0; i < ci->core_count; i++) {\n+\t\tci->cd[i].global_enabled_cpus = 1;\n+\t\tci->cd[i].oob_enabled = 0;\n+\t\tci->cd[i].msr_fd = 0;\n+\t}\n+\tprintf(\"%d cores in system\\n\", ci->core_count);\n+\treturn 0;\n+}\n+\n int\n power_manager_init(void)\n {\ndiff --git a/examples/vm_power_manager/power_manager.h b/examples/vm_power_manager/power_manager.h\nindex 8a8a84aa4..45385de37 100644\n--- a/examples/vm_power_manager/power_manager.h\n+++ b/examples/vm_power_manager/power_manager.h\n@@ -8,6 +8,26 @@\n #ifdef __cplusplus\n extern \"C\" {\n #endif\n+struct core_details {\n+\tuint64_t last_branches;\n+\tuint64_t last_branch_misses;\n+\tuint16_t global_enabled_cpus;\n+\tuint16_t oob_enabled;\n+\tint msr_fd;\n+};\n+\n+struct core_info {\n+\tuint16_t core_count;\n+\tstruct core_details *cd;\n+};\n+\n+struct core_info *\n+get_core_info(void);\n+\n+int\n+core_info_init(void);\n+\n+#define RTE_LOGTYPE_POWER_MANAGER RTE_LOGTYPE_USER1\n \n /* Maximum number of CPUS to manage */\n #define POWER_MGR_MAX_CPUS 64\n",
    "prefixes": [
        "dpdk-dev",
        "v1",
        "2/6"
    ]
}