Thread (24 messages) 24 messages, 3 authors, 2017-10-11

Re: [PATCH v2] eal: add function to check lcore role

From: Pavan Nikhilesh Bhagavatula <hidden>
Date: 2017-09-21 10:04:10

On Thu, Sep 21, 2017 at 09:41:29AM +0000, Van Haaren, Harry wrote:
quoted
From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com]
Sent: Thursday, September 21, 2017 9:58 AM
To: Van Haaren, Harry <redacted>; thomas@monjalon.net
Cc: dev@dpdk.org; Pavan Bhagavatula <redacted>
Subject: [dpdk-dev] [PATCH v2] eal: add function to check lcore role

From: Pavan Bhagavatula <redacted>

This function can be used to check the role of a specific lcore.

Signed-off-by: Pavan Nikhilesh <redacted>
---

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;
Thanks Harry
- whitespace in bsd/linux .map files
- "unsigned" -> "unsigned int" (checkpatch)
- Move function to eal_common_thread.c
For some reason ./devtools/checkpatches.sh reports no error.
Will move the function to eal_common_thread.c and send a v3.
With those,

Acked-by: Harry van Haaren <redacted>

quoted
 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
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) += malloc_elem.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += malloc_heap.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_keepalive.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_service.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_lcore.c

 # from arch dir
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += 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;

 } 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.

quoted
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);

+/**
+ * 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).

quoted
 #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 copyright
+ *       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 FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   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 = rte_eal_get_configuration();
+
+	if (lcore_id >= RTE_MAX_LCORE)
+		return -EINVAL;
+
+	if (cfg->lcore_role[lcore_id] == role)
+		return 0;
+
+	return -EINVAL;
+}
While reviewing, I found that the rte_socket_id() function is declared in rte_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 suggesting rte_lcore.c

quoted
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) += malloc_elem.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += malloc_heap.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_keepalive.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_lcore.c

 # from arch dir
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += 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;

 } DPDK_17.08;
+
+DPDK_17.11 {
+	global:
+
+	rte_lcore_has_role;
+} DPDK_17.08;
--
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help