From c1ebf893e32a0a77e820484d48a903523fef7c1b Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Fri, 10 Jun 2016 14:33:48 -0400 Subject: [PATCH] Adding volatile modifier to tmp variable in memory test Issue explanation: ./sysbench/sysbench --test=memory --num-threads=16 \ --memory-block-size=268435456 \ --memory-total-size=137438953472 \ --memory-oper=read \ --memory-access-mode=seq \ --memory-scope=local run Without this commit the time to run the above command is 0.0004 seconds. With this commit the time is greater than 3 seconds. Essentially, without the volatile modifier, the compiler optimizes read access so that no real access happens. Upstream-Status: Backport [part of v1.0.0 https://github.com/akopytov/sysbench/commit/8753cb93be4c0b81a20b704ced91e7a422da52b1] (cherry picked from commit 8753cb93be4c0b81a20b704ced91e7a422da52b1) Signed-off-by: massimo toscanelli --- sysbench/tests/memory/sb_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/tests/memory/sb_memory.c b/sysbench/tests/memory/sb_memory.c index 2e8998f..7d22bb9 100644 --- a/sysbench/tests/memory/sb_memory.c +++ b/sysbench/tests/memory/sb_memory.c @@ -244,7 +244,7 @@ sb_request_t memory_get_request(int tid) int memory_execute_request(sb_request_t *sb_req, int thread_id) { sb_mem_request_t *mem_req = &sb_req->u.mem_request; - int tmp = 0; + volatile int tmp = 0; int idx; int *buf, *end; log_msg_t msg;