From: Jens Axboe Date: Mon, 21 Jan 2013 17:55:02 +0000 (-0700) Subject: Add generic hweight helpers X-Git-Tag: fio-2.0.14~110 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=51aa2da8cf422a06ddfa1ce673f3bfc03f96b86e Add generic hweight helpers Signed-off-by: Jens Axboe --- diff --git a/Makefile b/Makefile index 03e46fa4..967996d7 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \ engines/mmap.c engines/sync.c engines/null.c engines/net.c \ memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \ json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \ - helpers.c lib/flist_sort.c + helpers.c lib/flist_sort.c lib/hweight.c ifdef CONFIG_64BIT_LLP64 CFLAGS += -DBITS_PER_LONG=32 diff --git a/lib/hweight.c b/lib/hweight.c new file mode 100644 index 00000000..738ed277 --- /dev/null +++ b/lib/hweight.c @@ -0,0 +1,19 @@ +#include "hweight.h" + +unsigned int hweight8(uint8_t w) +{ + unsigned int res = w - ((w >> 1) & 0x55); + + res = (res & 0x33) + ((res >> 2) & 0x33); + return (res + (res >> 4)) & 0x0F; +} + +unsigned int hweight32(uint32_t w) +{ + unsigned int res = w - ((w >> 1) & 0x55555555); + + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res + (res >> 4)) & 0x0F0F0F0F; + res = res + (res >> 8); + return (res + (res >> 16)) & 0x000000FF; +} diff --git a/lib/hweight.h b/lib/hweight.h new file mode 100644 index 00000000..1965eaa6 --- /dev/null +++ b/lib/hweight.h @@ -0,0 +1,9 @@ +#ifndef FIO_HWEIGHT_H +#define FIO_HWEIGHT_H + +#include + +unsigned int hweight8(uint8_t w); +unsigned int hweight32(uint32_t w); + +#endif diff --git a/options.c b/options.c index 8d460be2..2b71abdd 100644 --- a/options.c +++ b/options.c @@ -1961,6 +1961,11 @@ static struct fio_option options[FIO_MAX_OPTS] = { .parent = "verify_async", }, #endif + { + .name = "experimental_verify", + .off1 = td_var_offset(experimental_verify), + .type = FIO_OPT_BOOL, + }, #ifdef FIO_HAVE_TRIM { .name = "trim_percentage", diff --git a/verify.c b/verify.c index c0485d55..cb13b629 100644 --- a/verify.c +++ b/verify.c @@ -13,6 +13,7 @@ #include "smalloc.h" #include "trim.h" #include "lib/rand.h" +#include "lib/hweight.h" #include "crc/md5.h" #include "crc/crc64.h" @@ -308,14 +309,6 @@ static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc) return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(hdr); } -static unsigned int hweight8(unsigned int w) -{ - unsigned int res = w - ((w >> 1) & 0x55); - - res = (res & 0x33) + ((res >> 2) & 0x33); - return (res + (res >> 4)) & 0x0F; -} - static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc) { struct thread_data *td = vc->td;