* [Qemu-devel] [PATCH 0/1] configure time fix for thread naming on old glibc
@ 2014-03-12 11:48 Dr. David Alan Gilbert (git)
2014-03-12 11:48 ` [Qemu-devel] [PATCH 1/1] Detect pthread_setname_np at configure time Dr. David Alan Gilbert (git)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2014-03-12 11:48 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, jan.kiszka, mst
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Peter was preferring configure time detection of pthread_setname_np
to guard against my recent breaking of builds on old libc.
I've tested this on:
Fedora 20 - modern glibc - works as before
RHEL 5 - glibc 2.5:
[dgilbert@davidgil-rhel5 try]$ ./bin/qemu-system-x86_64 -nographic -name debug-threads=on
qemu: thread naming not supported on this host
and checked a mingw windows cross build builds.
A check on SLES11 is probably worth a try if someone has one to hand.
Dr. David Alan Gilbert (1):
Detect pthread_setname_np at configure time
configure | 28 ++++++++++++++++++++++++++++
util/qemu-thread-posix.c | 21 ++++++++++++++++++---
util/qemu-thread-win32.c | 2 ++
3 files changed, 48 insertions(+), 3 deletions(-)
--
1.8.5.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/1] Detect pthread_setname_np at configure time
2014-03-12 11:48 [Qemu-devel] [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert (git)
@ 2014-03-12 11:48 ` Dr. David Alan Gilbert (git)
2014-03-26 17:51 ` [Qemu-devel] Ping: [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert
2014-03-27 7:20 ` [Qemu-devel] " Michael S. Tsirkin
2 siblings, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2014-03-12 11:48 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, jan.kiszka, mst
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Warn if no way of setting thread name is available.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
configure | 28 ++++++++++++++++++++++++++++
util/qemu-thread-posix.c | 21 ++++++++++++++++++---
util/qemu-thread-win32.c | 2 ++
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 9539979..d349ba2 100755
--- a/configure
+++ b/configure
@@ -2709,6 +2709,24 @@ if test "$mingw32" != yes -a "$pthread" = no; then
"Make sure to have the pthread libs and headers installed."
fi
+# check for pthread_setname_np
+pthread_setname_np=no
+cat > $TMPC << EOF
+#include <pthread.h>
+
+static void *f(void *p) { return NULL; }
+int main(void)
+{
+ pthread_t thread;
+ pthread_create(&thread, 0, f, 0);
+ pthread_setname_np(thread, "QEMU");
+ return 0;
+}
+EOF
+if compile_prog "" "$pthread_lib" ; then
+ pthread_setname_np=yes
+fi
+
##########################################
# rbd probe
if test "$rbd" != "no" ; then
@@ -4636,6 +4654,16 @@ if test "$rdma" = "yes" ; then
echo "CONFIG_RDMA=y" >> $config_host_mak
fi
+# Hold two types of flag:
+# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
+# a thread we have a handle to
+# CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
+# platform
+if test "$pthread_setname_np" = "yes" ; then
+ echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
+ echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
+fi
+
if test "$tcg_interpreter" = "yes"; then
QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
elif test "$ARCH" = "sparc64" ; then
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 960d7f5..d05a649 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -32,6 +32,13 @@ static bool name_threads;
void qemu_thread_naming(bool enable)
{
name_threads = enable;
+
+#ifndef CONFIG_THREAD_SETNAME_BYTHREAD
+ /* This is a debugging option, not fatal */
+ if (enable) {
+ fprintf(stderr, "qemu: thread naming not supported on this host\n");
+ }
+#endif
}
static void error_exit(int err, const char *msg)
@@ -394,6 +401,16 @@ void qemu_event_wait(QemuEvent *ev)
}
}
+/* 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.
+ */
+static void qemu_thread_set_name(QemuThread *thread, const char *name)
+{
+#ifdef CONFIG_PTHREAD_SETNAME_NP
+ pthread_setname_np(thread->thread, name);
+#endif
+}
+
void qemu_thread_create(QemuThread *thread, const char *name,
void *(*start_routine)(void*),
void *arg, int mode)
@@ -420,11 +437,9 @@ void qemu_thread_create(QemuThread *thread, const char *name,
if (err)
error_exit(err, __func__);
-#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
if (name_threads) {
- pthread_setname_np(thread->thread, name);
+ qemu_thread_set_name(thread, name);
}
-#endif
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index b9c957b..c405c9b 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -22,6 +22,8 @@ void qemu_thread_naming(bool enable)
{
/* But note we don't actually name them on Windows yet */
name_threads = enable;
+
+ fprintf(stderr, "qemu: thread naming not supported on this host\n");
}
static void error_exit(int err, const char *msg)
--
1.8.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Ping: [PATCH 0/1] configure time fix for thread naming on old glibc
2014-03-12 11:48 [Qemu-devel] [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert (git)
2014-03-12 11:48 ` [Qemu-devel] [PATCH 1/1] Detect pthread_setname_np at configure time Dr. David Alan Gilbert (git)
@ 2014-03-26 17:51 ` Dr. David Alan Gilbert
2014-03-27 7:20 ` [Qemu-devel] " Michael S. Tsirkin
2 siblings, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert @ 2014-03-26 17:51 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, mst, jan.kiszka
* Dr. David Alan Gilbert (git) (dgilbert@redhat.com) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Peter was preferring configure time detection of pthread_setname_np
> to guard against my recent breaking of builds on old libc.
>
> I've tested this on:
> Fedora 20 - modern glibc - works as before
> RHEL 5 - glibc 2.5:
> [dgilbert@davidgil-rhel5 try]$ ./bin/qemu-system-x86_64 -nographic -name debug-threads=on
> qemu: thread naming not supported on this host
>
> and checked a mingw windows cross build builds.
>
> A check on SLES11 is probably worth a try if someone has one to hand.
>
> Dr. David Alan Gilbert (1):
> Detect pthread_setname_np at configure time
>
> configure | 28 ++++++++++++++++++++++++++++
> util/qemu-thread-posix.c | 21 ++++++++++++++++++---
> util/qemu-thread-win32.c | 2 ++
> 3 files changed, 48 insertions(+), 3 deletions(-)
>
> --
> 1.8.5.3
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 0/1] configure time fix for thread naming on old glibc
2014-03-12 11:48 [Qemu-devel] [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert (git)
2014-03-12 11:48 ` [Qemu-devel] [PATCH 1/1] Detect pthread_setname_np at configure time Dr. David Alan Gilbert (git)
2014-03-26 17:51 ` [Qemu-devel] Ping: [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert
@ 2014-03-27 7:20 ` Michael S. Tsirkin
2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2014-03-27 7:20 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git); +Cc: peter.maydell, qemu-devel, jan.kiszka
On Wed, Mar 12, 2014 at 11:48:17AM +0000, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Peter was preferring configure time detection of pthread_setname_np
> to guard against my recent breaking of builds on old libc.
>
> I've tested this on:
> Fedora 20 - modern glibc - works as before
> RHEL 5 - glibc 2.5:
> [dgilbert@davidgil-rhel5 try]$ ./bin/qemu-system-x86_64 -nographic -name debug-threads=on
> qemu: thread naming not supported on this host
>
> and checked a mingw windows cross build builds.
>
> A check on SLES11 is probably worth a try if someone has one to hand.
I've applied this for 2.0, thanks!
> Dr. David Alan Gilbert (1):
> Detect pthread_setname_np at configure time
>
> configure | 28 ++++++++++++++++++++++++++++
> util/qemu-thread-posix.c | 21 ++++++++++++++++++---
> util/qemu-thread-win32.c | 2 ++
> 3 files changed, 48 insertions(+), 3 deletions(-)
>
> --
> 1.8.5.3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-27 8:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12 11:48 [Qemu-devel] [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert (git)
2014-03-12 11:48 ` [Qemu-devel] [PATCH 1/1] Detect pthread_setname_np at configure time Dr. David Alan Gilbert (git)
2014-03-26 17:51 ` [Qemu-devel] Ping: [PATCH 0/1] configure time fix for thread naming on old glibc Dr. David Alan Gilbert
2014-03-27 7:20 ` [Qemu-devel] " Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).