From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4754C433F5 for ; Thu, 7 Oct 2021 20:52:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 653BD61040 for ; Thu, 7 Oct 2021 20:52:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 653BD61040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:54002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYaNW-0005ak-CJ for qemu-devel@archiver.kernel.org; Thu, 07 Oct 2021 16:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYaDH-0005ED-4J for qemu-devel@nongnu.org; Thu, 07 Oct 2021 16:41:59 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:34564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYaDE-0005wu-KP for qemu-devel@nongnu.org; Thu, 07 Oct 2021 16:41:58 -0400 Received: by mail-wr1-x429.google.com with SMTP id t8so23024210wri.1 for ; Thu, 07 Oct 2021 13:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YRLoPh/Xbstgr2dVENWUhURrCQrnaxnHz/xSyxqHSHE=; b=H+LgYc5jYke5TS9dp/F6jumz9oasghGouTAT6sFJFZ7czosYr3JNja43vyC+k+VByA czr0rcrTBkeqF5PZGqYsHecJ7IjhHzpnaY0Sf+pwxmxqlgFmYFbTNwR+gKj7gUHxNsd0 kwFQunABgKiKZVmWJKCdA69SQaFOF6n57yLaV7UvjcGHPUs2orqKMVxKv4H44e8nRld+ Rl/7J9XSbgxv0AxTz5amovUNnpdx9swPZgyTzmFsBuwyVlQ4G0oAFuCH0sCLyXY+mYER BPbmKgq5dbyVxJ5OMnFepd/R0etT2McsZYY9qbgSX5U32DXDCfc07erLTKgFY9rwlCVX RCPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YRLoPh/Xbstgr2dVENWUhURrCQrnaxnHz/xSyxqHSHE=; b=oPWYgzhWFyXKl7KbVYkLjdXA6gHKZBi0Q8OyCGtOlUiWX3ynpbmcPk6EYpvu6WnynF V/V3jGpnNylhlipvHih2erxEDAMqDnOWsjwl9En+qlyVpkvEacbHt1h4p3v/tAIbKfME pSrmU5jM60zVCjDg2+x7zKw+v7qwR9zjJocGio3pJYLpx0LuIU5zswthI1L1WJoJ5qGJ LAEFtJ79yBbuNA/IlaqRpixtbcY06sHf9VMaCmVNGuQ3WrJmZJXjsMH4NgUVVxkGVQE+ nglOYbd3VbukBKKKqXjQRP/xLUiz+VVexjC7shFLu6tfbowN4+r0+qEftEEypl1y0qBi g5gQ== X-Gm-Message-State: AOAM533b8BY3DAvmto+uZap+MVW7Lsj19JbxYbArON7wxX7dYjAxDzcV oYrtDLgSHhwenxhyPtO5wNhG8jezK+tLVDmaBsw= X-Google-Smtp-Source: ABdhPJzUPjdef5GFfqfTU5+L0YxxBU45UdYKatP6dZ76dRbN4ZEIoZYJyE3gcHQUyPOfgDh/XLBGKt7J3STIwgNusmU= X-Received: by 2002:a5d:47a4:: with SMTP id 4mr8437238wrb.374.1633639315312; Thu, 07 Oct 2021 13:41:55 -0700 (PDT) MIME-Version: 1.0 References: <20211007130630.632028-1-pbonzini@redhat.com> <20211007130829.632254-9-pbonzini@redhat.com> In-Reply-To: <20211007130829.632254-9-pbonzini@redhat.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 8 Oct 2021 00:41:40 +0400 Message-ID: Subject: Re: [PATCH 14/24] configure, meson: move pthread_setname_np checks to Meson To: Paolo Bonzini Content-Type: multipart/alternative; boundary="00000000000014932d05cdc94bea" Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=marcandre.lureau@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000014932d05cdc94bea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Oct 7, 2021 at 5:19 PM Paolo Bonzini wrote: > This makes the pthreads check dead in configure, so remove it > as well. > > Signed-off-by: Paolo Bonzini > Reviewed-by: Marc-Andr=C3=A9 Lureau (a shame that g_system_thread_set_name() is not exported imho) --- > configure | 78 ---------------------------------------- > meson.build | 23 ++++++++++++ > util/qemu-thread-posix.c | 5 ++- > 3 files changed, 25 insertions(+), 81 deletions(-) > > diff --git a/configure b/configure > index 52f89b05d6..a1e142d5f8 100755 > --- a/configure > +++ b/configure > @@ -3146,71 +3146,6 @@ if test "$modules" =3D yes; then > fi > fi > > -########################################## > -# pthread probe > -PTHREADLIBS_LIST=3D"-pthread -lpthread -lpthreadGC2" > - > -pthread=3Dno > -cat > $TMPC << EOF > -#include > -static void *f(void *p) { return NULL; } > -int main(void) { > - pthread_t thread; > - pthread_create(&thread, 0, f, 0); > - return 0; > -} > -EOF > -if compile_prog "" "" ; then > - pthread=3Dyes > -else > - for pthread_lib in $PTHREADLIBS_LIST; do > - if compile_prog "" "$pthread_lib" ; then > - pthread=3Dyes > - break > - fi > - done > -fi > - > -if test "$mingw32" !=3D yes && test "$pthread" =3D no; then > - error_exit "pthread check failed" \ > - "Make sure to have the pthread libs and headers installed." > -fi > - > -# check for pthread_setname_np with thread id > -pthread_setname_np_w_tid=3Dno > -cat > $TMPC << EOF > -#include > - > -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_w_tid=3Dyes > -fi > - > -# check for pthread_setname_np without thread id > -pthread_setname_np_wo_tid=3Dno > -cat > $TMPC << EOF > -#include > - > -static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; } > -int main(void) > -{ > - pthread_t thread; > - pthread_create(&thread, 0, f, 0); > - return 0; > -} > -EOF > -if compile_prog "" "$pthread_lib" ; then > - pthread_setname_np_wo_tid=3Dyes > -fi > - > ########################################## > # libssh probe > if test "$libssh" !=3D "no" ; then > @@ -4496,19 +4431,6 @@ if test "$debug_mutex" =3D "yes" ; then > echo "CONFIG_DEBUG_MUTEX=3Dy" >> $config_host_mak > fi > > -# Hold two types of flag: > -# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the nam= e > on > -# a thread we have a handle to > -# CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular > -# platform > -if test "$pthread_setname_np_w_tid" =3D "yes" ; then > - echo "CONFIG_THREAD_SETNAME_BYTHREAD=3Dy" >> $config_host_mak > - echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=3Dy" >> $config_host_mak > -elif test "$pthread_setname_np_wo_tid" =3D "yes" ; then > - echo "CONFIG_THREAD_SETNAME_BYTHREAD=3Dy" >> $config_host_mak > - echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=3Dy" >> $config_host_mak > -fi > - > if test "$bochs" =3D "yes" ; then > echo "CONFIG_BOCHS=3Dy" >> $config_host_mak > fi > diff --git a/meson.build b/meson.build > index 935a20c198..54b2afdb96 100644 > --- a/meson.build > +++ b/meson.build > @@ -1586,6 +1586,29 @@ config_host_data.set('CONFIG_POSIX_MADVISE', > cc.links(gnu_source_prefix + ''' > #include > #include > int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); > }''')) > + > +config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(''' > + #include > + > + 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; > + }''', dependencies: threads)) > +config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(''' > + #include > + > + static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; } > + int main(void) > + { > + pthread_t thread; > + pthread_create(&thread, 0, f, 0); > + return 0; > + }''', dependencies: threads)) > + > config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + ''' > #include > #include > diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c > index 6c5004220d..e1225b63bd 100644 > --- a/util/qemu-thread-posix.c > +++ b/util/qemu-thread-posix.c > @@ -23,7 +23,8 @@ void qemu_thread_naming(bool enable) > { > name_threads =3D enable; > > -#ifndef CONFIG_THREAD_SETNAME_BYTHREAD > +#if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \ > + !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID > /* This is a debugging option, not fatal */ > if (enable) { > fprintf(stderr, "qemu: thread naming not supported on this > host\n"); > @@ -522,7 +523,6 @@ static void *qemu_thread_start(void *args) > void *arg =3D qemu_thread_args->arg; > void *r; > > -#ifdef CONFIG_THREAD_SETNAME_BYTHREAD > /* 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. > */ > @@ -533,7 +533,6 @@ static void *qemu_thread_start(void *args) > pthread_setname_np(qemu_thread_args->name); > # endif > } > -#endif > QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name); > g_free(qemu_thread_args->name); > g_free(qemu_thread_args); > -- > 2.31.1 > > > > --=20 Marc-Andr=C3=A9 Lureau --00000000000014932d05cdc94bea Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Oct 7, 2021 at 5:19 PM Paolo = Bonzini <pbonzi= ni@redhat.com> wrote:
This makes the pthreads check dead in configure, so remove it<= br> as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

