[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/30] qemu-thread: always keep the posix wrapper lay
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 11/30] qemu-thread: always keep the posix wrapper layer |
Date: |
Wed, 9 May 2018 00:14:28 +0200 |
From: Peter Xu <address@hidden>
We will conditionally have a wrapper layer depending on whether the host
has the PTHREAD_SETNAME capability. It complicates stuff. Let's keep
the wrapper there; we opt out the pthread_setname_np() call only.
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/qemu-thread-posix.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index b789cf3..a1c34ba 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -482,7 +482,6 @@ static void __attribute__((constructor))
qemu_thread_atexit_init(void)
}
-#ifdef CONFIG_PTHREAD_SETNAME_NP
typedef struct {
void *(*start_routine)(void *);
void *arg;
@@ -495,16 +494,18 @@ static void *qemu_thread_start(void *args)
void *(*start_routine)(void *) = qemu_thread_args->start_routine;
void *arg = qemu_thread_args->arg;
+#ifdef CONFIG_PTHREAD_SETNAME_NP
/* Attempt to set the threads name; note that this is for debug, so
* we're not going to fail if we can't set it.
*/
- pthread_setname_np(pthread_self(), qemu_thread_args->name);
+ if (name_threads && qemu_thread_args->name) {
+ pthread_setname_np(pthread_self(), qemu_thread_args->name);
+ }
+#endif
g_free(qemu_thread_args->name);
g_free(qemu_thread_args);
return start_routine(arg);
}
-#endif
-
void qemu_thread_create(QemuThread *thread, const char *name,
void *(*start_routine)(void*),
@@ -513,6 +514,7 @@ void qemu_thread_create(QemuThread *thread, const char
*name,
sigset_t set, oldset;
int err;
pthread_attr_t attr;
+ QemuThreadArgs *qemu_thread_args;
err = pthread_attr_init(&attr);
if (err) {
@@ -527,22 +529,13 @@ void qemu_thread_create(QemuThread *thread, const char
*name,
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, &oldset);
-#ifdef CONFIG_PTHREAD_SETNAME_NP
- if (name_threads) {
- QemuThreadArgs *qemu_thread_args;
- qemu_thread_args = g_new0(QemuThreadArgs, 1);
- qemu_thread_args->name = g_strdup(name);
- qemu_thread_args->start_routine = start_routine;
- qemu_thread_args->arg = arg;
-
- err = pthread_create(&thread->thread, &attr,
- qemu_thread_start, qemu_thread_args);
- } else
-#endif
- {
- err = pthread_create(&thread->thread, &attr,
- start_routine, arg);
- }
+ qemu_thread_args = g_new0(QemuThreadArgs, 1);
+ qemu_thread_args->name = g_strdup(name);
+ qemu_thread_args->start_routine = start_routine;
+ qemu_thread_args->arg = arg;
+
+ err = pthread_create(&thread->thread, &attr,
+ qemu_thread_start, qemu_thread_args);
if (err)
error_exit(err, __func__);
--
1.8.3.1
- [Qemu-devel] [PULL 00/30] Misc patches for 2018-05-09, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 01/30] configure: recognize more rpmbuild macros, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 03/30] cpus: tcg: fix never exiting loop on unplug, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 02/30] cpus: Fix event order on resume of stopped guest, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 04/30] checkpatch.pl: add common glib defines to typelist, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 06/30] memdev: remove "id" property, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 05/30] qom: allow object_get_canonical_path_component without parent, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 09/30] exec: extract address_space_translate_iommu, fix page_mask corner case, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 08/30] exec: small changes to flatview_do_translate, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 10/30] exec: reintroduce MemoryRegion caching, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 11/30] qemu-thread: always keep the posix wrapper layer,
Paolo Bonzini <=
- [Qemu-devel] [PULL 12/30] update-linux-headers: drop hyperv.h, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 07/30] exec: move memory access declarations to a common header, inline *_phys functions, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 13/30] accel: use g_strsplit for parsing accelerator names, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 14/30] opts: don't silently truncate long parameter keys, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 17/30] qemu-options: Mark -virtioconsole as deprecated, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 18/30] qemu-options: Remove remainders of the -tdf option, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 19/30] qemu-options: Bail out on unsupported options instead of silently ignoring them, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 20/30] qemu-options: Remove deprecated -no-kvm-pit-reinjection, Paolo Bonzini, 2018/05/08
- [Qemu-devel] [PULL 16/30] target/i386: sev: fix memory leaks, Paolo Bonzini, 2018/05/08