Skip to contentSkip to conversation

eal: create runtime dir even when shared data is not used

PATCH Superseded Bruce Richardson 5 participants 17 messages Jul 1, 2021 – Jul 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: create runtime dir even when shared data is not used

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
 lib/eal/linux/eal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/eal/linux/eal.c +2 -3
index ba19fc6347..1e05ba3847 100644
@@ -838,9 +838,8 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
+	/* create runtime data directory. In no_shconf mode, skip any errors */
+	if (eal_create_runtime_dir() < 0 && internal_conf->no_shconf == 0) {
 		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
 		ret = -1;
 		goto out;
Signature · 1 line
2.30.2
#1 lore raw
Quoted 35 lines

From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Thursday, 1 July 2021 11.35

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the
unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of
DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
 lib/eal/linux/eal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/eal/linux/eal.c +1 -3
index ba19fc6347..1e05ba3847 100644
@@ -838,9 +838,8 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
+	/* create runtime data directory. In no_shconf mode, skip any

errors */

lib/eal/linux/eal.c +1 -0
+	if (eal_create_runtime_dir() < 0 && internal_conf->no_shconf ==

0) {

lib/eal/linux/eal.c eal_parse_args(int argc, char **argv) · line 845

Quoted 3 lines
lib/eal/linux/eal.c +0 -0
 		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
 		ret = -1;
 		goto out;

When internal_conf->no_shconf == 1 and eal_create_runtime_dir() fails, DPDK will run without telemetry. Shouldn't it then be logged that telemetry is unavailable (and why it is unavailable)?

Quoted 3 lines

--
2.30.2

#2 lore raw
Quoted 28 lines · Morten Brørup
Quoted 28 lines

From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Thursday, 1 July 2021 11.35

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the
unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of
DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
 lib/eal/linux/eal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/eal/linux/eal.c +0 -0
index ba19fc6347..1e05ba3847 100644
@@ -838,9 +838,8 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
Quoted 13 lines

lib/eal/linux/eal.c eal_parse_args(int argc, char **argv) · line 845

Quoted 10 lines
lib/eal/linux/eal.c +1 -3
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
+	/* create runtime data directory. In no_shconf mode, skip any

errors */

lib/eal/linux/eal.c +1 -0
+	if (eal_create_runtime_dir() < 0 && internal_conf->no_shconf ==

0) {

lib/eal/linux/eal.c +0 -0
 		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
 		ret = -1;
 		goto out;

When internal_conf->no_shconf == 1 and eal_create_runtime_dir() fails, DPDK will run without telemetry. Shouldn't it then be logged that telemetry is unavailable (and why it is unavailable)?

There will be an error printed from the telemetry library about the socket creation failing. However, it probably could do with being improved. I'll see about creating a separate patch for that, since EAL should not be required to know about what other libs may need a runtime dir or not.

/Bruce

#3 lore raw

PATCH v2 1/2 eal: create runtime dir even when shared data is not used

In reply to Bruce Richardson

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
V2: add a warning for the no-shconf case, rather than skipping it silently.

 lib/eal/linux/eal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
lib/eal/linux/eal.c +8 -6
index ba19fc6347..ccb7535619 100644
@@ -838,12 +838,14 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-		ret = -1;
-		goto out;
+	/* create runtime data directory. In no_shconf mode, skip any errors */
+	if (eal_create_runtime_dir() < 0) {
+		if (internal_conf->no_shconf == 0) {
+			RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+			ret = -1;
+			goto out;
+		} else
+			RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n");
 	}
 
 	if (eal_adjust_config(internal_conf) != 0) {

--
2.30.2

#4 lore raw

PATCH v2 2/2 telemetry: add extra log message on socket bind failure

If the library fails to create the needed socket, add an additional check to report if the error is due to a missing DPDK runtime dir.

---
 lib/telemetry/telemetry.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/telemetry/telemetry.c +5 -0
index 6baba57ec2..8665db8d03 100644
@@ -7,6 +7,7 @@
 #include <pthread.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/stat.h>
 #include <dlfcn.h>
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
@@ -422,7 +423,11 @@ create_socket(char *path)
 	strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
 	unlink(sun.sun_path);
 	if (bind(sock, (void *) &sun, sizeof(sun)) < 0) {
+		struct stat st;
+
 		TMTY_LOG(ERR, "Error binding socket: %s\n", strerror(errno));
+		if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode))
+			TMTY_LOG(ERR, "Cannot access DPDK runtime directory: %s\n", socket_dir);
 		sun.sun_path[0] = 0;
 		goto error;
 	}

--
2.30.2

Acked-by on v2 2/2
#5 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] telemetry: add extra log message on socket bind failure

Quoted 38 lines

From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Friday, 2 July 2021 14.56

If the library fails to create the needed socket, add an additional check to report if the error is due to a missing DPDK runtime dir.

---
 lib/telemetry/telemetry.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/telemetry/telemetry.c +5 -0
index 6baba57ec2..8665db8d03 100644
@@ -7,6 +7,7 @@
 #include <pthread.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/stat.h>
 #include <dlfcn.h>
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
@@ -422,7 +423,11 @@ create_socket(char *path)
 	strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
 	unlink(sun.sun_path);
 	if (bind(sock, (void *) &sun, sizeof(sun)) < 0) {
+		struct stat st;
+
 		TMTY_LOG(ERR, "Error binding socket: %s\n",
 strerror(errno));
+		if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode))
+			TMTY_LOG(ERR, "Cannot access DPDK runtime directory:
 %s\n", socket_dir);
 		sun.sun_path[0] = 0;
lib/telemetry/telemetry.c +0 -1
 		goto error;
 	}
--
Quoted 2 lines

2.30.2

Acked-by
#6 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] telemetry: add extra log message on socket bind failure

Quoted 19 lines

-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Friday 2 July 2021 15:23
To: Richardson, Bruce <[email protected]>; [email protected]
Cc: Power, Ciara <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 2/2] telemetry: add extra log message on socket bind failure

