From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <harry.van.haaren@intel.com>
Received: from mga06.intel.com (mga06.intel.com [134.134.136.31])
 by dpdk.org (Postfix) with ESMTP id 2C9E1199A9
 for <dev@dpdk.org>; Thu, 21 Sep 2017 11:41:32 +0200 (CEST)
Received: from fmsmga005.fm.intel.com ([10.253.24.32])
 by orsmga104.jf.intel.com with ESMTP; 21 Sep 2017 02:41:31 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.42,424,1500966000"; d="scan'208";a="153873960"
Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155])
 by fmsmga005.fm.intel.com with ESMTP; 21 Sep 2017 02:41:30 -0700
Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by
 IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS)
 id 14.3.319.2; Thu, 21 Sep 2017 10:41:29 +0100
Received: from irsmsx101.ger.corp.intel.com ([169.254.1.22]) by
 IRSMSX156.ger.corp.intel.com ([169.254.3.33]) with mapi id 14.03.0319.002;
 Thu, 21 Sep 2017 10:41:29 +0100
From: "Van Haaren, Harry" <harry.van.haaren@intel.com>
To: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>, "thomas@monjalon.net"
 <thomas@monjalon.net>
CC: "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH v2] eal: add function to check lcore role
Thread-Index: AQHTMrffU35iJOLt80K2Zo0Yw8YiNaK/Dc6Q
Date: Thu, 21 Sep 2017 09:41:29 +0000
Message-ID: <E923DB57A917B54B9182A2E928D00FA650FA75E1@IRSMSX101.ger.corp.intel.com>
References: <1503501027-11046-1-git-send-email-pbhagavatula@caviumnetworks.com>
 <1505984291-18702-1-git-send-email-pbhagavatula@caviumnetworks.com>
In-Reply-To: <1505984291-18702-1-git-send-email-pbhagavatula@caviumnetworks.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmUzZWNiODQtOWE2Yi00NzRmLWI4NzktZmQ4Yzk5OGI3N2I1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImgrdFVLUGRWWFRZdzVGbmNvSHVpeW56eTl3a24ybEd2eDFqVGYrUVdJY0k9In0=
x-ctpclassification: CTP_IC
dlp-product: dlpe-windows
dlp-version: 11.0.0.116
dlp-reaction: no-action
x-originating-ip: [163.33.239.180]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH v2] eal: add function to check lcore role
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <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>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 21 Sep 2017 09:41:34 -0000

> From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com]
> Sent: Thursday, September 21, 2017 9:58 AM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; thomas@monjalon.net
> Cc: dev@dpdk.org; Pavan Bhagavatula <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v2] eal: add function to check lcore role
>=20
> From: Pavan Bhagavatula <pbhagavatula@caviumnetworks.com>
>=20
> This function can be used to check the role of a specific lcore.
>=20
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
>=20
> v2 changs:
>  - removed ack due to significant changes in patch
>  - addressed review comments
>  - modified commit title and message

Good work - a few final inline comments below;

- whitespace in bsd/linux .map files
- "unsigned" -> "unsigned int" (checkpatch)
- Move function to eal_common_thread.c

With those,

Acked-by: Harry van Haaren <harry.van.haaren@intel.com>


>  lib/librte_eal/bsdapp/eal/Makefile              |  1 +
>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  6 +++
>  lib/librte_eal/common/include/rte_lcore.h       | 14 +++++++
>  lib/librte_eal/common/rte_lcore.c               | 49 +++++++++++++++++++=
++++++
>  lib/librte_eal/linuxapp/eal/Makefile            |  1 +
>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  6 +++
>  6 files changed, 77 insertions(+)
>  create mode 100644 lib/librte_eal/common/rte_lcore.c
>=20
> diff --git a/lib/librte_eal/bsdapp/eal/Makefile
> b/lib/librte_eal/bsdapp/eal/Makefile
> index 005019e..f1263fc 100644
> --- a/lib/librte_eal/bsdapp/eal/Makefile
> +++ b/lib/librte_eal/bsdapp/eal/Makefile
> @@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D malloc_elem.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D malloc_heap.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D rte_keepalive.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D rte_service.c
> +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D rte_lcore.c
>=20
>  # from arch dir
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D rte_cpuflags.c
> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> index aac6fd7..3be3287 100644
> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> @@ -237,3 +237,9 @@ EXPERIMENTAL {
>  	rte_service_unregister;
>=20
>  } DPDK_17.08;
> +
> +DPDK_17.11 {
> +	global:
> +
> +	rte_lcore_has_role;
> +} DPDK_17.08;


