qemu-e2k/include/qemu
Emilio Cota e3feb2cc22 util: import GTree as QTree
The only reason to add this implementation is to control the memory allocator
used. Some users (e.g. TCG) cannot work reliably in multi-threaded
environments (e.g. forking in user-mode) with GTree's allocator, GSlice.
See https://gitlab.com/qemu-project/qemu/-/issues/285 for details.

Importing GTree is a temporary workaround until GTree migrates away
from GSlice.

This implementation is identical to that in glib v2.75.0, except that
we don't import recent additions to the API nor deprecated API calls,
none of which are used in QEMU.

I've imported tests from glib and added a benchmark just to
make sure that performance is similar. Note: it cannot be identical
because (1) we are not using GSlice, (2) we use different compilation flags
(e.g. -fPIC) and (3) we're linking statically.

$ cat /proc/cpuinfo| grep 'model name' | head -1
model name      : AMD Ryzen 7 PRO 5850U with Radeon Graphics
$ echo '0' | sudo tee /sys/devices/system/cpu/cpufreq/boost
$ tests/bench/qtree-bench

 Tree         Op      32            1024            4096          131072         1048576
------------------------------------------------------------------------------------------------
GTree     Lookup   83.23           43.08           25.31           19.40           16.22
QTree     Lookup  113.42 (1.36x)   53.83 (1.25x)   28.38 (1.12x)   17.64 (0.91x)   13.04 (0.80x)
GTree     Insert   44.23           29.37           25.83           19.49           17.03
QTree     Insert   46.87 (1.06x)   25.62 (0.87x)   24.29 (0.94x)   16.83 (0.86x)   12.97 (0.76x)
GTree     Remove   53.27           35.15           31.43           24.64           16.70
QTree     Remove   57.32 (1.08x)   41.76 (1.19x)   38.37 (1.22x)   29.30 (1.19x)   15.07 (0.90x)
GTree  RemoveAll  135.44          127.52          126.72          120.11           64.34
QTree  RemoveAll  127.15 (0.94x)  110.37 (0.87x)  107.97 (0.85x)   97.13 (0.81x)   55.10 (0.86x)
GTree   Traverse  277.71          276.09          272.78          246.72           98.47
QTree   Traverse  370.33 (1.33x)  411.97 (1.49x)  400.23 (1.47x)  262.82 (1.07x)   78.52 (0.80x)
------------------------------------------------------------------------------------------------

As a sanity check, the same benchmark when Glib's version
is >= $glib_dropped_gslice_version (i.e. QTree == GTree):

 Tree         Op      32            1024            4096          131072         1048576
------------------------------------------------------------------------------------------------
GTree     Lookup   82.72           43.09           24.18           19.73           16.09
QTree     Lookup   81.82 (0.99x)   43.10 (1.00x)   24.20 (1.00x)   19.76 (1.00x)   16.26 (1.01x)
GTree     Insert   45.07           29.62           26.34           19.90           17.18
QTree     Insert   45.72 (1.01x)   29.60 (1.00x)   26.38 (1.00x)   19.71 (0.99x)   17.20 (1.00x)
GTree     Remove   54.48           35.36           31.77           24.97           16.95
QTree     Remove   54.46 (1.00x)   35.32 (1.00x)   31.77 (1.00x)   24.91 (1.00x)   17.15 (1.01x)
GTree  RemoveAll  140.68          127.36          125.43          121.45           68.20
QTree  RemoveAll  140.65 (1.00x)  127.64 (1.00x)  125.01 (1.00x)  121.73 (1.00x)   67.06 (0.98x)
GTree   Traverse  278.68          276.05          266.75          251.65          104.93
QTree   Traverse  278.31 (1.00x)  275.78 (1.00x)  266.42 (1.00x)  247.89 (0.99x)  104.58 (1.00x)
------------------------------------------------------------------------------------------------

