if (td->io_ops->io_u_free)
td->io_ops->io_u_free(td, io_u);
- fio_memfree(io_u, sizeof(*io_u));
+ fio_memfree(io_u, sizeof(*io_u), td_offload_overlap(td));
}
free_io_mem(td);
io_u_rexit(&td->io_u_requeues);
- io_u_qexit(&td->io_u_freelist);
- io_u_qexit(&td->io_u_all);
+ io_u_qexit(&td->io_u_freelist, false);
+ io_u_qexit(&td->io_u_all, td_offload_overlap(td));
free_file_completion_logging(td);
}
err = 0;
err += !io_u_rinit(&td->io_u_requeues, td->o.iodepth);
- err += !io_u_qinit(&td->io_u_freelist, td->o.iodepth);
- err += !io_u_qinit(&td->io_u_all, td->o.iodepth);
+ err += !io_u_qinit(&td->io_u_freelist, td->o.iodepth, false);
+ err += !io_u_qinit(&td->io_u_all, td->o.iodepth, td_offload_overlap(td));
if (err) {
log_err("fio: failed setting up IO queues\n");
if (td->terminate)
return 1;
- ptr = fio_memalign(cl_align, sizeof(*io_u));
+ ptr = fio_memalign(cl_align, sizeof(*io_u), td_offload_overlap(td));
if (!ptr) {
log_err("fio: unable to allocate aligned memory\n");
break;
#include <stdlib.h>
+#include <string.h>
#include "io_u_queue.h"
+#include "smalloc.h"
-bool io_u_qinit(struct io_u_queue *q, unsigned int nr)
+bool io_u_qinit(struct io_u_queue *q, unsigned int nr, bool shared)
{
- q->io_us = calloc(nr, sizeof(struct io_u *));
+ if (shared)
+ q->io_us = smalloc(nr * sizeof(struct io_u *));
+ else
+ q->io_us = calloc(nr, sizeof(struct io_u *));
+
if (!q->io_us)
return false;
return true;
}
-void io_u_qexit(struct io_u_queue *q)
+void io_u_qexit(struct io_u_queue *q, bool shared)
{
- free(q->io_us);
+ if (shared)
+ sfree(q->io_us);
+ else
+ free(q->io_us);
}
bool io_u_rinit(struct io_u_ring *ring, unsigned int nr)
#define io_u_qiter(q, io_u, i) \
for (i = 0; i < (q)->nr && (io_u = (q)->io_us[i]); i++)
-bool io_u_qinit(struct io_u_queue *q, unsigned int nr);
-void io_u_qexit(struct io_u_queue *q);
+bool io_u_qinit(struct io_u_queue *q, unsigned int nr, bool shared);
+void io_u_qexit(struct io_u_queue *q, bool shared);
struct io_u_ring {
unsigned int head;
#include <stdlib.h>
#include "memalign.h"
+#include "smalloc.h"
#define PTR_ALIGN(ptr, mask) \
(char *)((uintptr_t)((ptr) + (mask)) & ~(mask))
unsigned int offset;
};
-void *fio_memalign(size_t alignment, size_t size)
+void *fio_memalign(size_t alignment, size_t size, bool shared)
{
struct align_footer *f;
void *ptr, *ret = NULL;
assert(!(alignment & (alignment - 1)));
- ptr = malloc(size + alignment + sizeof(*f) - 1);
+ if (shared)
+ ptr = smalloc(size + alignment + sizeof(*f) - 1);
+ else
+ ptr = malloc(size + alignment + sizeof(*f) - 1);
+
if (ptr) {
ret = PTR_ALIGN(ptr, alignment - 1);
f = ret + size;
return ret;
}
-void fio_memfree(void *ptr, size_t size)
+void fio_memfree(void *ptr, size_t size, bool shared)
{
struct align_footer *f = ptr + size;
- free(ptr - f->offset);
+ if (shared)
+ sfree(ptr - f->offset);
+ else
+ free(ptr - f->offset);
}
#define FIO_MEMALIGN_H
#include <inttypes.h>
+#include <stdbool.h>
-extern void *fio_memalign(size_t alignment, size_t size);
-extern void fio_memfree(void *ptr, size_t size);
+extern void *fio_memalign(size_t alignment, size_t size, bool shared);
+extern void fio_memfree(void *ptr, size_t size, bool shared);
#endif
char *cbuf, *ibuf;
int ret = 1;
- cbuf = fio_memalign(blocksize, blocksize);
- ibuf = fio_memalign(blocksize, blocksize);
+ cbuf = fio_memalign(blocksize, blocksize, false);
+ ibuf = fio_memalign(blocksize, blocksize, false);
e = flist_entry(c->extent_list[0].next, struct extent, list);
if (read_block(file.fd, cbuf, e->offset))
ret = memcmp(ibuf, cbuf, blocksize);
out:
- fio_memfree(cbuf, blocksize);
- fio_memfree(ibuf, blocksize);
+ fio_memfree(cbuf, blocksize, false);
+ fio_memfree(ibuf, blocksize, false);
return ret;
}
struct worker_thread *thread = data;
void *buf;
- buf = fio_memalign(blocksize, chunk_size);
+ buf = fio_memalign(blocksize, chunk_size, false);
do {
if (get_work(&thread->cur_offset, &thread->size)) {
} while (1);
thread->done = 1;
- fio_memfree(buf, chunk_size);
+ fio_memfree(buf, chunk_size, false);
return NULL;
}