support systemd service convention for runtime directory
[dpdk.git] / lib / eal / linux / eal.c
index 81fdebc..e9764f6 100644 (file)
@@ -86,25 +86,28 @@ struct lcore_config lcore_config[RTE_MAX_LCORE];
 /* used by rte_rdtsc() */
 int rte_cycles_vmware_tsc_map;
 
-static const char *default_runtime_dir = "/var/run";
-
 int
 eal_create_runtime_dir(void)
 {
-       const char *directory = default_runtime_dir;
-       const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
-       const char *fallback = "/tmp";
+       const char *directory;
        char run_dir[PATH_MAX];
        char tmp[PATH_MAX];
        int ret;
 
-       if (getuid() != 0) {
-               /* try XDG path first, fall back to /tmp */
-               if (xdg_runtime_dir != NULL)
-                       directory = xdg_runtime_dir;
+       /* from RuntimeDirectory= see systemd.exec */
+       directory = getenv("RUNTIME_DIRECTORY");
+       if (directory == NULL) {
+               /*
+                * Used standard convention defined in
+                * XDG Base Directory Specification and
+                * Filesystem Hierarchy Standard.
+                */
+               if (getuid() == 0)
+                       directory = "/var/run";
                else
-                       directory = fallback;
+                       directory = getenv("XDG_RUNTIME_DIR") ? : "/tmp";
        }
+
        /* create DPDK subdirectory under runtime dir */
        ret = snprintf(tmp, sizeof(tmp), "%s/dpdk", directory);
        if (ret < 0 || ret == sizeof(tmp)) {
@@ -137,7 +140,7 @@ eal_create_runtime_dir(void)
                return -1;
        }
 
-       if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
+       if (eal_set_runtime_dir(run_dir))
                return -1;
 
        return 0;
@@ -562,7 +565,6 @@ eal_parse_socket_arg(char *strval, volatile uint64_t *socket_arg)
        char * arg[RTE_MAX_NUMA_NODES];
        char *end;
        int arg_num, i, len;
-       uint64_t total_mem = 0;
 
        len = strnlen(strval, SOCKET_MEM_STRLEN);
        if (len == SOCKET_MEM_STRLEN) {
@@ -594,7 +596,6 @@ eal_parse_socket_arg(char *strval, volatile uint64_t *socket_arg)
                                (arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
                        return -1;
                val <<= 20;
-               total_mem += val;
                socket_arg[i] = val;
        }
 
@@ -1362,7 +1363,8 @@ rte_eal_cleanup(void)
        struct internal_config *internal_conf =
                eal_get_internal_configuration();
 
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
+                       internal_conf->hugepage_file.unlink_existing)
                rte_memseg_walk(mark_freeable, NULL);
        rte_service_finalize();
        rte_mp_channel_cleanup();