[PATCH] Fix hugetlb problems
authorJens Axboe <jens.axboe@oracle.com>
Wed, 20 Dec 2006 11:48:23 +0000 (12:48 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 20 Dec 2006 11:48:23 +0000 (12:48 +0100)
Alignment was bad, and we need to check the shmhuge string before shm,
otherwise it'll match the latter.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c
init.c
memory.c
os.h

diff --git a/fio.c b/fio.c
index 87136141b0e34770851dbab53a942d9774eb6f48..41b602020b9c93a68a13a0b02bbcf945102f3dcc 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -510,7 +510,7 @@ static int init_io_u(struct thread_data *td)
        td->orig_buffer_size = max_bs * max_units;
 
        if (td->mem_type == MEM_SHMHUGE)
-               td->orig_buffer_size = (td->orig_buffer_size + FIO_HUGE_PAGE - 1) & ~FIO_HUGE_PAGE;
+               td->orig_buffer_size = (td->orig_buffer_size + FIO_HUGE_PAGE - 1) & ~(FIO_HUGE_PAGE - 1);
        else
                td->orig_buffer_size += MASK;
 
diff --git a/init.c b/init.c
index bfe698106b3bf02fe529990c19aa204267ef273b..7d7c9d63f40b3c5e54d1408accda38c328e24d72 100644 (file)
--- a/init.c
+++ b/init.c
@@ -827,9 +827,6 @@ static int str_mem_cb(void *data, const char *mem)
        if (!strncmp(mem, "malloc", 6)) {
                td->mem_type = MEM_MALLOC;
                return 0;
-       } else if (!strncmp(mem, "shm", 3)) {
-               td->mem_type = MEM_SHM;
-               return 0;
        } else if (!strncmp(mem, "mmap", 4)) {
                td->mem_type = MEM_MMAP;
                return 0;
@@ -841,6 +838,9 @@ static int str_mem_cb(void *data, const char *mem)
                log_err("fio: shmhuge not available\n");
                return 1;
 #endif
+       } else if (!strncmp(mem, "shm", 3)) {
+               td->mem_type = MEM_SHM;
+               return 0;
        }
 
        log_err("fio: mem type: malloc, shm, mmap, shmhuge\n");
index a7bf82a88fbafd276be899e769e29348c1682757..d336c2bcb8cea017b6d9db980e3c39a95d70c717 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -98,7 +98,7 @@ void free_io_mem(struct thread_data *td)
 {
        if (td->mem_type == MEM_MALLOC)
                free(td->orig_buffer);
-       else if (td->mem_type == MEM_SHM) {
+       else if (td->mem_type == MEM_SHM || td->mem_type == MEM_SHMHUGE) {
                struct shmid_ds sbuf;
 
                shmdt(td->orig_buffer);
diff --git a/os.h b/os.h
index b5f43e593e6251efb179dc2dd22ca1ecdb59e3e3..a2699dd2d0b14e69c5091e412bf20a2dab32045f 100644 (file)
--- a/os.h
+++ b/os.h
@@ -51,7 +51,7 @@
 #define SHM_HUGETLB                    0
 #define FIO_HUGE_PAGE                  0
 #else
-#define FIO_HUGE_PAGE                  (2048 * 1024)
+#define FIO_HUGE_PAGE                  (4096 * 1024)
 #endif
 
 #endif