gettime: get rid of the (unecessary) 10x scaling factor
[fio.git] / memory.c
index f81c2dd44aabaf937dd5db3b88c10a0cd6a992ca..50602239a41c85ede74e124c5e52ef7848ce0ee0 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -63,6 +63,7 @@ int fio_pin_memory(struct thread_data *td)
 
 static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem)
 {
+#ifndef CONFIG_NO_SHM
        int flags = IPC_CREAT | S_IRUSR | S_IWUSR;
 
        if (td->o.mem_type == MEM_SHMHUGE) {
@@ -104,15 +105,21 @@ static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem)
        }
 
        return 0;
+#else
+       log_err("fio: shm not supported\n");
+       return 1;
+#endif
 }
 
 static void free_mem_shm(struct thread_data *td)
 {
+#ifndef CONFIG_NO_SHM
        struct shmid_ds sbuf;
 
        dprint(FD_MEM, "shmdt/ctl %d %p\n", td->shm_id, td->orig_buffer);
        shmdt(td->orig_buffer);
        shmctl(td->shm_id, IPC_RMID, &sbuf);
+#endif
 }
 
 static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
@@ -139,12 +146,14 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
                        return 1;
                }
                if (td->o.mem_type != MEM_MMAPHUGE &&
+                   td->o.mem_type != MEM_MMAPSHARED &&
                    ftruncate(td->mmapfd, total_mem) < 0) {
                        td_verror(td, errno, "truncate mmap file");
                        td->orig_buffer = NULL;
                        return 1;
                }
-               if (td->o.mem_type == MEM_MMAPHUGE)
+               if (td->o.mem_type == MEM_MMAPHUGE ||
+                   td->o.mem_type == MEM_MMAPSHARED)
                        flags |= MAP_SHARED;
                else
                        flags |= MAP_PRIVATE;
@@ -224,7 +233,8 @@ int allocate_io_mem(struct thread_data *td)
                ret = alloc_mem_malloc(td, total_mem);
        else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
                ret = alloc_mem_shm(td, total_mem);
-       else if (td->o.mem_type == MEM_MMAP || td->o.mem_type == MEM_MMAPHUGE)
+       else if (td->o.mem_type == MEM_MMAP || td->o.mem_type == MEM_MMAPHUGE ||
+                td->o.mem_type == MEM_MMAPSHARED)
                ret = alloc_mem_mmap(td, total_mem);
        else {
                log_err("fio: bad mem type: %d\n", td->o.mem_type);
@@ -249,7 +259,8 @@ void free_io_mem(struct thread_data *td)
                free_mem_malloc(td);
        else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
                free_mem_shm(td);
-       else if (td->o.mem_type == MEM_MMAP || td->o.mem_type == MEM_MMAPHUGE)
+       else if (td->o.mem_type == MEM_MMAP || td->o.mem_type == MEM_MMAPHUGE ||
+                td->o.mem_type == MEM_MMAPSHARED)
                free_mem_mmap(td, total_mem);
        else
                log_err("Bad memory type %u\n", td->o.mem_type);