<= div>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com><= /div>

(a shame that g_system_thread_set_name() is not ex= ported imho)

---
=C2=A0configure=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 78= ----------------------------------------
=C2=A0meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 23 ++++= ++++++++
=C2=A0util/qemu-thread-posix.c |=C2=A0 5 ++-
=C2=A03 files changed, 25 insertions(+), 81 deletions(-)

diff --git a/configure b/configure
index 52f89b05d6..a1e142d5f8 100755
--- a/configure
+++ b/configure
@@ -3146,71 +3146,6 @@ if test "$modules" =3D yes; then
=C2=A0 =C2=A0 =C2=A0fi
=C2=A0fi

-##########################################
-# pthread probe
-PTHREADLIBS_LIST=3D"-pthread -lpthread -lpthreadGC2"
-
-pthread=3Dno
-cat > $TMPC << EOF
-#include <pthread.h>
-static void *f(void *p) { return NULL; }
-int main(void) {
-=C2=A0 pthread_t thread;
-=C2=A0 pthread_create(&thread, 0, f, 0);
-=C2=A0 return 0;
-}
-EOF
-if compile_prog "" "" ; then
-=C2=A0 pthread=3Dyes
-else
-=C2=A0 for pthread_lib in $PTHREADLIBS_LIST; do
-=C2=A0 =C2=A0 if compile_prog "" "$pthread_lib" ; then=
-=C2=A0 =C2=A0 =C2=A0 pthread=3Dyes
-=C2=A0 =C2=A0 =C2=A0 break
-=C2=A0 =C2=A0 fi
-=C2=A0 done
-fi
-
-if test "$mingw32" !=3D yes && test "$pthread"= =3D no; then
-=C2=A0 error_exit "pthread check failed" \
-=C2=A0 =C2=A0 =C2=A0 "Make sure to have the pthread libs and headers = installed."
-fi
-
-# check for pthread_setname_np with thread id
-pthread_setname_np_w_tid=3Dno
-cat > $TMPC << EOF
-#include <pthread.h>
-
-static void *f(void *p) { return NULL; }
-int main(void)
-{
-=C2=A0 =C2=A0 pthread_t thread;
-=C2=A0 =C2=A0 pthread_create(&thread, 0, f, 0);
-=C2=A0 =C2=A0 pthread_setname_np(thread, "QEMU");
-=C2=A0 =C2=A0 return 0;
-}
-EOF
-if compile_prog "" "$pthread_lib" ; then
-=C2=A0 pthread_setname_np_w_tid=3Dyes
-fi
-
-# check for pthread_setname_np without thread id
-pthread_setname_np_wo_tid=3Dno
-cat > $TMPC << EOF
-#include <pthread.h>
-
-static void *f(void *p) { pthread_setname_np("QEMU"); return NUL= L; }
-int main(void)
-{
-=C2=A0 =C2=A0 pthread_t thread;
-=C2=A0 =C2=A0 pthread_create(&thread, 0, f, 0);
-=C2=A0 =C2=A0 return 0;
-}
-EOF
-if compile_prog "" "$pthread_lib" ; then
-=C2=A0 pthread_setname_np_wo_tid=3Dyes
-fi
-
=C2=A0##########################################
=C2=A0# libssh probe
=C2=A0if test "$libssh" !=3D "no" ; then
@@ -4496,19 +4431,6 @@ if test "$debug_mutex" =3D "yes"= ; then
=C2=A0 =C2=A0echo "CONFIG_DEBUG_MUTEX=3Dy" >> $config_host_= mak
=C2=A0fi

