summaryrefslogtreecommitdiff
path: root/tests/atomic_add-bench.c
AgeCommit message (Collapse)Author
2020-09-23qemu/atomic.h: rename atomic_ to qatomic_Stefan Hajnoczi
clang's C11 atomic_fetch_*() functions only take a C11 atomic type pointer argument. QEMU uses direct types (int, etc) and this causes a compiler error when a QEMU code calls these functions in a source file that also included <stdatomic.h> via a system header file: $ CC=clang CXX=clang++ ./configure ... && make ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid) Avoid using atomic_*() names in QEMU's atomic.h since that namespace is used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h and <stdatomic.h> can co-exist. I checked /usr/include on my machine and searched GitHub for existing "qatomic_" users but there seem to be none. This patch was generated using: $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \ sort -u >/tmp/changed_identifiers $ for identifier in $(</tmp/changed_identifiers); do sed -i "s%\<$identifier\>%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
2019-01-14tests: use g_usleep instead of rem = sleep(time)Alex Bennée
Relying on sleep to always return having slept isn't safe as a signal may have occurred. If signals are constantly incoming the program will never reach its termination condition. This is believed to be the mechanism causing time outs for qht-test in Travis. The glib g_usleep() deals with all of this for us so lets use it instead. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2018-08-23tests/atomic_add-bench: add -p to enable sync profilerEmilio G. Cota
When used together with -m, this allows us to benchmark the profiler's performance impact on qemu_mutex_lock. Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28tests/atomic_add-bench: add -m option to use mutexesEmilio G. Cota
This allows us to use atomic-add-bench as a microbenchmark for evaluating qemu_mutex_lock's performance. Signed-off-by: Emilio G. Cota <cota@braap.org> [cherry picked from https://github.com/cota/qemu/commit/f04f34df] Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180425025459.5258-2-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-10-26tests: add atomic_add-benchEmilio G. Cota
With this microbenchmark we can measure the overhead of emulating atomic instructions with a configurable degree of contention. The benchmark spawns $n threads, each performing $o atomic ops (additions) in a loop. Each atomic operation is performed on a different cache line (assuming lines are 64b long) that is randomly selected from a range [0, $r). [ Note: each $foo corresponds to a -foo flag ] Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Richard Henderson <rth@twiddle.net> Message-Id: <1467054136-10430-20-git-send-email-cota@braap.org>