[PATCH] Add hugepage-size option
authorJens Axboe <jens.axboe@oracle.com>
Wed, 20 Dec 2006 19:27:36 +0000 (20:27 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 20 Dec 2006 19:27:36 +0000 (20:27 +0100)
We default to 4MiB, but export the setting so it can be changed.

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

diff --git a/HOWTO b/HOWTO
index 996da23a1ce998665d1f9af7d65faaf064eced64..3b270b1d723460110607b1c2b455d61f35164d06 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -378,12 +378,16 @@ mem=str           Fio can use various types of memory as the io unit buffer.
                divide that number by the huge page size. You can see the
                size of the huge pages in /proc/meminfo. If no huge pages
                are allocated by having a non-zero number in nr_hugepages,
                divide that number by the huge page size. You can see the
                size of the huge pages in /proc/meminfo. If no huge pages
                are allocated by having a non-zero number in nr_hugepages,
-               using mmaphuge or shmhuge will fail.
+               using mmaphuge or shmhuge will fail. Also see hugepage-size.
 
                mmaphuge also needs to have hugetlbfs mounted and the file
                location should point there. So if it's mounted in /huge,
                you would use mem=mmaphuge:/huge/somefile.
 
 
                mmaphuge also needs to have hugetlbfs mounted and the file
                location should point there. So if it's mounted in /huge,
                you would use mem=mmaphuge:/huge/somefile.
 
+hugepage-size=siint
+               Defines the size of a huge page. Must at least be equal
+               to the system setting, see /proc/meminfo. Defaults to 4MiB.
+
 exitall                When one job finishes, terminate the rest. The default is
                to wait for each job to finish, sometimes that is not the
                desired action.
 exitall                When one job finishes, terminate the rest. The default is
                to wait for each job to finish, sometimes that is not the
                desired action.
diff --git a/fio.c b/fio.c
index 8a4a44dc902f0f0dde0695deceaefb1dbab9ae4a..f046b0cd61e88d0571cedd63f03c681f16024083 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->mem_type == MEM_MMAPHUGE)
        td->orig_buffer_size = max_bs * max_units;
 
        if (td->mem_type == MEM_SHMHUGE || td->mem_type == MEM_MMAPHUGE)
-               td->orig_buffer_size = (td->orig_buffer_size + FIO_HUGE_PAGE - 1) & ~(FIO_HUGE_PAGE - 1);
+               td->orig_buffer_size = (td->orig_buffer_size + td->hugepage_size - 1) & ~(td->hugepage_size - 1);
        else
                td->orig_buffer_size += MASK;
 
        else
                td->orig_buffer_size += MASK;
 
diff --git a/fio.h b/fio.h
index 432c098863978840779dc280e146b74109da8b47..df36f14e6e895d74d8712e7cdd77ca7f842f304c 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -214,6 +214,7 @@ struct thread_data {
        unsigned int bs[2];
        unsigned int min_bs[2];
        unsigned int max_bs[2];
        unsigned int bs[2];
        unsigned int min_bs[2];
        unsigned int max_bs[2];
+       unsigned int hugepage_size;
        unsigned int rw_min_bs;
        unsigned int thinktime;
        unsigned int fsync_blocks;
        unsigned int rw_min_bs;
        unsigned int thinktime;
        unsigned int fsync_blocks;
diff --git a/init.c b/init.c
index edaec144f3aaaa5895339df4f2a703bdff7d9c48..4ca5ee6f8f9e41df678ad56a0569187775eed47f 100644 (file)
--- a/init.c
+++ b/init.c
@@ -52,6 +52,7 @@
 #define DEF_WRITE_BW_LOG       (0)
 #define DEF_WRITE_LAT_LOG      (0)
 #define DEF_NO_RAND_MAP                (0)
 #define DEF_WRITE_BW_LOG       (0)
 #define DEF_WRITE_LAT_LOG      (0)
 #define DEF_NO_RAND_MAP                (0)
+#define DEF_HUGEPAGE_SIZE      FIO_HUGE_PAGE
 
 #define td_var_offset(var)     ((size_t) &((struct thread_data *)0)->var)
 
 
 #define td_var_offset(var)     ((size_t) &((struct thread_data *)0)->var)
 
@@ -358,6 +359,11 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_STR_SET,
                .off1   = td_var_offset(bs_unaligned),
        },
                .type   = FIO_OPT_STR_SET,
                .off1   = td_var_offset(bs_unaligned),
        },
+       {
+               .name   = "hugepage-size",
+               .type   = FIO_OPT_STR_VAL,
+               .off1   = td_var_offset(hugepage_size),
+       },
        {
                .name = NULL,
        },
        {
                .name = NULL,
        },
@@ -1058,6 +1064,7 @@ static int fill_def_thread(void)
        def_thread.write_bw_log = write_bw_log;
        def_thread.write_lat_log = write_lat_log;
        def_thread.norandommap = DEF_NO_RAND_MAP;
        def_thread.write_bw_log = write_bw_log;
        def_thread.write_lat_log = write_lat_log;
        def_thread.norandommap = DEF_NO_RAND_MAP;
+       def_thread.hugepage_size = DEF_HUGEPAGE_SIZE;
 #ifdef FIO_HAVE_DISK_UTIL
        def_thread.do_disk_util = 1;
 #endif
 #ifdef FIO_HAVE_DISK_UTIL
        def_thread.do_disk_util = 1;
 #endif