Quoted 11 lines

From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Friday, 2 July 2021 14.56

If the library fails to create the needed socket, add an additional check to report if the error is due to a missing DPDK runtime dir.

---
 lib/telemetry/telemetry.c | 5 +++++
 1 file changed, 5 insertions(+)

<snip>

Quoted 2 lines
Quoted 1 line
Reviewed-by on v2 1/2
#8 lore raw
In reply to Bruce Richardson
Quoted 53 lines

From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Friday, 2 July 2021 14.56
To: [email protected]

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the
unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of
DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
V2: add a warning for the no-shconf case, rather than skipping it silently.

 lib/eal/linux/eal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
lib/eal/linux/eal.c +1 -6
index ba19fc6347..ccb7535619 100644
@@ -838,12 +838,14 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-		ret = -1;
-		goto out;
+	/* create runtime data directory. In no_shconf mode, skip any

errors */

lib/eal/linux/eal.c +3 -0
+	if (eal_create_runtime_dir() < 0) {
+		if (internal_conf->no_shconf == 0) {
+			RTE_LOG(ERR, EAL, "Cannot create runtime

directory\n");

lib/eal/linux/eal.c +4 -0
+			ret = -1;
+			goto out;
+		} else
+			RTE_LOG(WARNING, EAL, "No DPDK runtime directory

created\n");

lib/eal/linux/eal.c +0 -1
 	}
 
 	if (eal_adjust_config(internal_conf) != 0) {
--
Quoted 2 lines

2.30.2

Reviewed-by on v2 1/2
#9 lore raw
In reply to Bruce Richardson
Quoted 44 lines · Bruce Richardson

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
V2: add a warning for the no-shconf case, rather than skipping it silently.

 lib/eal/linux/eal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
lib/eal/linux/eal.c +8 -7
index ba19fc6347..ccb7535619 100644
@@ -838,12 +838,14 @@ eal_parse_args(int argc, char **argv)
                }
        }
 
-       /* create runtime data directory */
-       if (internal_conf->no_shconf == 0 &&
-                       eal_create_runtime_dir() < 0) {
-               RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-               ret = -1;
-               goto out;
+       /* create runtime data directory. In no_shconf mode, skip any errors */
+       if (eal_create_runtime_dir() < 0) {
+               if (internal_conf->no_shconf == 0) {
+                       RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+                       ret = -1;
+                       goto out;
+               } else
+                       RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n");
        }
 
        if (eal_adjust_config(internal_conf) != 0) {
--
Quoted 2 lines

2.30.2

Should this change be applied to FreeBSD too?

Signature · 1 line
David Marchand
#10 lore raw
Quoted 44 lines · David Marchand
Quoted 42 lines · Bruce Richardson

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
V2: add a warning for the no-shconf case, rather than skipping it silently.

 lib/eal/linux/eal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
lib/eal/linux/eal.c +8 -6
index ba19fc6347..ccb7535619 100644
@@ -838,12 +838,14 @@ eal_parse_args(int argc, char **argv)
                }
        }
 
-       /* create runtime data directory */
-       if (internal_conf->no_shconf == 0 &&
-                       eal_create_runtime_dir() < 0) {
-               RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-               ret = -1;
-               goto out;
+       /* create runtime data directory. In no_shconf mode, skip any errors */
+       if (eal_create_runtime_dir() < 0) {
+               if (internal_conf->no_shconf == 0) {
+                       RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+                       ret = -1;
+                       goto out;
+               } else
+                       RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n");
        }
 
Quoted 9 lines
Quoted 4 lines
lib/eal/linux/eal.c +0 -1
        if (eal_adjust_config(internal_conf) != 0) {
--

2.30.2

Should this change be applied to FreeBSD too?

Yes it should. :-( For some reason I assumed that this would not be relevant for FreeBSD, but I obviously should have double-checked the code!

#11 lore raw
Quoted 4 lines · Bruce Richardson
Quoted 2 lines

Should this change be applied to FreeBSD too?

Yes it should. :-( For some reason I assumed that this would not be relevant for FreeBSD, but I obviously should have double-checked the code!

Ok, how do you want to handle it?

Should I go with this revision and you send a followup patch for FreeBSD after rc1?
Or can you send a v2 this afternoon?

This series does not seem that risky, so we could wait for rc2 too.

Signature · 1 line
David Marchand
#12 lore raw
Quoted 7 lines · David Marchand
Quoted 4 lines · Bruce Richardson
Quoted 2 lines

Should this change be applied to FreeBSD too?

Yes it should. :-( For some reason I assumed that this would not be relevant for FreeBSD, but I obviously should have double-checked the code!

Quoted 8 lines

Ok, how do you want to handle it?

Should I go with this revision and you send a followup patch for FreeBSD after rc1?
Or can you send a v2 this afternoon?

This series does not seem that risky, so we could wait for rc2 too.

I'll send a v2 this afternoon.

Acked-by on v2 1/2
#13 lore raw
In reply to Bruce Richardson
Quoted 10 lines · Bruce Richardson

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

Quoted 2 lines

---

Quoted 11 lines

V2: add a warning for the no-shconf case, rather than skipping it silently.

 lib/eal/linux/eal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
lib/eal/linux/eal.c +0 -0
index ba19fc6347..ccb7535619 100644
@@ -838,12 +838,14 @@ eal_parse_args(int argc, char **argv)
 		}

lib/eal/linux/eal.c eal_parse_args(int argc, char **argv) · line 842

Quoted 10 lines
lib/eal/linux/eal.c +2 -6
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-		ret = -1;
-		goto out;
+	/* create runtime data directory. In no_shconf mode, skip any errors */
+	if (eal_create_runtime_dir() < 0) {

nit: suggest explicit comparison against -1 instead of < 0

Quoted 11 lines
lib/eal/linux/eal.c +6 -1
+		if (internal_conf->no_shconf == 0) {
+			RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+			ret = -1;
+			goto out;
+		} else
+			RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n");
 	}
 
 	if (eal_adjust_config(internal_conf) != 0) {
--

2.30.2

#14 lore raw

PATCH v3 1/2 eal: create runtime dir even when shared data is not used

In reply to Bruce Richardson

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

---
V3: added freebsd EAL changes.

---
 lib/eal/freebsd/eal.c | 14 ++++++++------
 lib/eal/linux/eal.c   | 14 ++++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)
lib/eal/freebsd/eal.c +8 -6
index f4d1676754..6cee5ae369 100644
@@ -575,12 +575,14 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-		ret = -1;
-		goto out;
+	/* create runtime data directory. In no_shconf mode, skip any errors */
+	if (eal_create_runtime_dir() < 0) {
+		if (internal_conf->no_shconf == 0) {
+			RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+			ret = -1;
+			goto out;
+		} else
+			RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n");
 	}
 
 	if (eal_adjust_config(internal_conf) != 0) {
lib/eal/linux/eal.c +8 -6
index ba19fc6347..3577eaeaa4 100644
@@ -838,12 +838,14 @@ eal_parse_args(int argc, char **argv)
 		}
 	}
 
-	/* create runtime data directory */
-	if (internal_conf->no_shconf == 0 &&
-			eal_create_runtime_dir() < 0) {
-		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
-		ret = -1;
-		goto out;
+	/* create runtime data directory. In no_shconf mode, skip any errors */
+	if (eal_create_runtime_dir() < 0) {
+		if (internal_conf->no_shconf == 0) {
+			RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+			ret = -1;
+			goto out;
+		} else
+			RTE_LOG(WARNING, EAL, "No DPDK runtime directory created\n");
 	}
 
 	if (eal_adjust_config(internal_conf) != 0) {
Signature · 1 line
2.30.2
#15 lore raw

PATCH v3 2/2 telemetry: add extra log message on socket bind failure

If the library fails to create the needed socket, add an additional check to report if the error is due to a missing DPDK runtime dir.

---
 lib/telemetry/telemetry.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/telemetry/telemetry.c +5 -0
index 6baba57ec2..8665db8d03 100644
@@ -7,6 +7,7 @@
 #include <pthread.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/stat.h>
 #include <dlfcn.h>
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
@@ -422,7 +423,11 @@ create_socket(char *path)
 	strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
 	unlink(sun.sun_path);
 	if (bind(sock, (void *) &sun, sizeof(sun)) < 0) {
+		struct stat st;
+
 		TMTY_LOG(ERR, "Error binding socket: %s\n", strerror(errno));
+		if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode))
+			TMTY_LOG(ERR, "Cannot access DPDK runtime directory: %s\n", socket_dir);
 		sun.sun_path[0] = 0;
 		goto error;
 	}
Signature · 1 line
2.30.2
#16 lore raw
In reply to Bruce Richardson
Quoted 11 lines · Bruce Richardson

When multi-process is not wanted and DPDK is run with the "no-shconf" flag, the telemetry library still needs a runtime directory to place the unix socket for telemetry connections. Therefore, rather than not creating the directory when this flag is set, we can change the code to attempt the creation anyway, but not error out if it fails. If it succeeds, then telemetry will be available, but if it fails, the rest of DPDK will run without telemetry. This ensures that the "in-memory" flag will allow DPDK to run even if the whole filesystem is read-only, for example.

Quoted 5 lines

---
V3: added freebsd EAL changes.

Series applied, thanks.

Signature · 1 line
David Marchand