patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] fbarray: get fbarrays from containerized secondary
@ 2019-04-16  1:59 ogawa.yasufumi
  2019-04-16  3:43 ` [dpdk-stable] [PATCH v2 0/1] Get " ogawa.yasufumi
                   ` (2 more replies)
  0 siblings, 3 replies; 56+ messages in thread
From: ogawa.yasufumi @ 2019-04-16  1:59 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev, stable, Yasufumi Ogawa

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

In secondary_msl_create_walk(), it creates a file for fbarrays with its
PID for reserving unique name among secondary processes. However, it
does not work as expected if secondary is run as app container becuase
each of containerized secondary has PID 1. To reserve unique name, use
hostname instead of PID if the value is 1.

Cc: stable@dpdk.org

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 lib/librte_eal/linux/eal/eal_memalloc.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index 1e9ebb86d..beec03648 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -1362,6 +1362,7 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl,
 	struct rte_memseg_list *primary_msl, *local_msl;
 	char name[PATH_MAX];
 	int msl_idx, ret;
+	char proc_id[16];
 
 	if (msl->external)
 		return 0;
@@ -1371,8 +1372,28 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl,
 	local_msl = &local_memsegs[msl_idx];
 
 	/* create distinct fbarrays for each secondary */
-	snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%i",
-		primary_msl->memseg_arr.name, getpid());
+	/* if run secondary in a container, the name of fbarray file cannot
+	 * be decided with pid because getpid() always returns 1, so use
+	 * hostname as a unique identifier among containers instead.
+	 */
+	if (getpid() == 1) {
+		FILE *hn_fp;
+		hn_fp = fopen("/etc/hostname", "r");
+		if (hn_fp == NULL) {
+			RTE_LOG(ERR, EAL,
+				"Cannot open '/etc/hostname' for secondary\n");
+			return -1;
+		}
+
+		/* with docker, /etc/hostname just has one entry of hostname */
+		if (fscanf(hn_fp, "%s", proc_id) == EOF)
+			return -1;
+		fclose(hn_fp);
+	} else
+		sprintf(proc_id, "%d", (int)getpid());
+
+	snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s",
+			primary_msl->memseg_arr.name, proc_id);
 
 	ret = rte_fbarray_init(&local_msl->memseg_arr, name,
 		primary_msl->memseg_arr.len,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2023-06-13 16:51 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16  1:59 [dpdk-stable] [PATCH] fbarray: get fbarrays from containerized secondary ogawa.yasufumi
2019-04-16  3:43 ` [dpdk-stable] [PATCH v2 0/1] Get " ogawa.yasufumi
2019-04-16  3:43   ` [dpdk-stable] [PATCH v2 1/1] fbarray: get " ogawa.yasufumi
2019-07-04 20:17     ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2019-07-05  8:53     ` [dpdk-stable] " Burakov, Anatoly
2019-07-09 10:22       ` [dpdk-stable] [dpdk-dev] " Yasufumi Ogawa
2019-07-09 10:24         ` Burakov, Anatoly
2019-07-09 10:26           ` Burakov, Anatoly
2019-07-11  9:37             ` Yasufumi Ogawa
2019-07-11  9:43               ` Burakov, Anatoly
2019-07-11 10:31 ` [dpdk-stable] [PATCH v3 0/1] " yasufum.o
2019-07-11 10:31   ` [dpdk-stable] [PATCH v3 1/1] " yasufum.o
2019-07-11 10:53     ` Burakov, Anatoly
2019-07-11 11:57       ` Yasufumi Ogawa
2019-07-11 13:14         ` Burakov, Anatoly
2019-07-12  2:22           ` Yasufumi Ogawa
2019-07-22  1:06             ` Ogawa Yasufumi
2019-07-22  9:33               ` Burakov, Anatoly
2019-07-22  9:25             ` Burakov, Anatoly
2019-07-24  8:20   ` [dpdk-stable] [PATCH v4 0/1] " yasufum.o
2019-07-24  8:20     ` [dpdk-stable] [PATCH v4 1/1] " yasufum.o
2019-07-24  9:59       ` Burakov, Anatoly
2019-07-30  8:16         ` Thomas Monjalon
2019-07-30  9:18           ` Burakov, Anatoly
2019-07-31  5:48             ` Yasufumi Ogawa
2019-10-11  9:36       ` David Marchand
2019-10-25 15:36         ` David Marchand
2019-10-25 19:54           ` Yasufumi Ogawa
2019-10-26 16:15             ` David Marchand
2019-10-26 18:11               ` Yasufumi Ogawa
2019-10-28  8:07     ` [dpdk-stable] [PATCH v5 0/1] fbarray: fix duplicated fbarray file in secondary yasufum.o
2019-10-28  8:07       ` [dpdk-stable] [PATCH v5 1/1] " yasufum.o
2019-10-29 12:03         ` [dpdk-stable] [dpdk-dev] " Ananyev, Konstantin
2019-10-30 13:42           ` Yasufumi Ogawa
2019-10-30 19:00             ` Ananyev, Konstantin
2019-10-31 10:03               ` Yasufumi Ogawa
2019-10-31 10:32                 ` Ananyev, Konstantin
2019-11-01  9:04     ` [dpdk-stable] [PATCH v6 0/1] " yasufum.o
2019-11-01  9:04       ` [dpdk-stable] [PATCH v6 1/1] " yasufum.o
2019-11-01 12:01         ` Ananyev, Konstantin
2019-11-04 10:20         ` Burakov, Anatoly
2019-11-05 10:13           ` David Marchand
2019-11-05 11:31             ` Burakov, Anatoly
2019-11-05 11:41               ` Ananyev, Konstantin
2019-11-06 10:37                 ` Burakov, Anatoly
2019-11-08  3:19                   ` Yasufumi Ogawa
2019-11-13 21:43     ` [dpdk-stable] [PATCH v7 0/1] " yasufum.o
2019-11-13 21:43       ` [dpdk-stable] [PATCH v7 1/1] " yasufum.o
2019-11-14 10:01         ` Burakov, Anatoly
2019-11-14 11:42           ` Yasufumi Ogawa
2019-11-14 12:27             ` David Marchand
2019-11-26 19:40               ` Yasufumi Ogawa
2019-11-27 10:26                 ` Burakov, Anatoly
2019-11-14 12:55         ` David Marchand
2019-11-14 17:32         ` Ananyev, Konstantin
2023-06-13 16:51 ` [dpdk-dev] [PATCH] fbarray: get fbarrays from containerized secondary Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).