get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2607,
    "url": "https://patches.dpdk.org/api/patches/2607/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1422428365-5875-3-git-send-email-cunming.liang@intel.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<1422428365-5875-3-git-send-email-cunming.liang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1422428365-5875-3-git-send-email-cunming.liang@intel.com",
    "date": "2015-01-28T06:59:12",
    "name": "[dpdk-dev,v2,02/15] eal: new eal option '--lcores' for cpu assignment",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "c3eb4dc93eacc121585aaa786881f1f43370d7d8",
    "submitter": {
        "id": 46,
        "url": "https://patches.dpdk.org/api/people/46/?format=api",
        "name": "Cunming Liang",
        "email": "cunming.liang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1422428365-5875-3-git-send-email-cunming.liang@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2607/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2607/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 398C55A8E;\n\tWed, 28 Jan 2015 08:00:12 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 8544F5A7A\n\tfor <dev@dpdk.org>; Wed, 28 Jan 2015 07:59:56 +0100 (CET)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby fmsmga101.fm.intel.com with ESMTP; 27 Jan 2015 22:59:55 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby orsmga002.jf.intel.com with ESMTP; 27 Jan 2015 22:59:54 -0800",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id t0S6xpxG023585;\n\tWed, 28 Jan 2015 14:59:51 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t0S6xmVI005943; Wed, 28 Jan 2015 14:59:50 +0800",
            "(from cliang18@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t0S6xmgo005939; \n\tWed, 28 Jan 2015 14:59:48 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,479,1418112000\"; d=\"scan'208\";a=\"677179927\"",
        "From": "Cunming Liang <cunming.liang@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Wed, 28 Jan 2015 14:59:12 +0800",
        "Message-Id": "<1422428365-5875-3-git-send-email-cunming.liang@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1422428365-5875-1-git-send-email-cunming.liang@intel.com>",
        "References": "<1421914598-2747-1-git-send-email-cunming.liang@intel.com>\n\t<1422428365-5875-1-git-send-email-cunming.liang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 02/15] eal: new eal option '--lcores' for cpu\n\tassignment",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://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": "<http://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": "It supports one new eal long option '--lcores' for EAL thread cpuset assignment.\n\nThe format pattern:\n\t--lcores='lcores[@cpus]<,lcores[@cpus]>'\nlcores, cpus could be a single digit/range or a group.\n'(' and ')' are necessary if it's a group.\nIf not supply '@cpus', the value of cpus uses the same as lcores.\n\ne.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means starting 9 EAL thread as below\n  lcore 0 runs on cpuset 0x41 (cpu 0,6)\n  lcore 1 runs on cpuset 0x2 (cpu 1)\n  lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)\n  lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)\n  lcore 6 runs on cpuset 0x41 (cpu 0,6)\n  lcore 7 runs on cpuset 0x80 (cpu 7)\n  lcore 8 runs on cpuset 0x100 (cpu 8)\n\nSigned-off-by: Cunming Liang <cunming.liang@intel.com>\n---\n lib/librte_eal/common/eal_common_launch.c  |   1 -\n lib/librte_eal/common/eal_common_options.c | 300 ++++++++++++++++++++++++++++-\n lib/librte_eal/common/eal_options.h        |   2 +\n lib/librte_eal/linuxapp/eal/Makefile       |   1 +\n 4 files changed, 299 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/eal_common_launch.c b/lib/librte_eal/common/eal_common_launch.c\nindex 599f83b..2d732b1 100644\n--- a/lib/librte_eal/common/eal_common_launch.c\n+++ b/lib/librte_eal/common/eal_common_launch.c\n@@ -117,4 +117,3 @@ rte_eal_mp_wait_lcore(void)\n \t\trte_eal_wait_lcore(lcore_id);\n \t}\n }\n-\ndiff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c\nindex 67e02dc..29ebb6f 100644\n--- a/lib/librte_eal/common/eal_common_options.c\n+++ b/lib/librte_eal/common/eal_common_options.c\n@@ -45,6 +45,7 @@\n #include <rte_lcore.h>\n #include <rte_version.h>\n #include <rte_devargs.h>\n+#include <rte_memcpy.h>\n \n #include \"eal_internal_cfg.h\"\n #include \"eal_options.h\"\n@@ -85,6 +86,7 @@ eal_long_options[] = {\n \t{OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM},\n \t{OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM},\n \t{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},\n+\t{OPT_LCORES, 1, 0, OPT_LCORES_NUM},\n \t{0, 0, 0, 0}\n };\n \n@@ -255,9 +257,11 @@ eal_parse_corelist(const char *corelist)\n \t\t\tif (min == RTE_MAX_LCORE)\n \t\t\t\tmin = idx;\n \t\t\tfor (idx = min; idx <= max; idx++) {\n-\t\t\t\tcfg->lcore_role[idx] = ROLE_RTE;\n-\t\t\t\tlcore_config[idx].core_index = count;\n-\t\t\t\tcount++;\n+\t\t\t\tif (cfg->lcore_role[idx] != ROLE_RTE) {\n+\t\t\t\t\tcfg->lcore_role[idx] = ROLE_RTE;\n+\t\t\t\t\tlcore_config[idx].core_index = count;\n+\t\t\t\t\tcount++;\n+\t\t\t\t}\n \t\t\t}\n \t\t\tmin = RTE_MAX_LCORE;\n \t\t} else\n@@ -292,6 +296,279 @@ eal_parse_master_lcore(const char *arg)\n \treturn 0;\n }\n \n+/*\n+ * Parse elem, the elem could be single number/range or '(' ')' group\n+ * Within group elem, '-' used for a range seperator;\n+ *                    ',' used for a single number.\n+ */\n+static int\n+eal_parse_set(const char *input, uint16_t set[], unsigned num)\n+{\n+\tunsigned idx;\n+\tconst char *str = input;\n+\tchar *end = NULL;\n+\tunsigned 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 qulify for start point */\n+\tif ((!isdigit(*str) && *str != '(') || *str == '\\0')\n+\t\treturn -1;\n+\n+\t/* process single number or single range of number */\n+\tif (*str != '(') {\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+\t\telse {\n+\t\t\twhile (isblank(*end))\n+\t\t\t\tend++;\n+\n+\t\t\tmin = idx;\n+\t\t\tmax = idx;\n+\t\t\tif (*end == '-') {\n+\t\t\t\t/* proccess single <number>-<number> */\n+\t\t\t\tend++;\n+\t\t\t\twhile (isblank(*end))\n+\t\t\t\t\tend++;\n+\t\t\t\tif (!isdigit(*end))\n+\t\t\t\t\treturn -1;\n+\n+\t\t\t\terrno = 0;\n+\t\t\t\tidx = strtoul(end, &end, 10);\n+\t\t\t\tif (errno || end == NULL || idx >= num)\n+\t\t\t\t\treturn -1;\n+\t\t\t\tmax = idx;\n+\t\t\t\twhile (isblank(*end))\n+\t\t\t\t\tend++;\n+\t\t\t\tif (*end != ',' && *end != '\\0')\n+\t\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tif (*end != ',' && *end != '\\0' &&\n+\t\t\t    *end != '@')\n+\t\t\t\treturn -1;\n+\n+\t\t\tfor (idx = RTE_MIN(min, max);\n+\t\t\t     idx <= RTE_MAX(min, max); idx++)\n+\t\t\t\tset[idx] = 1;\n+\n+\t\t\treturn end - input;\n+\t\t}\n+\t}\n+\n+\t/* process set within bracket */\n+\tstr++;\n+\twhile (isblank(*str))\n+\t\tstr++;\n+\tif (*str == '\\0')\n+\t\treturn -1;\n+\n+\tmin = RTE_MAX_LCORE;\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 == RTE_MAX_LCORE)\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 == ')')) {\n+\t\t\tmax = idx;\n+\t\t\tif (min == RTE_MAX_LCORE)\n+\t\t\t\tmin = idx;\n+\t\t\tfor (idx = RTE_MIN(min, max);\n+\t\t\t     idx <= RTE_MAX(min, max); idx++)\n+\t\t\t\tset[idx] = 1;\n+\n+\t\t\tmin = RTE_MAX_LCORE;\n+\t\t} else\n+\t\t\treturn -1;\n+\n+\t\tstr = end + 1;\n+\t} while (*end != '\\0' && *end != ')');\n+\n+\treturn str - input;\n+}\n+\n+/* convert from set array to cpuset bitmap */\n+static inline int\n+convert_to_cpuset(rte_cpuset_t *cpusetp,\n+\t      uint16_t *set, unsigned num)\n+{\n+\tunsigned idx;\n+\n+\tCPU_ZERO(cpusetp);\n+\n+\tfor (idx = 0; idx < num; idx++) {\n+\t\tif (!set[idx])\n+\t\t\tcontinue;\n+\n+\t\tif (!lcore_config[idx].detected) {\n+\t\t\tRTE_LOG(ERR, EAL, \"core %u \"\n+\t\t\t\t\"unavailable\\n\", idx);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tCPU_SET(idx, cpusetp);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * The format pattern: --lcores='lcores[@cpus]<,lcores[@cpus]>'\n+ * lcores, cpus could be a single digit/range or a group.\n+ * '(' and ')' are necessary if it's a group.\n+ * If not supply '@cpus', the value of cpus uses the same as lcores.\n+ * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below\n+ *   lcore 0 runs on cpuset 0x41 (cpu 0,6)\n+ *   lcore 1 runs on cpuset 0x2 (cpu 1)\n+ *   lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)\n+ *   lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)\n+ *   lcore 6 runs on cpuset 0x41 (cpu 0,6)\n+ *   lcore 7 runs on cpuset 0x80 (cpu 7)\n+ *   lcore 8 runs on cpuset 0x100 (cpu 8)\n+ */\n+static int\n+eal_parse_lcores(const char *lcores)\n+{\n+\tstruct rte_config *cfg = rte_eal_get_configuration();\n+\tstatic uint16_t set[RTE_MAX_LCORE];\n+\tunsigned idx = 0;\n+\tint i;\n+\tunsigned count = 0;\n+\tconst char *lcore_start = NULL;\n+\tconst char *end = NULL;\n+\tint offset;\n+\trte_cpuset_t cpuset;\n+\tint lflags = 0;\n+\tint ret = -1;\n+\n+\tif (lcores == NULL)\n+\t\treturn -1;\n+\n+\t/* Remove all blank characters ahead and after */\n+\twhile (isblank(*lcores))\n+\t\tlcores++;\n+\ti = strnlen(lcores, sysconf(_SC_ARG_MAX));\n+\twhile ((i > 0) && isblank(lcores[i - 1]))\n+\t\ti--;\n+\n+\tCPU_ZERO(&cpuset);\n+\n+\t/* Reset lcore config */\n+\tfor (idx = 0; idx < RTE_MAX_LCORE; idx++) {\n+\t\tcfg->lcore_role[idx] = ROLE_OFF;\n+\t\tlcore_config[idx].core_index = -1;\n+\t\tCPU_ZERO(&lcore_config[idx].cpuset);\n+\t}\n+\n+\t/* Get list of cores */\n+\tdo {\n+\t\twhile (isblank(*lcores))\n+\t\t\tlcores++;\n+\t\tif (*lcores == '\\0')\n+\t\t\tgoto err;\n+\n+\t\t/* record lcore_set start point */\n+\t\tlcore_start = lcores;\n+\n+\t\t/* go across a complete bracket */\n+\t\tif (*lcore_start == '(') {\n+\t\t\tlcores += strcspn(lcores, \")\");\n+\t\t\tif (*lcores++ == '\\0')\n+\t\t\t\tgoto err;\n+\t\t}\n+\n+\t\t/* scan the separator '@', ','(next) or '\\0'(finish) */\n+\t\tlcores += strcspn(lcores, \"@,\");\n+\n+\t\tif (*lcores == '@') {\n+\t\t\t/* explict assign cpu_set */\n+\t\t\toffset = eal_parse_set(lcores + 1, set, RTE_DIM(set));\n+\t\t\tif (offset < 0)\n+\t\t\t\tgoto err;\n+\n+\t\t\t/* prepare cpu_set and update the end cursor */\n+\t\t\tif (0 > convert_to_cpuset(&cpuset,\n+\t\t\t\t\t\t  set, RTE_DIM(set)))\n+\t\t\t\tgoto err;\n+\t\t\tend = lcores + 1 + offset;\n+\t\t} else { /* ',' or '\\0' */\n+\t\t\t/* haven't given cpu_set, current loop done */\n+\t\t\tend = lcores;\n+\n+\t\t\t/* go back to check <number>-<number> */\n+\t\t\toffset = strcspn(lcore_start, \"-\");\n+\t\t\tif (offset < (end - lcore_start))\n+\t\t\t\tlflags = 1;\n+\t\t}\n+\n+\t\tif (*end != ',' && *end != '\\0')\n+\t\t\tgoto err;\n+\n+\t\t/* parse lcore_set from start point */\n+\t\tif (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))\n+\t\t\tgoto err;\n+\n+\t\t/* without '@', by default using lcore_set as cpu_set */\n+\t\tif (*lcores != '@' &&\n+\t\t    0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))\n+\t\t\tgoto err;\n+\n+\t\t/* start to update lcore_set */\n+\t\tfor (idx = 0; idx < RTE_MAX_LCORE; idx++) {\n+\t\t\tif (!set[idx])\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (cfg->lcore_role[idx] != ROLE_RTE) {\n+\t\t\t\tlcore_config[idx].core_index = count;\n+\t\t\t\tcfg->lcore_role[idx] = ROLE_RTE;\n+\t\t\t\tcount++;\n+\t\t\t}\n+\n+\t\t\tif (lflags) {\n+\t\t\t\tCPU_ZERO(&cpuset);\n+\t\t\t\tCPU_SET(idx, &cpuset);\n+\t\t\t}\n+\t\t\trte_memcpy(&lcore_config[idx].cpuset, &cpuset,\n+\t\t\t\t   sizeof(rte_cpuset_t));\n+\t\t}\n+\n+\t\tlcores = end + 1;\n+\t} while (*end != '\\0');\n+\n+\tif (count == 0)\n+\t\tgoto err;\n+\n+\tcfg->lcore_count = count;\n+\tlcores_parsed = 1;\n+\tret = 0;\n+\n+err:\n+\n+\treturn ret;\n+}\n+\n static int\n eal_parse_syslog(const char *facility, struct internal_config *conf)\n {\n@@ -492,6 +769,13 @@ eal_parse_common_option(int opt, const char *optarg,\n \t\tconf->log_level = log;\n \t\tbreak;\n \t}\n+\tcase OPT_LCORES_NUM:\n+\t\tif (eal_parse_lcores(optarg) < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"invalid parameter for --\"\n+\t\t\t\tOPT_LCORES \"\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tbreak;\n \n \t/* don't know what to do, leave this to caller */\n \tdefault:\n@@ -530,7 +814,7 @@ eal_check_common_options(struct internal_config *internal_cfg)\n \n \tif (!lcores_parsed) {\n \t\tRTE_LOG(ERR, EAL, \"CPU cores must be enabled with options \"\n-\t\t\t\"-c or -l\\n\");\n+\t\t\t\"-c, -l or --lcores\\n\");\n \t\treturn -1;\n \t}\n \tif (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {\n@@ -586,6 +870,14 @@ eal_common_usage(void)\n \t       \"                 The argument format is <c1>[-c2][,c3[-c4],...]\\n\"\n \t       \"                 where c1, c2, etc are core indexes between 0 and %d\\n\"\n \t       \"  --\"OPT_MASTER_LCORE\" ID: Core ID that is used as master\\n\"\n+\t       \"  --\"OPT_LCORES\" MAP: maps between lcore_set to phys_cpu_set\\n\"\n+\t       \"                 The argument format is\\n\"\n+\t       \"                       'lcores[@cpus]<,lcores[@cpus],...>'\\n\"\n+\t       \"                 lcores and cpus list are grouped by '(' and ')'\\n\"\n+\t       \"                 Within the group, '-' is used for range separator,\\n\"\n+\t       \"                 ',' is used for single number separator.\\n\"\n+\t       \"                 '( )' can be omitted for single element group, '@' \\n\"\n+\t       \"                 can be omitted if cpus and lcores has the same value\\n\"\n \t       \"  -n NUM       : Number of memory channels\\n\"\n \t       \"  -v           : Display version information on startup\\n\"\n \t       \"  -m MB        : memory to allocate (see also --\"OPT_SOCKET_MEM\")\\n\"\ndiff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h\nindex e476f8d..a1cc59f 100644\n--- a/lib/librte_eal/common/eal_options.h\n+++ b/lib/librte_eal/common/eal_options.h\n@@ -77,6 +77,8 @@ enum {\n \tOPT_CREATE_UIO_DEV_NUM,\n #define OPT_VFIO_INTR    \"vfio-intr\"\n \tOPT_VFIO_INTR_NUM,\n+#define OPT_LCORES \"lcores\"\n+\tOPT_LCORES_NUM,\n \tOPT_LONG_MAX_NUM\n };\n \ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex 0e9c447..025d836 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -95,6 +95,7 @@ CFLAGS_eal_hugepage_info.o := -D_GNU_SOURCE\n CFLAGS_eal_pci.o := -D_GNU_SOURCE\n CFLAGS_eal_pci_vfio.o := -D_GNU_SOURCE\n CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE\n+CFLAGS_eal_common_options.o := -D_GNU_SOURCE\n \n # workaround for a gcc bug with noreturn attribute\n # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "02/15"
    ]
}