qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, "Stefan Weil" <sw@weilnetz.de>,
	qemu-block@nongnu.org,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v2 05/14] audio: make jackaudio use qemu_thread_set_name
Date: Sat, 30 Aug 2025 23:12:29 +0000	[thread overview]
Message-ID: <aLOFXb18pV85FPq7@gallifrey> (raw)
In-Reply-To: <20250829180354.2922145-6-berrange@redhat.com>

* Daniel P. Berrangé (berrange@redhat.com) wrote:
> This has greater portability than directly call pthread_setname_np,
> which is only 1 out of 3 possible functions for pthreads that can
> set the name.
> 
> The new API requires a trampoline function, since it can only set
> the name of the current thread.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>

> ---
>  audio/jackaudio.c | 28 +++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/audio/jackaudio.c b/audio/jackaudio.c
> index 974a3caad3..48ffbf735f 100644
> --- a/audio/jackaudio.c
> +++ b/audio/jackaudio.c
> @@ -629,18 +629,36 @@ static void qjack_enable_in(HWVoiceIn *hw, bool enable)
>      ji->c.enabled = enable;
>  }
>  
> -#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID)
> +#if !defined(WIN32)
> +struct QJackThreadData {
> +    void *(*function)(void *);
> +    void *arg;
> +};
> +
> +static void *qjack_thread_trampoline(void *targ)
> +{
> +    struct QJackThreadData *data = targ;
> +    void *(*function)(void *) = data->function;
> +    void *arg = data->arg;
> +
> +    g_free(data);
> +    qemu_thread_set_name("jack-client");
> +
> +    return function(arg);
> +}
> +
>  static int qjack_thread_creator(jack_native_thread_t *thread,
>      const pthread_attr_t *attr, void *(*function)(void *), void *arg)
>  {
> -    int ret = pthread_create(thread, attr, function, arg);
> +    struct QJackThreadData *data = g_new0(struct QJackThreadData, 1);
> +    data->function = function;
> +    data->arg = arg;
> +    int ret = pthread_create(thread, attr, qjack_thread_trampoline, data);
>      if (ret != 0) {
> +        g_free(data);
>          return ret;
>      }
>  
> -    /* set the name of the thread */
> -    pthread_setname_np(*thread, "jack-client");
> -
>      return ret;
>  }
>  #endif
> -- 
> 2.50.1
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/


  parent reply	other threads:[~2025-08-30 23:13 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 18:03 [PATCH v2 00/14] util: sync error_report & qemu_log output more closely Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 01/14] include: define constant for early constructor priority Daniel P. Berrangé
2025-08-30 21:56   ` Richard Henderson
2025-08-30 22:56   ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 02/14] monitor: initialize global data from a constructor Daniel P. Berrangé
2025-08-30 21:57   ` Richard Henderson
2025-08-30 23:00   ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 03/14] system: unconditionally enable thread naming Daniel P. Berrangé
2025-08-30 21:59   ` Richard Henderson
2025-09-11 11:59   ` Ján Tomko
2025-08-29 18:03 ` [PATCH v2 04/14] util: expose qemu_thread_set_name Daniel P. Berrangé
2025-08-30 22:01   ` Richard Henderson
2025-08-30 23:02   ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 05/14] audio: make jackaudio use qemu_thread_set_name Daniel P. Berrangé
2025-08-30 22:05   ` Richard Henderson
2025-08-30 23:12   ` Dr. David Alan Gilbert [this message]
2025-08-29 18:03 ` [PATCH v2 06/14] util: set the name for the 'main' thread Daniel P. Berrangé
2025-08-30 22:06   ` Richard Henderson
2025-08-30 23:26   ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 07/14] util: add API to fetch the current thread name Daniel P. Berrangé
2025-08-30 22:14   ` Richard Henderson
2025-09-01  8:49     ` Daniel P. Berrangé
2025-09-02 10:19       ` Richard Henderson
2025-08-29 18:03 ` [PATCH v2 08/14] log: avoid prefix on split qemu_log calls Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 09/14] util: introduce common helper for error-report & log code Daniel P. Berrangé
2025-09-02 10:22   ` Richard Henderson
2025-08-29 18:03 ` [PATCH v2 10/14] util: convert error-report & log to message API for timestamp Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 11/14] util: add support for formatting a workload name in messages Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 12/14] util: add support for formatting a program " Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 13/14] util: add support for formatting thread info " Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 14/14] util: add brackets around guest name in message context Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aLOFXb18pV85FPq7@gallifrey \
    --to=dave@treblig.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).