From: Jens Axboe Date: Sat, 12 Sep 2009 19:33:51 +0000 (+0200) Subject: Make sure shmhuge allocations are huge page size aligned X-Git-Tag: fio-1.34~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=a1242a20ac186dccdf8a72e37b9c331e0b4f8a5e Make sure shmhuge allocations are huge page size aligned Signed-off-by: Jens Axboe --- diff --git a/memory.c b/memory.c index 9b49d398..5285c0a5 100644 --- a/memory.c +++ b/memory.c @@ -65,8 +65,12 @@ static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem) { int flags = IPC_CREAT | SHM_R | SHM_W; - if (td->o.mem_type == MEM_SHMHUGE) + if (td->o.mem_type == MEM_SHMHUGE) { + unsigned long mask = td->o.hugepage_size - 1; + flags |= SHM_HUGETLB; + total_mem = (total_mem + mask) & ~mask; + } td->shm_id = shmget(IPC_PRIVATE, total_mem, flags); dprint(FD_MEM, "shmget %u, %d\n", total_mem, td->shm_id);