From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BC80B2C7A for ; Mon, 9 Feb 2015 12:45:53 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 09 Feb 2015 03:45:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,543,1418112000"; d="scan'208";a="683044618" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by orsmga002.jf.intel.com with ESMTP; 09 Feb 2015 03:45:51 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 9 Feb 2015 19:45:49 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.62]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.161]) with mapi id 14.03.0195.001; Mon, 9 Feb 2015 19:45:49 +0800 From: "Liang, Cunming" To: Olivier MATZ , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 02/17] eal: new eal option '--lcores' for cpu assignment Thread-Index: AQHQPoxpLpBwmOUePk2LRHyNgl7prZzmsF0AgAGLWjA= Date: Mon, 9 Feb 2015 11:45:48 +0000 Message-ID: References: <1422491072-5114-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-3-git-send-email-cunming.liang@intel.com> <54D7C032.5090602@6wind.com> In-Reply-To: <54D7C032.5090602@6wind.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 02/17] eal: new eal option '--lcores' for cpu assignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2015 11:45:54 -0000 > -----Original Message----- > From: Olivier MATZ [mailto:olivier.matz@6wind.com] > Sent: Monday, February 09, 2015 4:00 AM > To: Liang, Cunming; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v4 02/17] eal: new eal option '--lcores' f= or cpu > assignment >=20 > Hi, >=20 > On 02/02/2015 03:02 AM, Cunming Liang wrote: > > It supports one new eal long option '--lcores' for EAL thread cpuset as= signment. > > > > The format pattern: > > --lcores=3D'lcores[@cpus]<,lcores[@cpus]>' > > lcores, cpus could be a single digit/range or a group. > > '(' and ')' are necessary if it's a group. > > If not supply '@cpus', the value of cpus uses the same as lcores. > > > > e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means starting 9 EAL thread as b= elow > > lcore 0 runs on cpuset 0x41 (cpu 0,6) > > lcore 1 runs on cpuset 0x2 (cpu 1) > > lcore 2 runs on cpuset 0xe0 (cpu 5,6,7) > > lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2) > > lcore 6 runs on cpuset 0x41 (cpu 0,6) > > lcore 7 runs on cpuset 0x80 (cpu 7) > > lcore 8 runs on cpuset 0x100 (cpu 8) > > > > Signed-off-by: Cunming Liang > > --- > > lib/librte_eal/common/eal_common_launch.c | 1 - > > lib/librte_eal/common/eal_common_options.c | 300 > ++++++++++++++++++++++++++++- > > lib/librte_eal/common/eal_options.h | 2 + > > lib/librte_eal/linuxapp/eal/Makefile | 1 + > > 4 files changed, 299 insertions(+), 5 deletions(-) > > > > diff --git a/lib/librte_eal/common/eal_common_launch.c > b/lib/librte_eal/common/eal_common_launch.c > > index 599f83b..2d732b1 100644 > > --- a/lib/librte_eal/common/eal_common_launch.c > > +++ b/lib/librte_eal/common/eal_common_launch.c > > @@ -117,4 +117,3 @@ rte_eal_mp_wait_lcore(void) > > rte_eal_wait_lcore(lcore_id); > > } > > } > > - >=20 >=20 > This line should be removed from the patch. [LCM] Accept. >=20 >=20 > > diff --git a/lib/librte_eal/common/eal_common_options.c > b/lib/librte_eal/common/eal_common_options.c > > index 67e02dc..29ebb6f 100644 > > --- a/lib/librte_eal/common/eal_common_options.c > > +++ b/lib/librte_eal/common/eal_common_options.c > > @@ -45,6 +45,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "eal_internal_cfg.h" > > #include "eal_options.h" > > @@ -85,6 +86,7 @@ eal_long_options[] =3D { > > {OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM}, > > {OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM}, > > {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM}, > > + {OPT_LCORES, 1, 0, OPT_LCORES_NUM}, > > {0, 0, 0, 0} > > }; > > > > @@ -255,9 +257,11 @@ eal_parse_corelist(const char *corelist) > > if (min =3D=3D RTE_MAX_LCORE) > > min =3D idx; > > for (idx =3D min; idx <=3D max; idx++) { > > - cfg->lcore_role[idx] =3D ROLE_RTE; > > - lcore_config[idx].core_index =3D count; > > - count++; > > + if (cfg->lcore_role[idx] !=3D ROLE_RTE) { > > + cfg->lcore_role[idx] =3D ROLE_RTE; > > + lcore_config[idx].core_index =3D count; > > + count++; > > + } > > } > > min =3D RTE_MAX_LCORE; > > } else > > @@ -292,6 +296,279 @@ eal_parse_master_lcore(const char *arg) > > return 0; > > } > > > > +/* > > + * Parse elem, the elem could be single number/range or '(' ')' group > > + * Within group elem, '-' used for a range seperator; > > + * ',' used for a single number. > > + */ > > +static int > > +eal_parse_set(const char *input, uint16_t set[], unsigned num) >=20 > It's not very clear what elem is. Maybe it could be a bit reworded. > What about naming the function "eal_parse_cpuset()" instead? [LCM] As it not only parse cpuset but also used for lcore set, so 'eal_pars= e_cpuset' is not accurate. The set/elem here identify for a single number (e.g. 1), a number range (e.= g. 4-6) or a group (e.g. (3,4-8,9) ). I'll reword the comment for better understand. Thanks. >=20 >=20 > > +{ > > + unsigned idx; > > + const char *str =3D input; > > + char *end =3D NULL; > > + unsigned min, max; > > + > > + memset(set, 0, num * sizeof(uint16_t)); > > + > > + while (isblank(*str)) > > + str++; > > + > > + /* only digit or left bracket is qulify for start point */ > > + if ((!isdigit(*str) && *str !=3D '(') || *str =3D=3D '\0') > > + return -1; > > + > > + /* process single number or single range of number */ > > + if (*str !=3D '(') { > > + errno =3D 0; > > + idx =3D strtoul(str, &end, 10); > > + if (errno || end =3D=3D NULL || idx >=3D num) > > + return -1; > > + else { > > + while (isblank(*end)) > > + end++; > > + > > + min =3D idx; > > + max =3D idx; > > + if (*end =3D=3D '-') { > > + /* proccess single - */ > > + end++; > > + while (isblank(*end)) > > + end++; > > + if (!isdigit(*end)) > > + return -1; > > + > > + errno =3D 0; > > + idx =3D strtoul(end, &end, 10); > > + if (errno || end =3D=3D NULL || idx >=3D num) > > + return -1; > > + max =3D idx; > > + while (isblank(*end)) > > + end++; > > + if (*end !=3D ',' && *end !=3D '\0') > > + return -1; > > + } > > + > > + if (*end !=3D ',' && *end !=3D '\0' && > > + *end !=3D '@') > > + return -1; > > + > > + for (idx =3D RTE_MIN(min, max); > > + idx <=3D RTE_MAX(min, max); idx++) > > + set[idx] =3D 1; > > + > > + return end - input; > > + } > > + } > > + > > + /* process set within bracket */ > > + str++; > > + while (isblank(*str)) > > + str++; > > + if (*str =3D=3D '\0') > > + return -1; > > + > > + min =3D RTE_MAX_LCORE; > > + do { > > + > > + /* go ahead to the first digit */ > > + while (isblank(*str)) > > + str++; > > + if (!isdigit(*str)) > > + return -1; > > + > > + /* get the digit value */ > > + errno =3D 0; > > + idx =3D strtoul(str, &end, 10); > > + if (errno || end =3D=3D NULL || idx >=3D num) > > + return -1; > > + > > + /* go ahead to separator '-',',' and ')' */ > > + while (isblank(*end)) > > + end++; > > + if (*end =3D=3D '-') { > > + if (min =3D=3D RTE_MAX_LCORE) > > + min =3D idx; > > + else /* avoid continuous '-' */ > > + return -1; > > + } else if ((*end =3D=3D ',') || (*end =3D=3D ')')) { > > + max =3D idx; > > + if (min =3D=3D RTE_MAX_LCORE) > > + min =3D idx; > > + for (idx =3D RTE_MIN(min, max); > > + idx <=3D RTE_MAX(min, max); idx++) > > + set[idx] =3D 1; > > + > > + min =3D RTE_MAX_LCORE; > > + } else > > + return -1; > > + > > + str =3D end + 1; > > + } while (*end !=3D '\0' && *end !=3D ')'); > > + > > + return str - input; > > +} >=20 > In the function above, there are some typos in the comments > seperator -> separator > qulify -> qualify > proccess -> process [LCM] Sorry for that, will fix it. >=20 > > + > > +/* convert from set array to cpuset bitmap */ > > +static inline int > > +convert_to_cpuset(rte_cpuset_t *cpusetp, > > + uint16_t *set, unsigned num) >=20 > I don't think the function should be inlined [LCM] accept. >=20 >=20 >=20 > Regards, > Olivier