From nobody Thu Oct 30 15:33:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152581874084942.66001016059897; Tue, 8 May 2018 15:32:20 -0700 (PDT) Received: from localhost ([::1]:53604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGB9g-0001xE-4H for importer@patchew.org; Tue, 08 May 2018 18:32:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGAt0-0002yW-6Y for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGAsz-0001NV-2x for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:06 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGAsy-0001NB-Ss for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:05 -0400 Received: by mail-wm0-x244.google.com with SMTP id a137-v6so20817234wme.1 for ; Tue, 08 May 2018 15:15:04 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-189-60.clienti.tiscali.it. [78.12.189.60]) by smtp.gmail.com with ESMTPSA id c15-v6sm14020129edr.78.2018.05.08.15.15.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 15:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=N59Qz5fEql8DYRahVBdKDJGltPSXxzdf/HZI/wHBY1g=; b=NCb/OZbz08BcBJNrAxGxVg/ZKhKhOqg9n2YaTzqHPjesnnhIjVL4BUc89hDQ+qGxer QZZyFRRVpAiXwdOGKn+HuxVNa3g+DVdV+LoDMxBYI8PbKeOFctPbk9bKoN6a3FxQPx+k /PK3VdP5HmiLzJu/whylE/NRi2Ye8G9NqhSIGX5OBXCXSqJVJrATxdrW9YXdYJypGthM w7inlTi97Ar1KnDgaDvXJkMaZN6i/mvXGsTsQA+eR5flzoiOOu5zXtJ+wh88AK5DSUap DJojqiJKZfgY+BQZ5ul84E0JVqB+rWjVJ1MJw4Zoj6AvYsgAJmFFcrcSfVw1DYNerlTe S77w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=N59Qz5fEql8DYRahVBdKDJGltPSXxzdf/HZI/wHBY1g=; b=lEFI5nBxPwW4ooVCJpYx2pbIFqqLtOh3/f1uShdhc8SttAVP0swIJ8yD9JoekqO9aK b20bzgI6W9zo/xeHdGN1c2QCp3tdLVv8psUA7JkyUyOdqIwhZvVf2ydStKYFSNvKFJPd IuTaKIM1lZfaVVDtG+8QEpqJUje1PWW3diNGPSSKqsecAHZ3IJa9+7T9fvU1VvRFhO/l CvDwl2wo7eErZjSs/2ZQ23An4swVRXEAOni5NWDwFzpVm6BsO1T4YU9lHoOStUNqttWl Vh5DkW+F/W1YzOa/7O1Lh2ALlv4zoxsprs6cS1z33uDQwjdoTEtVEiMNPTHO3LyEsPu5 RP2g== X-Gm-Message-State: ALQs6tDtpmor7SkilcA240VwufSbrjGOp3LaznWosrhwt+iQk13bCuey m/0YXjjfmCkWh+iwkG2enUoIcPVs X-Google-Smtp-Source: AB8JxZoue0xqjIiwkv2POT26leglqhAtigPA8ZyafwkMirBTyjxTZ0sIez/KkxF0HLU+Nv2EHI+jDQ== X-Received: by 2002:a50:951d:: with SMTP id u29-v6mr57592695eda.268.1525817703609; Tue, 08 May 2018 15:15:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 00:14:28 +0200 Message-Id: <1525817687-34620-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525817687-34620-1-git-send-email-pbonzini@redhat.com> References: <1525817687-34620-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 11/30] qemu-thread: always keep the posix wrapper layer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu 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 Message-Id: <20180412053444.17801-1-peterx@redhat.com> Reviewed-by: Fam Zheng Signed-off-by: Paolo Bonzini --- 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_at= exit_init(void) } =20 =20 -#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 *) =3D qemu_thread_args->start_routine; void *arg =3D qemu_thread_args->arg; =20 +#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 - =20 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; =20 err =3D pthread_attr_init(&attr); if (err) { @@ -527,22 +529,13 @@ void qemu_thread_create(QemuThread *thread, const cha= r *name, sigfillset(&set); pthread_sigmask(SIG_SETMASK, &set, &oldset); =20 -#ifdef CONFIG_PTHREAD_SETNAME_NP - if (name_threads) { - QemuThreadArgs *qemu_thread_args; - qemu_thread_args =3D g_new0(QemuThreadArgs, 1); - qemu_thread_args->name =3D g_strdup(name); - qemu_thread_args->start_routine =3D start_routine; - qemu_thread_args->arg =3D arg; - - err =3D pthread_create(&thread->thread, &attr, - qemu_thread_start, qemu_thread_args); - } else -#endif - { - err =3D pthread_create(&thread->thread, &attr, - start_routine, arg); - } + qemu_thread_args =3D g_new0(QemuThreadArgs, 1); + qemu_thread_args->name =3D g_strdup(name); + qemu_thread_args->start_routine =3D start_routine; + qemu_thread_args->arg =3D arg; + + err =3D pthread_create(&thread->thread, &attr, + qemu_thread_start, qemu_thread_args); =20 if (err) error_exit(err, __func__); --=20 1.8.3.1