X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=memory.c;h=0135abb1b0eb42d574eed3fe646a69908de12983;hp=39fb9f237bb6fcb3d2a378997ed6debe71e2f236;hb=83ea422a62b8a42b14c362db61c2e7bf53862e80;hpb=03e20d687566753b90383571e5e152c5142bdffd diff --git a/memory.c b/memory.c index 39fb9f23..0135abb1 100644 --- a/memory.c +++ b/memory.c @@ -115,14 +115,14 @@ static void free_mem_shm(struct thread_data *td) shmctl(td->shm_id, IPC_RMID, &sbuf); } -static int alloc_mem_mmap(struct thread_data *td, unsigned int total_mem) +static int alloc_mem_mmap(struct thread_data *td, size_t total_mem) { int flags = MAP_PRIVATE; td->mmapfd = 1; - if (td->mmapfile) { - td->mmapfd = open(td->mmapfile, O_RDWR|O_CREAT, 0644); + if (td->o.mmapfile) { + td->mmapfd = open(td->o.mmapfile, O_RDWR|O_CREAT, 0644); if (td->mmapfd < 0) { td_verror(td, errno, "open mmap file"); @@ -146,7 +146,7 @@ static int alloc_mem_mmap(struct thread_data *td, unsigned int total_mem) td->orig_buffer = NULL; if (td->mmapfd) { close(td->mmapfd); - unlink(td->mmapfile); + unlink(td->o.mmapfile); } return 1; @@ -155,18 +155,18 @@ static int alloc_mem_mmap(struct thread_data *td, unsigned int total_mem) return 0; } -static void free_mem_mmap(struct thread_data *td, unsigned int total_mem) +static void free_mem_mmap(struct thread_data *td, size_t total_mem) { dprint(FD_MEM, "munmap %u %p\n", total_mem, td->orig_buffer); munmap(td->orig_buffer, td->orig_buffer_size); - if (td->mmapfile) { + if (td->o.mmapfile) { close(td->mmapfd); - unlink(td->mmapfile); - free(td->mmapfile); + unlink(td->o.mmapfile); + free(td->o.mmapfile); } } -static int alloc_mem_malloc(struct thread_data *td, unsigned int total_mem) +static int alloc_mem_malloc(struct thread_data *td, size_t total_mem) { td->orig_buffer = malloc(total_mem); dprint(FD_MEM, "malloc %u %p\n", total_mem, td->orig_buffer); @@ -185,7 +185,7 @@ static void free_mem_malloc(struct thread_data *td) */ int allocate_io_mem(struct thread_data *td) { - unsigned int total_mem; + size_t total_mem; int ret = 0; if (td->io_ops->flags & FIO_NOIO) @@ -200,6 +200,8 @@ int allocate_io_mem(struct thread_data *td) total_mem += td->o.mem_align - page_size; } + dprint(FD_MEM, "Alloc %lu for buffers\n", (size_t) total_mem); + if (td->o.mem_type == MEM_MALLOC) ret = alloc_mem_malloc(td, total_mem); else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)