summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVincent Fu <vincent.fu@wdc.com>2018-10-17 12:03:23 -0400
committerJens Axboe <axboe@kernel.dk>2018-10-19 11:09:17 -0600
commit3114b675fd2b77ffa0f485b466811feb34dc57ed (patch)
tree75f55f54c2b399eae5c1b25c83e8f3fbce908efb /lib
parent1368d95b060802f3032bb662144faa99bd521b56 (diff)
downloadfio-3114b675fd2b77ffa0f485b466811feb34dc57ed.tar.gz
fio-3114b675fd2b77ffa0f485b466811feb34dc57ed.tar.bz2
fio: enable cross-thread overlap checking with processes
Overlap checking with io_submit_mode=offload requires relevant jobs to access each other's io_u's and io_u_all members. This patch modifies the fio_memalign and io_u_queue helpers to include an indicator signifying whether operations should use the shared memory pool. When fio is carrying out cross-job overlap checking in offload submission mode, these variables will be allocated from shared memory so that processes can be used and threads will no longer be required. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'lib')
-rw-r--r--lib/memalign.c16
-rw-r--r--lib/memalign.h5
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/memalign.c b/lib/memalign.c
index e774c19c..537bb9fb 100644
--- a/lib/memalign.c
+++ b/lib/memalign.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include "memalign.h"
+#include "smalloc.h"
#define PTR_ALIGN(ptr, mask) \
(char *)((uintptr_t)((ptr) + (mask)) & ~(mask))
@@ -10,14 +11,18 @@ struct align_footer {
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;
@@ -27,9 +32,12 @@ void *fio_memalign(size_t alignment, size_t 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);
}
diff --git a/lib/memalign.h b/lib/memalign.h
index c2eb1702..d7030870 100644
--- a/lib/memalign.h
+++ b/lib/memalign.h
@@ -2,8 +2,9 @@
#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