Based on a patch from Andrey Kuzmin, but modified so that we error
out if the user has specified a specific memory backing type
through the use of mem= or iomem=.
Signed-off-by: Jens Axboe <axboe@fb.com>
#include <guasi.h>
#endif
#include <guasi.h>
#endif
-#define FIO_IOOPS_VERSION 22
+#define FIO_IOOPS_VERSION 23
enum {
IO_U_F_FREE = 1 << 0,
enum {
IO_U_F_FREE = 1 << 0,
int (*unlink_file)(struct thread_data *, struct fio_file *);
int (*get_file_size)(struct thread_data *, struct fio_file *);
void (*terminate)(struct thread_data *);
int (*unlink_file)(struct thread_data *, struct fio_file *);
int (*get_file_size)(struct thread_data *, struct fio_file *);
void (*terminate)(struct thread_data *);
+ int (*iomem_alloc)(struct thread_data *, size_t);
+ void (*iomem_free)(struct thread_data *);
int (*io_u_init)(struct thread_data *, struct io_u *);
void (*io_u_free)(struct thread_data *, struct io_u *);
int option_struct_size;
int (*io_u_init)(struct thread_data *, struct io_u *);
void (*io_u_free)(struct thread_data *, struct io_u *);
int option_struct_size;
dprint(FD_MEM, "Alloc %llu for buffers\n", (unsigned long long) total_mem);
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);
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);
if (td->o.odirect || td->o.oatomic)
total_mem += page_mask;
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);
free_mem_malloc(td);
else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
free_mem_shm(td);