From 0268b8ba7b2c79c669323cb1fcc0b045b84313f1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 20 Dec 2006 12:48:23 +0100 Subject: [PATCH] [PATCH] Fix hugetlb problems Alignment was bad, and we need to check the shmhuge string before shm, otherwise it'll match the latter. Signed-off-by: Jens Axboe --- fio.c | 2 +- init.c | 6 +++--- memory.c | 2 +- os.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fio.c b/fio.c index 87136141..41b60202 100644 --- 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 bfe69810..7d7c9d63 100644 --- 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"); diff --git a/memory.c b/memory.c index a7bf82a8..d336c2bc 100644 --- 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 b5f43e59..a2699dd2 100644 --- 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 -- 2.25.1