diff mbox series

[v1,5/7] shm: use shm in /dev/shm instead of /tmp

Message ID 1499205607-30786-6-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/7] linux-gen: pktio: ipc fix send return code on tx | expand

Commit Message

Github ODP bot July 4, 2017, 10 p.m. UTC
From: Maxim Uvarov <maxim.uvarov@linaro.org>


/tmp might be mounted to tmpfs or not mounted. If it's
disk then some writes are loss there. At least ipc test
shows missing packets in shm ring on 4.10.0-rc8+ kernel.
Which is more likely kernel bug.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 67 (muvarov:master_ipc_fixes)
 ** https://github.com/Linaro/odp/pull/67
 ** Patch: https://github.com/Linaro/odp/pull/67.patch
 ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110
 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf
 **/
 platform/linux-generic/_fdserver.c |  2 +-
 platform/linux-generic/_ishm.c     | 18 ++++++++++--------
 platform/linux-generic/odp_init.c  |  2 +-
 3 files changed, 12 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c
index 9aed7a9f..20d6e233 100644
--- a/platform/linux-generic/_fdserver.c
+++ b/platform/linux-generic/_fdserver.c
@@ -58,7 +58,7 @@ 
 #include <sys/wait.h>
 
 #define FDSERVER_SOCKPATH_MAXLEN 32
-#define FDSERVER_SOCKPATH_FORMAT "/tmp/odp-%d-fdserver"
+#define FDSERVER_SOCKPATH_FORMAT "/dev/shm/odp-%d-fdserver"
 #define FDSERVER_BACKLOG 5
 
 #ifndef MAP_ANONYMOUS
diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c
index c1efd7d2..c0623f18 100644
--- a/platform/linux-generic/_ishm.c
+++ b/platform/linux-generic/_ishm.c
@@ -92,12 +92,13 @@ 
  * Linux underlying file name: <directory>/odp-<odp_pid>-ishm-<name>
  * The <name> part may be replaced by a sequence number if no specific
  * name is given at reserve time
- * <directory> is either /tmp or the hugepagefs mount point for default size.
+ * <directory> is either /dev/shm or the hugepagefs mount point for default
+ * size.
  * (searched at init time)
  */
 #define ISHM_FILENAME_MAXLEN (ISHM_NAME_MAXLEN + 64)
 #define ISHM_FILENAME_FORMAT "%s/odp-%d-ishm-%s"
-#define ISHM_FILENAME_NORMAL_PAGE_DIR "/tmp"
+#define ISHM_FILENAME_NORMAL_PAGE_DIR "/dev/shm"
 
 /*
  * when the memory is to be shared with an external entity (such as another
@@ -105,7 +106,7 @@ 
  * export file is created describing the exported memory: this defines the
  * location and the filename format of this description file
  */
-#define ISHM_EXPTNAME_FORMAT "/tmp/odp-%d-shm-%s"
+#define ISHM_EXPTNAME_FORMAT "/dev/shm/odp-%d-shm-%s"
 
 /*
  * At worse case the virtual space gets so fragmented that there is
@@ -117,7 +118,7 @@ 
 
 /*
  * when a memory block is to be exported outside its ODP instance,
- * an block 'attribute file' is created in /tmp/odp-<pid>-shm-<name>.
+ * an block 'attribute file' is created in /dev/shm/odp-<pid>-shm-<name>.
  * The information given in this file is according to the following:
  */
 #define EXPORT_FILE_LINE1_FMT "ODP exported shm block info:"
@@ -401,7 +402,7 @@  static void free_fragment(ishm_fragment_t *fragmnt)
 
 /*
  * Create file with size len. returns -1 on error
- * Creates a file to /tmp/odp-<pid>-<sequence_or_name> (for normal pages)
+ * Creates a file to /dev/shm/odp-<pid>-<sequence_or_name> (for normal pages)
  * or /mnt/huge/odp-<pid>-<sequence_or_name> (for huge pages)
  * Return the new file descriptor, or -1 on error.
  */
@@ -412,7 +413,8 @@  static int create_file(int block_index, huge_flag_t huge, uint64_t len,
 	int  fd;
 	ishm_block_t *new_block;	  /* entry in the main block table    */
 	char seq_string[ISHM_FILENAME_MAXLEN];   /* used to construct filename*/
-	char filename[ISHM_FILENAME_MAXLEN];/* filename in /tmp/ or /mnt/huge */
+	char filename[ISHM_FILENAME_MAXLEN]; /* filename in /dev/shm or
+					      *		    /mnt/huge */
 	int  oflag = O_RDWR | O_CREAT | O_TRUNC; /* flags for open	      */
 	FILE *export_file;
 
@@ -530,7 +532,7 @@  static void *do_map(int block_index, uint64_t len, uint32_t align,
 	new_block = &ishm_tbl->block[block_index];
 
 	/*
-	 * Creates a file to /tmp/odp-<pid>-<sequence> (for normal pages)
+	 * Creates a file to /dev/shm/odp-<pid>-<sequence> (for normal pages)
 	 * or /mnt/huge/odp-<pid>-<sequence> (for huge pages)
 	 * unless a fd was already given
 	 */
@@ -761,7 +763,7 @@  static void procsync(void)
  * If ok, allocate a new shared memory block and map the
  * provided fd in it (if fd >=0 was given).
  * If no fd is provided, a shared memory file desc named
- * /tmp/odp-<pid>-ishm-<name_or_sequence> is created and mapped.
+ * /dev/shm/odp-<pid>-ishm-<name_or_sequence> is created and mapped.
  * (the name is different for huge page file as they must be on hugepagefs)
  * The function returns the index of the newly created block in the
  * main block table (>=0) or -1 on error.
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 06c61435..b4abb181 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -19,7 +19,7 @@ 
 #include <errno.h>
 
 #define _ODP_FILES_FMT "odp-%d-"
-#define _ODP_TMPDIR    "/tmp"
+#define _ODP_TMPDIR    "/dev/shm"
 
 struct odp_global_data_s odp_global_data;