From de7a37a8d8ada2c28a3777381dd1b83e0810b05d Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Sun, 24 Jun 2018 21:50:10 +0200 Subject: [PATCH] ioat/verify: ensure 8-byte alignment for FILL requests We're usually lucky and either the buffer is physically-contiguous, or the address is already 8-bit aligned, but intermittent failures were still happening. Not anymore. Change-Id: Iec226b42f66c7c273f181cda764b92164e24b0e3 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/416658 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- examples/ioat/verify/verify.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/ioat/verify/verify.c b/examples/ioat/verify/verify.c index 34122f3a3..dbc82e95f 100644 --- a/examples/ioat/verify/verify.c +++ b/examples/ioat/verify/verify.c @@ -134,10 +134,15 @@ static void prepare_ioat_task(struct thread_entry *thread_entry, struct ioat_tas fill_pattern = rand_r(&seed); fill_pattern = fill_pattern << 32 | rand_r(&seed); - /* ensure that the length of memset block is 8 Bytes aligned */ - len = 8 + ((rand_r(&seed) % (SRC_BUFFER_SIZE - 8)) & ~0x7); - dst_offset = rand_r(&seed) % (SRC_BUFFER_SIZE - len); + /* Ensure that the length of memset block is 8 Bytes aligned. + * In case the buffer crosses hugepage boundary and must be split, + * we also need to ensure 8 byte address alignment. We do it + * unconditionally to keep things simple. + */ + len = 8 + ((rand_r(&seed) % (SRC_BUFFER_SIZE - 16)) & ~0x7); + dst_offset = 8 + rand_r(&seed) % (SRC_BUFFER_SIZE - 8 - len); ioat_task->fill_pattern = fill_pattern; + ioat_task->dst = (void *)(((uintptr_t)ioat_task->buffer + dst_offset) & ~0x7); } else { src_offset = rand_r(&seed) % SRC_BUFFER_SIZE; len = rand_r(&seed) % (SRC_BUFFER_SIZE - src_offset); @@ -145,9 +150,9 @@ static void prepare_ioat_task(struct thread_entry *thread_entry, struct ioat_tas memset(ioat_task->buffer, 0, SRC_BUFFER_SIZE); ioat_task->src = (void *)((uintptr_t)g_src + src_offset); + ioat_task->dst = (void *)((uintptr_t)ioat_task->buffer + dst_offset); } ioat_task->len = len; - ioat_task->dst = (void *)((uintptr_t)ioat_task->buffer + dst_offset); ioat_task->thread_entry = thread_entry; }