Merge branch 'master' of ssh://brick.kernel.dk/data/git/fio
authorJens Axboe <jens.axboe@oracle.com>
Thu, 30 Apr 2009 06:07:43 +0000 (08:07 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 30 Apr 2009 06:07:43 +0000 (08:07 +0200)
HOWTO
fio.c
os/os-linux.h
os/os.h

diff --git a/HOWTO b/HOWTO
index 15f576d28fa2ff16038c6249d41da6d2f4d64357..f4f596a4c02e7880a0394f809a1f24aae05a6737 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -935,7 +935,7 @@ I           Thread initialized, waiting.
        M       Running, doing mixed sequential reads/writes.
        m       Running, doing mixed random reads/writes.
        F       Running, currently waiting for fsync()
-V              Running, doing verification of written data.
+       V       Running, doing verification of written data.
 E              Thread exited, not reaped by main thread yet.
 _              Thread reaped.
 
diff --git a/fio.c b/fio.c
index ff77c91bb77f8968b4cf0807635b53256c504e0f..f0665e072ccbd5f6ac3f4dcd52a5edfe015cbf31 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -733,7 +733,7 @@ static int init_io_u(struct thread_data *td)
 {
        struct io_u *io_u;
        unsigned int max_bs;
-       int i, max_units;
+       int cl_align, i, max_units;
        char *p;
 
        max_units = td->o.iodepth;
@@ -761,10 +761,20 @@ static int init_io_u(struct thread_data *td)
        else
                p = td->orig_buffer;
 
+       cl_align = os_cache_line_size();
+
        for (i = 0; i < max_units; i++) {
+               void *ptr;
+
                if (td->terminate)
                        return 1;
-               io_u = malloc(sizeof(*io_u));
+
+               if (posix_memalign(&ptr, cl_align, sizeof(*io_u))) {
+                       log_err("fio: posix_memalign=%s\n", strerror(errno));
+                       break;
+               }
+
+               io_u = ptr;
                memset(io_u, 0, sizeof(*io_u));
                INIT_FLIST_HEAD(&io_u->list);
 
index 4460653fae44d0e8182239ac69105dbda2dd49c2..1cd8272d5241750c67107536b2a0a1268236e7c0 100644 (file)
@@ -30,6 +30,7 @@
 #define FIO_HAVE_FALLOCATE
 #define FIO_HAVE_POSIXAIO_FSYNC
 #define FIO_HAVE_PSHARED_MUTEX
+#define FIO_HAVE_CL_SIZE
 
 #define OS_MAP_ANON            MAP_ANONYMOUS
 
@@ -249,4 +250,23 @@ static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
 #define FIO_O_NOATIME  0
 #endif
 
+#define CACHE_LINE_FILE        \
+       "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"
+
+static inline int arch_cache_line_size(void)
+{
+       char size[32];
+       int fd, ret;
+
+       fd = open(CACHE_LINE_FILE, O_RDONLY);
+       if (fd < 0)
+               return -1;
+
+       ret = read(fd, size, sizeof(size));
+       if (ret <= 0)
+               return -1;
+
+       return atoi(size);
+}
+
 #endif
diff --git a/os/os.h b/os/os.h
index 5a3bc559186a2c076635a91c6cf85c72a9b80211..dbf095711c08344e054966512dae3f41d8c75280 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -90,4 +90,20 @@ static inline int load_blktrace(struct thread_data *td, const char *fname)
 }
 #endif
 
+#define FIO_DEF_CL_SIZE                128
+
+static inline int os_cache_line_size(void)
+{
+#ifdef FIO_HAVE_CL_SIZE
+       int ret = arch_cache_line_size();
+
+       if (ret <= 0)
+               return FIO_DEF_CL_SIZE;
+
+       return ret;
+#else
+       return FIO_DEF_CL_SIZE;
+#endif
+}
+
 #endif