2020-08-19 12:44:56 +00:00
|
|
|
util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c'))
|
util: Introduce ThreadContext user-creatable object
Setting the CPU affinity of QEMU threads is a bit problematic, because
QEMU doesn't always have permissions to set the CPU affinity itself,
for example, with seccomp after initialized by QEMU:
-sandbox enable=on,resourcecontrol=deny
General information about CPU affinities can be found in the man page of
taskset:
CPU affinity is a scheduler property that "bonds" a process to a given
set of CPUs on the system. The Linux scheduler will honor the given CPU
affinity and the process will not run on any other CPUs.
While upper layers are already aware of how to handle CPU affinities for
long-lived threads like iothreads or vcpu threads, especially short-lived
threads, as used for memory-backend preallocation, are more involved to
handle. These threads are created on demand and upper layers are not even
able to identify and configure them.
Introduce the concept of a ThreadContext, that is essentially a thread
used for creating new threads. All threads created via that context
thread inherit the configured CPU affinity. Consequently, it's
sufficient to create a ThreadContext and configure it once, and have all
threads created via that ThreadContext inherit the same CPU affinity.
The CPU affinity of a ThreadContext can be configured two ways:
(1) Obtaining the thread id via the "thread-id" property and setting the
CPU affinity manually (e.g., via taskset).
(2) Setting the "cpu-affinity" property and letting QEMU try set the
CPU affinity itself. This will fail if QEMU doesn't have permissions
to do so anymore after seccomp was initialized.
A simple QEMU example to set the CPU affinity to host CPU 0,1,6,7 would be:
qemu-system-x86_64 -S \
-object thread-context,id=tc1,cpu-affinity=0-1,cpu-affinity=6-7
And we can query it via HMP/QMP:
(qemu) qom-get tc1 cpu-affinity
[
0,
1,
6,
7
]
But note that due to dynamic library loading this example will not work
before we actually make use of thread_context_create_thread() in QEMU
code, because the type will otherwise not get registered. We'll wire
this up next to make it work.
In general, the interface behaves like pthread_setaffinity_np(): host
CPU numbers that are currently not available are ignored; only host CPU
numbers that are impossible with the current kernel will fail. If the
list of host CPU numbers does not include a single CPU that is
available, setting the CPU affinity will fail.
A ThreadContext can be reused, simply by reconfiguring the CPU affinity.
Note that the CPU affinity of previously created threads will not get
adjusted.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221014134720.168738-4-david@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
2022-10-14 13:47:16 +00:00
|
|
|
util_ss.add(files('thread-context.c'))
|
2021-10-07 13:08:25 +00:00
|
|
|
if not config_host_data.get('CONFIG_ATOMIC64')
|
|
|
|
util_ss.add(files('atomic64.c'))
|
|
|
|
endif
|
2020-08-19 12:44:56 +00:00
|
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('aio-posix.c'))
|
|
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('fdmon-poll.c'))
|
2021-06-03 10:10:05 +00:00
|
|
|
if config_host_data.get('CONFIG_EPOLL_CREATE1')
|
|
|
|
util_ss.add(files('fdmon-epoll.c'))
|
|
|
|
endif
|
meson: fix missing preprocessor symbols
While most libraries do not need a CONFIG_* symbol because the
"when:" clauses are enough, some do. Add them back or stop
using them if possible.
In the case of libpmem, the statement to add the CONFIG_* symbol
was still in configure, but could not be triggered because it
checked for "no" instead of "disabled" (and it would be wrong anyway
since the test for the library has not been done yet).
Reported-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Fixes: 587d59d6cc ("configure, meson: convert virgl detection to meson", 2021-07-06)
Fixes: 83ef16821a ("configure, meson: convert libdaxctl detection to meson", 2021-07-06)
Fixes: e36e8c70f6 ("configure, meson: convert libpmem detection to meson", 2021-07-06)
Fixes: 53c22b68e3 ("configure, meson: convert liburing detection to meson", 2021-07-06)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-07-08 11:50:06 +00:00
|
|
|
util_ss.add(when: linux_io_uring, if_true: files('fdmon-io_uring.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
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'))
|
2022-03-23 15:57:13 +00:00
|
|
|
freebsd_dep = []
|
|
|
|
if targetos == 'freebsd'
|
|
|
|
freebsd_dep = util
|
|
|
|
endif
|
|
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: [files('oslib-posix.c'), freebsd_dep])
|
2020-08-19 12:44:56 +00:00
|
|
|
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)
|
2022-06-24 14:50:37 +00:00
|
|
|
util_ss.add(when: 'CONFIG_WIN32', if_true: pathcch)
|
2020-08-19 12:44:56 +00:00
|
|
|
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'))
|
2022-06-21 01:48:35 +00:00
|
|
|
util_ss.add(files('cacheflush.c'))
|
2022-03-23 15:57:25 +00:00
|
|
|
util_ss.add(files('error.c', 'error-report.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
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'))
|
2021-11-08 12:52:11 +00:00
|
|
|
if have_membarrier
|
|
|
|
util_ss.add(files('sys_membarrier.c'))
|
|
|
|
endif
|
2020-08-19 12:44:56 +00:00
|
|
|
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'))
|
2021-04-28 15:17:36 +00:00
|
|
|
util_ss.add(files('transactions.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c'))
|
|
|
|
util_ss.add(files('guest-random.c'))
|
2021-03-23 17:52:46 +00:00
|
|
|
util_ss.add(files('yank.c'))
|
2022-01-06 21:00:53 +00:00
|
|
|
util_ss.add(files('int128.c'))
|
2022-02-26 18:07:17 +00:00
|
|
|
util_ss.add(files('memalign.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
|
|
|
|
if have_user
|
|
|
|
util_ss.add(files('selfmap.c'))
|
|
|
|
endif
|
|
|
|
|
|
|
|
if have_system
|
2021-01-23 10:39:57 +00:00
|
|
|
util_ss.add(files('crc-ccitt.c'))
|
2022-04-20 15:33:44 +00:00
|
|
|
util_ss.add(when: gio, if_true: files('dbus.c'))
|
2021-01-29 10:14:04 +00:00
|
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if have_block
|
|
|
|
util_ss.add(files('aiocb.c', 'async.c', 'aio-wait.c'))
|
|
|
|
util_ss.add(files('base64.c'))
|
|
|
|
util_ss.add(files('buffer.c'))
|
|
|
|
util_ss.add(files('bufferiszero.c'))
|
|
|
|
util_ss.add(files('coroutine-@0@.c'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
|
|
|
|
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', 'qemu-sockets.c', 'uri.c'))
|
|
|
|
util_ss.add(files('lockcnt.c'))
|
|
|
|
util_ss.add(files('main-loop.c'))
|
|
|
|
util_ss.add(files('nvdimm-utils.c'))
|
|
|
|
util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c'))
|
2020-10-27 17:35:18 +00:00
|
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: [
|
2020-09-24 15:15:49 +00:00
|
|
|
files('vhost-user-server.c'), vhost_user
|
|
|
|
])
|
2020-09-18 08:09:09 +00:00
|
|
|
util_ss.add(files('block-helpers.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
util_ss.add(files('qemu-coroutine-sleep.c'))
|
|
|
|
util_ss.add(files('qemu-co-shared-resource.c'))
|
2022-04-07 13:27:23 +00:00
|
|
|
util_ss.add(files('qemu-co-timeout.c'))
|
2020-08-19 12:44:56 +00:00
|
|
|
util_ss.add(files('thread-pool.c', 'qemu-timer.c'))
|
|
|
|
util_ss.add(files('readline.c'))
|
|
|
|
util_ss.add(files('throttle.c'))
|
|
|
|
util_ss.add(files('timed-average.c'))
|
2022-01-07 13:35:14 +00:00
|
|
|
if config_host_data.get('CONFIG_INOTIFY1')
|
|
|
|
util_ss.add(files('filemonitor-inotify.c'))
|
|
|
|
else
|
|
|
|
util_ss.add(files('filemonitor-stub.c'))
|
|
|
|
endif
|
2020-08-19 12:44:56 +00:00
|
|
|
util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))
|
|
|
|
endif
|