Recent changes (master)
The following changes since commit fa6e7f4fb827adb124dbb97a7f72d64e76b2fe6a:
Merge branch 'master' of https://github.com/bvanassche/fio (2020-01-04 20:22:16 -0700)
are available in the Git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to dbab52955aeb0b58cc88c8eff1b1c2239241f0bd:
Merge branch 'memalign1' of https://github.com/kusumi/fio (2020-01-05 10:31:40 -0700)
----------------------------------------------------------------
Jens Axboe (1):
Merge branch 'memalign1' of https://github.com/kusumi/fio
Tomohiro Kusumi (1):
lib/memalign: remove smalloc()/sfree() dependency
fio.h | 12 ++++++++++++ lib/memalign.c | 15 ++++----------- lib/memalign.h | 7 +++++-- t/dedupe.c | 2 +- unittests/lib/memalign.c | 3 ++- unittests/unittest.c | 11 ----------- unittests/unittest.h | 4 ---- 7 files changed, 24 insertions(+), 30 deletions(-)
---
Diff of recent changes:
fio.h +12 -0
@@ -36,6 +36,8 @@#include "lib/rand.h" #include "lib/rbtree.h" #include "lib/num2str.h" +#include "lib/memalign.h" +#include "smalloc.h" #include "client.h" #include "server.h" #include "stat.h"
@@ -856,4 +858,14 @@ extern void check_trigger_file(void);extern bool in_flight_overlap (struct io_u_queue *q,struct io_u *io_u);extern pthread_mutex_t overlap_check; +static inline void *fio_memalign (size_t alignment,size_t size,bool shared) +{ +return __fio_memalign (alignment, size, shared ? smalloc : malloc); +} + +static inline void fio_memfree (void *ptr,size_t size,bool shared) +{ +return __fio_memfree (ptr, size, shared ? sfree : free); +} +#endif
lib/memalign.c +4 -11
@@ -11,18 +11,14 @@ struct align_footer {unsigned int offset; }; -void *fio_memalign (size_t alignment,size_t size,bool shared) +void *__fio_memalign (size_t alignment,size_t size,malloc_fn fn) {struct align_footer *f;void *ptr, *ret =NULL ;assert (!(alignment & (alignment -1 ))); -if (shared) - ptr =smalloc (size + alignment +sizeof (*f) -1 ); -else - ptr =malloc (size + alignment +sizeof (*f) -1 ); - + ptr =fn (size + alignment +sizeof (*f) -1 );if (ptr) { ret =PTR_ALIGN (ptr, alignment -1 ); f = ret + size;
@@ -32,12 +28,9 @@ void *fio_memalign(size_t alignment, size_t size, bool shared)return ret; } -void fio_memfree (void *ptr,size_t size,bool shared) +void __fio_memfree (void *ptr,size_t size,free_fn fn) {struct align_footer *f = ptr + size; -if (shared) -sfree (ptr - f->offset); -else -free (ptr - f->offset); +fn (ptr - f->offset); }
lib/memalign.h +5 -2
@@ -4,7 +4,10 @@#include <inttypes.h> #include <stdbool.h> -extern void *fio_memalign (size_t alignment,size_t size,bool shared); -extern void fio_memfree (void *ptr,size_t size,bool shared); +typedef void * (*malloc_fn )(size_t ); +typedef void (*free_fn )(void *); + +extern void *__fio_memalign (size_t alignment,size_t size,malloc_fn fn); +extern void __fio_memfree (void *ptr,size_t size,free_fn fn);#endif
t/dedupe.c +1 -1
@@ -10,13 +10,13 @@#include <unistd.h> #include <sys/stat.h> +#include "../fio.h" #include "../flist.h" #include "../log.h" #include "../fio_sem.h" #include "../smalloc.h" #include "../minmax.h" #include "../crc/md5.h" -#include "../lib/memalign.h" #include "../os/os.h" #include "../gettime.h" #include "../fio_time.h"
unittests/lib/memalign.c +2 -1
@@ -1,3 +1,4 @@ +#include <stdlib.h> #include "../unittest.h" #include "../../lib/memalign.h"
@@ -5,7 +6,7 @@static void test_memalign_1 (void ) {size_t align =4096 ; -void *p =fio_memalign (align,1234 , false); +void *p =__fio_memalign (align,1234 , malloc);if (p)CU_ASSERT_EQUAL (((int )(uintptr_t )p) & (align -1 ),0 );
unittests/unittest.c +0 -11
@@ -8,17 +8,6 @@#include "./unittest.h" -/* XXX workaround lib/memalign.c's dependency on smalloc.c */ -void *smalloc (size_t size) -{ -return malloc (size); -} - -void sfree (void *ptr) -{ -free (ptr); -} -CU_ErrorCode fio_unittest_add_suite (const char *name,CU_InitializeFunc initfn,CU_CleanupFunc cleanfn,struct fio_unittest_entry *tvec) {
unittests/unittest.h +0 -4
@@ -11,10 +11,6 @@ struct fio_unittest_entry {CU_TestFunc fn; }; -/* XXX workaround lib/memalign.c's dependency on smalloc.c */ -void *smalloc (size_t ); -void sfree (void *); -CU_ErrorCode fio_unittest_add_suite (const char *,CU_InitializeFunc ,CU_CleanupFunc ,struct fio_unittest_entry *);