Show a patch.

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

{
    "id": 43056,
    "url": "http://patches.dpdk.org/api/patches/43056/",
    "web_url": "http://patches.dpdk.org/patch/43056/",
    "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": "<20180713142302.34576-3-david.hunt@intel.com>",
    "date": "2018-07-13T14:22:55",
    "name": "[v4,2/9] examples/vm_power: add core list parameter",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "804e5d6a1dba42a109629dbf1e09dd3b63af42af",
    "submitter": {
        "id": 342,
        "url": "http://patches.dpdk.org/api/people/342/",
        "name": "David Hunt",
        "email": "david.hunt@intel.com"
    },
    "delegate": {
        "id": 22,
        "url": "http://patches.dpdk.org/api/users/22/",
        "username": "pdelarag",
        "first_name": "Pablo",
        "last_name": "de Lara Guarch",
        "email": "pablo.de.lara.guarch@intel.com"
    },
    "mbox": "http://patches.dpdk.org/patch/43056/mbox/",
    "series": [
        {
            "id": 568,
            "url": "http://patches.dpdk.org/api/series/568/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=568",
            "date": "2018-07-13T14:22:53",
            "name": "examples/vm_power: 100% Busy Polling",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/568/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/43056/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/43056/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "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 8FFF62C17;\n\tFri, 13 Jul 2018 16:23:24 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 4EF801E2F\n\tfor <dev@dpdk.org>; Fri, 13 Jul 2018 16:23:21 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t13 Jul 2018 07:23:20 -0700",
            "from silpixa00399952.ir.intel.com (HELO\n\tsilpixa00399952.ger.corp.intel.com) ([10.237.223.64])\n\tby orsmga007.jf.intel.com with ESMTP; 13 Jul 2018 07:23:19 -0700"
        ],
        "References": "<20180626092317.11031-2-david.hunt@intel.com>\n\t<20180713142302.34576-1-david.hunt@intel.com>",
        "X-Amp-File-Uploaded": "False",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<20180713142302.34576-3-david.hunt@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,347,1526367600\"; d=\"scan'208\";a=\"56278187\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "David Hunt <david.hunt@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": "<20180713142302.34576-1-david.hunt@intel.com>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Fri, 13 Jul 2018 15:22:55 +0100",
        "Cc": "david.hunt@intel.com,\n\tthomas@monjalon.net",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v4 2/9] examples/vm_power: add core list parameter"
    },
    "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>\nAcked-by: Radu Nicolau <radu.nicolau@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         | 81 +++++++++++++++++++++++\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, 185 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 0d3846971..613a40af0 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@@ -133,18 +134,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@@ -156,6 +161,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@@ -261,6 +287,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..8231533b6\n--- /dev/null\n+++ b/examples/vm_power_manager/parse.c\n@@ -0,0 +1,81 @@\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 <string.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": [
        "v4",
        "2/9"
    ]
}