mirror of
https://github.com/qemu/qemu.git
synced 2024-12-15 23:43:31 +08:00
e3feb2cc22
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>
109 lines
4.1 KiB
Meson
109 lines
4.1 KiB
Meson
util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c'))
|
|
util_ss.add(files('thread-context.c'), numa)
|
|
if not config_host_data.get('CONFIG_ATOMIC64')
|
|
util_ss.add(files('atomic64.c'))
|
|
endif
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: files('async-teardown.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('aio-posix.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('fdmon-poll.c'))
|
|
if config_host_data.get('CONFIG_EPOLL_CREATE1')
|
|
util_ss.add(files('fdmon-epoll.c'))
|
|
endif
|
|
util_ss.add(when: linux_io_uring, if_true: files('fdmon-io_uring.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('compatfd.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('event_notifier-posix.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('mmap-alloc.c'))
|
|
freebsd_dep = []
|
|
if targetos == 'freebsd'
|
|
freebsd_dep = util
|
|
endif
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: [files('oslib-posix.c'), freebsd_dep])
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('qemu-thread-posix.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('memfd.c'))
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: files('aio-win32.c'))
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: files('event_notifier-win32.c'))
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: files('oslib-win32.c'))
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: files('qemu-thread-win32.c'))
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: winmm)
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: pathcch)
|
|
util_ss.add(when: 'HAVE_GLIB_WITH_SLICE_ALLOCATOR', if_true: files('qtree.c'))
|
|
util_ss.add(files('envlist.c', 'path.c', 'module.c'))
|
|
util_ss.add(files('host-utils.c'))
|
|
util_ss.add(files('bitmap.c', 'bitops.c'))
|
|
util_ss.add(files('fifo8.c'))
|
|
util_ss.add(files('cacheflush.c'))
|
|
util_ss.add(files('error.c', 'error-report.c'))
|
|
util_ss.add(files('qemu-print.c'))
|
|
util_ss.add(files('id.c'))
|
|
util_ss.add(files('qemu-config.c', 'notify.c'))
|
|
util_ss.add(files('qemu-option.c', 'qemu-progress.c'))
|
|
util_ss.add(files('keyval.c'))
|
|
util_ss.add(files('crc32c.c'))
|
|
util_ss.add(files('uuid.c'))
|
|
util_ss.add(files('getauxval.c'))
|
|
util_ss.add(files('rcu.c'))
|
|
if have_membarrier
|
|
util_ss.add(files('sys_membarrier.c'))
|
|
endif
|
|
util_ss.add(files('log.c'))
|
|
util_ss.add(files('qdist.c'))
|
|
util_ss.add(files('qht.c'))
|
|
util_ss.add(files('qsp.c'))
|
|
util_ss.add(files('range.c'))
|
|
util_ss.add(files('stats64.c'))
|
|
util_ss.add(files('systemd.c'))
|
|
util_ss.add(files('transactions.c'))
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c'))
|
|
util_ss.add(files('guest-random.c'))
|
|
util_ss.add(files('yank.c'))
|
|
util_ss.add(files('int128.c'))
|
|
util_ss.add(files('memalign.c'))
|
|
util_ss.add(files('interval-tree.c'))
|
|
util_ss.add(files('lockcnt.c'))
|
|
|
|
if have_user
|
|
util_ss.add(files('selfmap.c'))
|
|
endif
|
|
|
|
if have_system
|
|
util_ss.add(files('crc-ccitt.c'))
|
|
util_ss.add(when: gio, if_true: files('dbus.c'))
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c'))
|
|
endif
|
|
|
|
if have_block or have_ga
|
|
util_ss.add(files('aiocb.c', 'async.c'))
|
|
util_ss.add(files('base64.c'))
|
|
util_ss.add(files('main-loop.c'))
|
|
util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c'))
|
|
util_ss.add(files('coroutine-@0@.c'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
|
|
util_ss.add(files('thread-pool.c', 'qemu-timer.c'))
|
|
util_ss.add(files('qemu-sockets.c'))
|
|
endif
|
|
if have_block
|
|
util_ss.add(files('aio-wait.c'))
|
|
util_ss.add(files('buffer.c'))
|
|
util_ss.add(files('bufferiszero.c'))
|
|
util_ss.add(files('hbitmap.c'))
|
|
util_ss.add(files('hexdump.c'))
|
|
util_ss.add(files('iova-tree.c'))
|
|
util_ss.add(files('iov.c', 'uri.c'))
|
|
util_ss.add(files('nvdimm-utils.c'))
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: [
|
|
files('vhost-user-server.c'), vhost_user
|
|
])
|
|
util_ss.add(files('block-helpers.c'))
|
|
util_ss.add(files('qemu-coroutine-sleep.c'))
|
|
util_ss.add(files('qemu-co-shared-resource.c'))
|
|
util_ss.add(files('qemu-co-timeout.c'))
|
|
util_ss.add(files('readline.c'))
|
|
util_ss.add(files('throttle.c'))
|
|
util_ss.add(files('timed-average.c'))
|
|
if config_host_data.get('CONFIG_INOTIFY1')
|
|
util_ss.add(files('filemonitor-inotify.c'))
|
|
else
|
|
util_ss.add(files('filemonitor-stub.c'))
|
|
endif
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))
|
|
endif
|