X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=memory.c;h=af4d5ef8ee371701f02806369a3581ecfdc42628;hp=50602239a41c85ede74e124c5e52ef7848ce0ee0;hb=5e62565b99c2d133e71cf7eed8586307452ad225;hpb=f672ef67527a27eb2bbc59aa6041a42d88a00838 diff --git a/memory.c b/memory.c index 50602239..af4d5ef8 100644 --- a/memory.c +++ b/memory.c @@ -89,7 +89,7 @@ static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem) " support huge pages.\n"); } else if (errno == ENOMEM) { log_err("fio: no huge pages available, do you" - " need to alocate some? See HOWTO.\n"); + " need to allocate some? See HOWTO.\n"); } } @@ -229,7 +229,17 @@ int allocate_io_mem(struct thread_data *td) dprint(FD_MEM, "Alloc %llu for buffers\n", (unsigned long long) total_mem); - if (td->o.mem_type == MEM_MALLOC) + /* + * If the IO engine has hooks to allocate/free memory, use those. But + * error out if the user explicitly asked for something else. + */ + if (td->io_ops->iomem_alloc) { + if (fio_option_is_set(&td->o, mem_type)) { + log_err("fio: option 'mem/iomem' conflicts with specified IO engine\n"); + ret = 1; + } else + ret = td->io_ops->iomem_alloc(td, total_mem); + } else 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) ret = alloc_mem_shm(td, total_mem); @@ -255,7 +265,10 @@ void free_io_mem(struct thread_data *td) if (td->o.odirect || td->o.oatomic) total_mem += page_mask; - if (td->o.mem_type == MEM_MALLOC) + if (td->io_ops->iomem_alloc) { + if (td->io_ops->iomem_free) + td->io_ops->iomem_free(td); + } else if (td->o.mem_type == MEM_MALLOC) free_mem_malloc(td); else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE) free_mem_shm(td);