Signed-off-by: Emilio Cota <cota@braap.org>
Message-Id: <20230205163758.416992-2-cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-03-28 15:23:10 -07:00
..
accel.h typedefs: Forward-declare AccelState 2023-01-06 00:50:32 +01:00
async-teardown.h Don't include headers already included by qemu/osdep.h 2023-02-08 07:28:05 +01:00
atomic128.h include/qemu/int128: Use Int128 structure for TCI 2023-02-04 06:19:42 -10:00
atomic.h qatomic: add smp_mb__before/after_rmw() 2023-03-07 12:38:40 +01:00
base64.h
bcd.h
bitmap.h replace TABs with spaces 2023-03-20 12:43:50 +01:00
bitops.h bitops.h: revert db1ffc32dd ("qemu/bitops.h: add bitrev8 implementation") 2021-07-26 06:56:41 -10:00
bswap.h qemu/bswap: Add const_le64() 2023-03-02 19:13:52 -05:00
buffer.h Replace GCC_FMT_ATTR with G_GNUC_PRINTF 2022-03-22 14:40:51 +04:00
cacheflush.h util: Enhance flush_icache_range with separate data pointer 2021-01-07 05:09:41 -10:00
cacheinfo.h include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h 2022-02-21 13:30:20 +00:00
clang-tsa.h clang-tsa: Add macros for shared locks 2022-12-15 16:07:43 +01:00
co-shared-resource.h co-shared-resource: protect with a mutex 2021-06-25 14:24:24 +03:00
compiler.h replace TABs with spaces 2023-03-20 12:43:50 +01:00
config-file.h qemu-config: Make config_parse_qdict() return bool 2022-12-14 16:19:35 +01:00
coroutine_int.h
coroutine-core.h coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h 2023-01-20 07:21:46 +01:00
coroutine-tls.h tls: add macros for coroutine-safe TLS variables 2022-03-04 18:14:40 +01:00
coroutine.h coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h 2023-01-20 07:21:46 +01:00
cpu-float.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
cpuid.h include/qemu/cpuid: Introduce xgetbv_low 2023-03-05 13:44:07 -08:00
crc32c.h
crc-ccitt.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
ctype.h
cutils.h cutils: Introduce bundle mechanism 2022-07-13 16:58:57 +02:00
datadir.h
dbus.h Don't include headers already included by qemu/osdep.h 2023-02-08 07:28:05 +01:00
drm.h
envlist.h remove unnecessary extern "C" blocks 2023-02-10 14:12:06 +01:00
error-report.h Move error_printf_unless_qmp() with monitor unit 2022-04-21 17:09:09 +04:00
event_notifier.h event_notifier: add event_notifier_get_wfd() 2022-03-06 06:19:47 -05:00
fifo8.h utils/fifo8: add VMSTATE_FIFO8_TEST macro 2021-02-07 20:38:34 +00:00
fifo32.h
filemonitor.h
futex.h
guest-random.h
hbitmap.h hbitmap: fix hbitmap_status() return value for first dirty bit case 2023-02-17 14:34:24 +01:00
help_option.h
help-texts.h Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
host-utils.h Don't include headers already included by qemu/osdep.h 2023-02-08 07:28:05 +01:00
hw-version.h include: Move hardware version declarations to new qemu/hw-version.h 2022-02-21 13:30:20 +00:00
id.h net: Use id_generate() in the network subsystem, too 2021-03-09 21:47:45 +01:00
int128.h include/qemu/int128: Use Int128 structure for TCI 2023-02-04 06:19:42 -10:00
interval-tree.h util: Add interval-tree.c 2022-12-20 17:09:41 -08:00
iov.h util/iov: make qemu_iovec_init_extended() honest 2021-02-03 08:00:33 -06:00
iova-tree.h util: accept iova_tree_remove_parameter by value 2022-09-02 10:22:39 +08:00
jhash.h
job.h job: remove unused functions 2022-10-07 12:11:41 +02:00
keyval.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
lockable.h coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h 2023-01-20 07:21:46 +01:00
log-for-trace.h util/log: Drop return value from qemu_log 2022-04-20 10:51:11 -07:00
log.h util/log: Support per-thread log files 2022-04-20 10:51:11 -07:00
madvise.h include: Move qemu_madvise() and related #defines to new qemu/madvise.h 2022-02-21 13:30:20 +00:00
main-loop.h main-loop: remove qemu_fd_register(), win32/slirp/socket specific 2023-03-13 15:39:31 +04:00
memalign.h osdep: Move memalign-related functions to their own header 2022-03-07 13:16:49 +00:00
memfd.h
mmap-alloc.h util/mmap-alloc: Remove qemu_mempath_getpagesize() 2022-08-26 13:34:21 +02:00
module.h module: add Error arguments to module_load and module_load_qom 2022-11-06 09:48:50 +01:00
mprotect.h include: Move qemu_mprotect_*() to new qemu/mprotect.h 2022-02-21 13:30:20 +00:00
notify.h
nvdimm-utils.h
option_int.h
option.h include: add qemu/keyval.h 2022-04-21 17:03:51 +04:00
osdep.h qemu/osdep: Switch position of "extern" and "G_NORETURN" 2023-03-20 12:43:50 +01:00
path.h
plugin-event.h include/qemu: Split out plugin-event.h 2023-03-22 15:06:57 +00:00
plugin-memory.h include: Include headers where needed 2023-01-08 01:54:22 -05:00
plugin.h include/qemu/plugin: Inline qemu_plugin_disable_mem_helpers 2023-03-22 15:06:57 +00:00
pmem.h
processor.h
progress_meter.h coroutine: Clean up superfluous inclusion of qemu/lockable.h 2023-01-19 10:18:28 +01:00
qdist.h
qemu-options.h remove qemu-options* from root directory 2021-05-26 14:49:46 +02:00
qemu-plugin.h include/qemu: add documentation for memory callbacks 2023-03-22 15:06:57 +00:00
qemu-print.h Replace GCC_FMT_ATTR with G_GNUC_PRINTF 2022-03-22 14:40:51 +04:00
qemu-progress.h include: move progress API to qemu-progress.h 2022-04-06 14:31:43 +02:00
qht.h
qsp.h
qtree.h util: import GTree as QTree 2023-03-28 15:23:10 -07:00
queue.h
range.h compiler.h: replace QEMU_WARN_UNUSED_RESULT with G_GNUC_WARN_UNUSED_RESULT 2022-03-22 14:40:51 +04:00
ratelimit.h ratelimit: treat zero speed as unlimited 2021-06-25 14:22:21 +03:00
rcu_queue.h remove unnecessary extern "C" blocks 2023-02-10 14:12:06 +01:00
rcu.h remove unnecessary extern "C" blocks 2023-02-10 14:12:06 +01:00
readline.h readline: Extract readline_add_completion_of() from monitor 2023-02-04 07:56:54 +01:00
selfmap.h Clean up decorations and whitespace around header guards 2022-05-11 16:50:32 +02:00
seqlock.h
sockets.h osdep: implement qemu_socketpair() for win32 2023-03-13 15:39:31 +04:00
stats64.h qemu/atomic: Add aligned_{int64,uint64}_t types 2021-07-21 07:45:38 -10:00
sys_membarrier.h
systemd.h
thread-context.h util: Introduce ThreadContext user-creatable object 2022-10-27 11:00:43 +02:00
thread-posix.h thread-posix: implement Semaphore with QemuCond and QemuMutex 2022-04-06 14:31:56 +02:00
thread-win32.h util: Use real functions for thread-posix QemuRecMutex 2021-06-16 15:03:26 +02:00
thread.h util/qemu-thread-posix: use TSA_NO_TSA to suppress clang TSA warnings in FreeBSD 2023-02-17 11:22:19 +01:00
throttle-options.h
throttle.h
timed-average.h
timer.h Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
transactions.h transactions: Invoke clean() after everything else 2021-11-16 09:43:44 +01:00
tsan.h
typedefs.h qemu/typedefs: Sort in case-insensitive alphabetical order (again) 2023-02-27 22:29:01 +01:00
unicode.h
units.h
uri.h replace TABs with spaces 2023-03-20 12:43:50 +01:00
userfaultfd.h migration: Clean up includes 2023-02-08 07:27:20 +01:00
uuid.h qemu/uuid: Add UUID static initializer 2023-03-02 19:13:52 -05:00
vfio-helpers.h util/vfio-helpers: Pass Error handle to qemu_vfio_dma_map() 2021-09-07 09:08:24 +01:00
vhost-user-server.h Do not include "qemu/error-report.h" in headers that do not need it 2023-02-14 09:11:27 +01:00
win_dump_defs.h include/qemu: add 32-bit Windows dump structures 2022-04-22 13:36:04 +04:00
xattr.h qemu/xattr.h: Exclude <sys/xattr.h> for Windows 2022-12-23 11:48:13 +01:00
xxhash.h target/arm: Implement an IMPDEF pauth algorithm 2021-01-19 14:38:51 +00:00
yank.h yank: Remove dependency on qiochannel 2021-04-01 15:27:44 +04:00