I think there's usually a newline between the function and closing brace - =
nit pick.


> diff --git a/lib/librte_eal/common/include/rte_lcore.h
> b/lib/librte_eal/common/include/rte_lcore.h
> index 50e0d0f..777208d 100644
> --- a/lib/librte_eal/common/include/rte_lcore.h
> +++ b/lib/librte_eal/common/include/rte_lcore.h
> @@ -262,6 +262,20 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
>   */
>  int rte_thread_setname(pthread_t id, const char *name);
>=20
> +/**
> + * Test if the core supplied has a specific role
> + *
> + * @param lcore_id
> + *   The identifier of the lcore, which MUST be between 0 and
> + *   RTE_MAX_LCORE-1.
> + * @param role
> + *   The role to be checked against.
> + * @return
> + *   On success, return 0; otherwise return a negative value.
> + */
> +int
> +rte_lcore_has_role(unsigned lcore_id, enum rte_lcore_role_t role);
> +

Other functions use "unsigned" in this header, however checkpatch complains=
 about it. I think we should use "unsigned int" instead, to make checkpatch=
 happy and use more modern C practice (at the cost of minor deviation from =
the existing funcs).


>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/librte_eal/common/rte_lcore.c
> b/lib/librte_eal/common/rte_lcore.c
> new file mode 100644
> index 0000000..66c03f4
> --- /dev/null
> +++ b/lib/librte_eal/common/rte_lcore.c
> @@ -0,0 +1,49 @@
> +/*
> + *   BSD LICENSE
> + *
> + *   Copyright (C) Cavium, Inc. 2017.
> + *
> + *   Redistribution and use in source and binary forms, with or without
> + *   modification, are permitted provided that the following conditions
> + *   are met:
> + *
> + *     * Redistributions of source code must retain the above copyright
> + *       notice, this list of conditions and the following disclaimer.
> + *     * Redistributions in binary form must reproduce the above copyrig=
ht
> + *       notice, this list of conditions and the following disclaimer in
> + *       the documentation and/or other materials provided with the
> + *       distribution.
> + *     * Neither the name of Cavium, Inc nor the names of its
> + *       contributors may be used to endorse or promote products derived
> + *       from this software without specific prior written permission.
> + *
> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS F=
OR
> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGH=
T
> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTA=
L,
> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF US=
E,
> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A=
NY
> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE U=
SE
> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE=
.
> + */
> +
> +#include <rte_common.h>
> +#include <rte_lcore.h>
> +
> +
> +int
> +rte_lcore_has_role(unsigned lcore_id, enum rte_lcore_role_t role)
> +{
> +	struct rte_config *cfg =3D rte_eal_get_configuration();
> +
> +	if (lcore_id >=3D RTE_MAX_LCORE)
> +		return -EINVAL;
> +
> +	if (cfg->lcore_role[lcore_id] =3D=3D role)
> +		return 0;
> +
> +	return -EINVAL;
> +}

While reviewing, I found that the rte_socket_id() function is declared in r=
te_lcore.h, but implemented in eal_common_thread.c
This function should probably move there too - common thread sounds like a =
good home to this function. Apologies for not noticing this earlier, and su=
ggesting rte_lcore.c


> diff --git a/lib/librte_eal/linuxapp/eal/Makefile
> b/lib/librte_eal/linuxapp/eal/Makefile
> index 90bca4d..9596acb 100644
> --- a/lib/librte_eal/linuxapp/eal/Makefile
> +++ b/lib/librte_eal/linuxapp/eal/Makefile
> @@ -100,6 +100,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D malloc_elem=
.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D malloc_heap.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D rte_keepalive.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D rte_service.c
> +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D rte_lcore.c
>=20
>  # from arch dir
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D rte_cpuflags.c
> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> index 3a8f154..7304a34 100644
> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> @@ -242,3 +242,9 @@ EXPERIMENTAL {
>  	rte_service_unregister;
>=20
>  } DPDK_17.08;
> +
> +DPDK_17.11 {
> +	global:
> +
> +	rte_lcore_has_role;
> +} DPDK_17.08;
> --
> 2.7.4