From 52598cf37e249ba5c425899aef6ea1e453e679c7 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Mon, 28 Aug 2017 14:57:20 -0400 Subject: [PATCH] Generalize size-dependent virtual address alignment Support all fragment sizes up to 2MB by aligning buffers according to their size. Change-Id: I82b7ef8be6f1507d941e5c97edb6618adf8c66de Signed-off-by: Felix Kuehling --- src/fmm.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/fmm.c b/src/fmm.c index c4f3da5b7a..115137a201 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -544,14 +544,11 @@ static void *aperture_allocate_area_aligned(manageable_aperture_t *app, if (align < app->align) align = app->align; - /* Huge-page and Big-K TLB optimizations require proper alignment */ - if (MemorySizeInBytes >= GPU_HUGE_PAGE_SIZE) { - if (align < GPU_HUGE_PAGE_SIZE) - align = GPU_HUGE_PAGE_SIZE; - } else if (MemorySizeInBytes >= GPU_BIGK_PAGE_SIZE) { - if (align < GPU_BIGK_PAGE_SIZE) - align = GPU_BIGK_PAGE_SIZE; - } + /* Align big buffers to the next power-of-2 up to huge page + * size for flexible fragment size TLB optimizations + */ + while (align < GPU_HUGE_PAGE_SIZE && MemorySizeInBytes >= (align << 1)) + align <<= 1; MemorySizeInBytes = vm_align_area_size(app, MemorySizeInBytes);