-# Hold two types of flag:
-#=C2=A0 =C2=A0CONFIG_THREAD_SETNAME_BYTHREAD=C2=A0 - we've got a way o= f setting the name on
-#=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0a thread we have= a handle to
-#=C2=A0 =C2=A0CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a par= ticular
-#=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0platform
-if test "$pthread_setname_np_w_tid" =3D "yes" ; then -=C2=A0 echo "CONFIG_THREAD_SETNAME_BYTHREAD=3Dy" >> $confi= g_host_mak
-=C2=A0 echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=3Dy" >> $conf= ig_host_mak
-elif test "$pthread_setname_np_wo_tid" =3D "yes" ; the= n
-=C2=A0 echo "CONFIG_THREAD_SETNAME_BYTHREAD=3Dy" >> $confi= g_host_mak
-=C2=A0 echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=3Dy" >> $con= fig_host_mak
-fi
-
=C2=A0if test "$bochs" =3D "yes" ; then
=C2=A0 =C2=A0echo "CONFIG_BOCHS=3Dy" >> $config_host_mak =C2=A0fi
diff --git a/meson.build b/meson.build
index 935a20c198..54b2afdb96 100644
--- a/meson.build
+++ b/meson.build
@@ -1586,6 +1586,29 @@ config_host_data.set('CONFIG_POSIX_MADVISE',= cc.links(gnu_source_prefix + '''
=C2=A0 =C2=A0#include <sys/mman.h>
=C2=A0 =C2=A0#include <stddef.h>
=C2=A0 =C2=A0int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONT= NEED); }'''))
+
+config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(&= #39;''
+=C2=A0 #include <pthread.h>
+
+=C2=A0 static void *f(void *p) { return NULL; }
+=C2=A0 int main(void)
+=C2=A0 {
+=C2=A0 =C2=A0 pthread_t thread;
+=C2=A0 =C2=A0 pthread_create(&thread, 0, f, 0);
+=C2=A0 =C2=A0 pthread_setname_np(thread, "QEMU");
+=C2=A0 =C2=A0 return 0;
+=C2=A0 }''', dependencies: threads))
+config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(= '''
+=C2=A0 #include <pthread.h>
+
+=C2=A0 static void *f(void *p) { pthread_setname_np("QEMU"); ret= urn NULL; }
+=C2=A0 int main(void)
+=C2=A0 {
+=C2=A0 =C2=A0 pthread_t thread;
+=C2=A0 =C2=A0 pthread_create(&thread, 0, f, 0);
+=C2=A0 =C2=A0 return 0;
+=C2=A0 }''', dependencies: threads))
+
=C2=A0config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_p= refix + '''
=C2=A0 =C2=A0#include <unistd.h>
=C2=A0 =C2=A0#include <sys/syscall.h>
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 6c5004220d..e1225b63bd 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -23,7 +23,8 @@ void qemu_thread_naming(bool enable)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0name_threads =3D enable;

-#ifndef CONFIG_THREAD_SETNAME_BYTHREAD
+#if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \
+=C2=A0 =C2=A0 !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID
=C2=A0 =C2=A0 =C2=A0/* This is a debugging option, not fatal */
=C2=A0 =C2=A0 =C2=A0if (enable) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf(stderr, "qemu: thread naming= not supported on this host\n");
@@ -522,7 +523,6 @@ static void *qemu_thread_start(void *args)
=C2=A0 =C2=A0 =C2=A0void *arg =3D qemu_thread_args->arg;
=C2=A0 =C2=A0 =C2=A0void *r;

-#ifdef CONFIG_THREAD_SETNAME_BYTHREAD
=C2=A0 =C2=A0 =C2=A0/* Attempt to set the threads name; note that this is f= or debug, so
=C2=A0 =C2=A0 =C2=A0 * we're not going to fail if we can't set it.<= br> =C2=A0 =C2=A0 =C2=A0 */
@@ -533,7 +533,6 @@ static void *qemu_thread_start(void *args)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pthread_setname_np(qemu_thread_args->n= ame);
=C2=A0# endif
=C2=A0 =C2=A0 =C2=A0}
-#endif
=C2=A0 =C2=A0 =C2=A0QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->nam= e);
=C2=A0 =C2=A0 =C2=A0g_free(qemu_thread_args->name);
=C2=A0 =C2=A0 =C2=A0g_free(qemu_thread_args);
--
2.31.1





--
Marc-Andr= =C3=A9 Lureau
--00000000000014932d05cdc94bea--