* [PATCH] thread-posix: add support for setting threads name on OpenBSD
@ 2022-12-18 8:22 Brad Smith
2022-12-18 17:07 ` Richard Henderson
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Brad Smith @ 2022-12-18 8:22 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
Make use of pthread_set_name_np() to be able to set the threads name
on OpenBSD.
Signed-off-by: Brad Smith <brad@comstyle.com>
---
meson.build | 12 ++++++++++++
util/qemu-thread-posix.c | 9 ++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 5c6b5a1c75..68adcb6291 100644
--- a/meson.build
+++ b/meson.build
@@ -2123,6 +2123,18 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_pre
pthread_create(&thread, 0, f, 0);
return 0;
}''', dependencies: threads))
+config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + '''
+ #include <pthread.h>
+ #include <pthread_np.h>
+
+ static void *f(void *p) { return NULL; }
+ int main(void)
+ {
+ pthread_t thread;
+ pthread_create(&thread, 0, f, 0);
+ pthread_set_name_np(thread, "QEMU");
+ return 0;
+ }''', dependencies: threads))
config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + '''
#include <pthread.h>
#include <time.h>
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index bae938c670..412caa45ef 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -18,6 +18,10 @@
#include "qemu/tsan.h"
#include "qemu/bitmap.h"
+#ifdef CONFIG_PTHREAD_SET_NAME_NP
+#include <pthread_np.h>
+#endif
+
static bool name_threads;
void qemu_thread_naming(bool enable)
@@ -25,7 +29,8 @@ void qemu_thread_naming(bool enable)
name_threads = enable;
#if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \
- !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID
+ !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID && \
+ !defined CONFIG_PTHREAD_SET_NAME_NP
/* This is a debugging option, not fatal */
if (enable) {
fprintf(stderr, "qemu: thread naming not supported on this host\n");
@@ -480,6 +485,8 @@ static void *qemu_thread_start(void *args)
pthread_setname_np(pthread_self(), qemu_thread_args->name);
# elif defined(CONFIG_PTHREAD_SETNAME_NP_WO_TID)
pthread_setname_np(qemu_thread_args->name);
+# elif defined(CONFIG_PTHREAD_SET_NAME_NP)
+ pthread_set_name_np(pthread_self(), qemu_thread_args->name);
# endif
}
QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name);
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] thread-posix: add support for setting threads name on OpenBSD
2022-12-18 8:22 [PATCH] thread-posix: add support for setting threads name on OpenBSD Brad Smith
@ 2022-12-18 17:07 ` Richard Henderson
2022-12-19 20:59 ` Philippe Mathieu-Daudé
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2022-12-18 17:07 UTC (permalink / raw)
To: Brad Smith, Paolo Bonzini; +Cc: qemu-devel
On 12/18/22 00:22, Brad Smith wrote:
> Make use of pthread_set_name_np() to be able to set the threads name
> on OpenBSD.
>
> Signed-off-by: Brad Smith<brad@comstyle.com>
> ---
> meson.build | 12 ++++++++++++
> util/qemu-thread-posix.c | 9 ++++++++-
> 2 files changed, 20 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thread-posix: add support for setting threads name on OpenBSD
2022-12-18 8:22 [PATCH] thread-posix: add support for setting threads name on OpenBSD Brad Smith
2022-12-18 17:07 ` Richard Henderson
@ 2022-12-19 20:59 ` Philippe Mathieu-Daudé
2023-02-17 2:48 ` Brad Smith
2023-02-17 8:56 ` Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-19 20:59 UTC (permalink / raw)
To: Brad Smith, Paolo Bonzini; +Cc: qemu-devel
On 18/12/22 09:22, Brad Smith wrote:
> Make use of pthread_set_name_np() to be able to set the threads name
> on OpenBSD.
>
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
> meson.build | 12 ++++++++++++
> util/qemu-thread-posix.c | 9 ++++++++-
> 2 files changed, 20 insertions(+), 1 deletion(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thread-posix: add support for setting threads name on OpenBSD
2022-12-18 8:22 [PATCH] thread-posix: add support for setting threads name on OpenBSD Brad Smith
2022-12-18 17:07 ` Richard Henderson
2022-12-19 20:59 ` Philippe Mathieu-Daudé
@ 2023-02-17 2:48 ` Brad Smith
2023-02-17 8:56 ` Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Brad Smith @ 2023-02-17 2:48 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
ping.
On 2022-12-18 3:22 a.m., Brad Smith wrote:
> Make use of pthread_set_name_np() to be able to set the threads name
> on OpenBSD.
>
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
> meson.build | 12 ++++++++++++
> util/qemu-thread-posix.c | 9 ++++++++-
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/meson.build b/meson.build
> index 5c6b5a1c75..68adcb6291 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2123,6 +2123,18 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_pre
> pthread_create(&thread, 0, f, 0);
> return 0;
> }''', dependencies: threads))
> +config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + '''
> + #include <pthread.h>
> + #include <pthread_np.h>
> +
> + static void *f(void *p) { return NULL; }
> + int main(void)
> + {
> + pthread_t thread;
> + pthread_create(&thread, 0, f, 0);
> + pthread_set_name_np(thread, "QEMU");
> + return 0;
> + }''', dependencies: threads))
> config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + '''
> #include <pthread.h>
> #include <time.h>
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index bae938c670..412caa45ef 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -18,6 +18,10 @@
> #include "qemu/tsan.h"
> #include "qemu/bitmap.h"
>
> +#ifdef CONFIG_PTHREAD_SET_NAME_NP
> +#include <pthread_np.h>
> +#endif
> +
> static bool name_threads;
>
> void qemu_thread_naming(bool enable)
> @@ -25,7 +29,8 @@ void qemu_thread_naming(bool enable)
> name_threads = enable;
>
> #if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \
> - !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID
> + !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID && \
> + !defined CONFIG_PTHREAD_SET_NAME_NP
> /* This is a debugging option, not fatal */
> if (enable) {
> fprintf(stderr, "qemu: thread naming not supported on this host\n");
> @@ -480,6 +485,8 @@ static void *qemu_thread_start(void *args)
> pthread_setname_np(pthread_self(), qemu_thread_args->name);
> # elif defined(CONFIG_PTHREAD_SETNAME_NP_WO_TID)
> pthread_setname_np(qemu_thread_args->name);
> +# elif defined(CONFIG_PTHREAD_SET_NAME_NP)
> + pthread_set_name_np(pthread_self(), qemu_thread_args->name);
> # endif
> }
> QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thread-posix: add support for setting threads name on OpenBSD
2022-12-18 8:22 [PATCH] thread-posix: add support for setting threads name on OpenBSD Brad Smith
` (2 preceding siblings ...)
2023-02-17 2:48 ` Brad Smith
@ 2023-02-17 8:56 ` Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2023-02-17 8:56 UTC (permalink / raw)
To: Brad Smith; +Cc: qemu-devel
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-17 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-18 8:22 [PATCH] thread-posix: add support for setting threads name on OpenBSD Brad Smith
2022-12-18 17:07 ` Richard Henderson
2022-12-19 20:59 ` Philippe Mathieu-Daudé
2023-02-17 2:48 ` Brad Smith
2023-02-17 8:56 ` Paolo Bonzini
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).