gettime: fix cpuclock-test on AMD platforms
authorVincent Fu <vincentfu@gmail.com>
Tue, 27 Feb 2024 15:26:00 +0000 (10:26 -0500)
committerVincent Fu <vincent.fu@samsung.com>
Tue, 27 Feb 2024 17:36:45 +0000 (12:36 -0500)
commit5ae4f4220a48dddddc84c8b839ef9d8a1ed4edb1
tree5c6464a43faf028c167ad2232aaa3acae2accf3f
parent97ef7f3a2755902dc547a8933724f63639473ac0
gettime: fix cpuclock-test on AMD platforms

Starting with gcc 11 __sync_synchronize() compiles to

lock or QWORD PTR [rsp], 0

on x86_64 platforms. Previously it compiled to an mfence instruction.

See line 47 of https://godbolt.org/z/xfE18K7b4 for an example.

On Intel platforms this change does not affect the result of fio's CPU
clock test. But on AMD platforms, this change causes fio's CPU clock
test to fail and fio to fall back to clock_gettime() instead of using
the CPU clock for timing.

This patch has fio explicitly use an mfence instruction instead of
__sync_synchornize() in the CPU clock test code on x86_64 platforms in
order to allow the CPU clock test to pass on AMD platforms.

Reviewed-by: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/20240227155856.5012-1-vincent.fu@samsung.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
arch/arch-x86_64.h
arch/arch.h
gettime.c