From nobody Sat May 18 08:35:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666379451; cv=none; d=zohomail.com; s=zohoarc; b=aOyjwmGLXA8eCSmrr0lON0BjZn+RWu6dEnzXgd8cjl1VZAhwOpDrxy7eeDfEMTwfXOvGu0Zx1TNEJhrbkFJe/kxA014wthbciZMZwjCgR5BJ8+upte0E3ZVZagAfHDFhPw0C31WsQ61hyDcQTP7YnCJNT+8OWIrVUJAx6Rj0PUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666379451; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=0eaOA0Mqr3aYi2uDLHNW9A4jpgOCivFc5XmGZui78Jc=; b=E1jJiFrnEeHxCJc4KsdQkMPVr7/NKfYNaFtGuKNwbnRvrYzLGkLdEgCunzb4SNDCvKR/DPpI33SFcB5s3sSM3NrSWD9zHR8kqopxTz7DMo/sx0XTG3wBBNU9BtshQM/lWh7TvuAYfMhIET3SLD8X+6s0doMTtqp50NiUOc7Zj88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1666379451052138.9889546660395; Fri, 21 Oct 2022 12:10:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olxKV-0002Qd-73; Fri, 21 Oct 2022 15:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oluyQ-0000d8-EL for qemu-devel@nongnu.org; Fri, 21 Oct 2022 12:34:18 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oluyM-0003av-1N for qemu-devel@nongnu.org; Fri, 21 Oct 2022 12:34:15 -0400 Received: by mail-wr1-x42c.google.com with SMTP id f11so5372487wrm.6 for ; Fri, 21 Oct 2022 09:34:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id l15-20020a05600012cf00b002365b759b65sm100173wrx.86.2022.10.21.09.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 09:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0eaOA0Mqr3aYi2uDLHNW9A4jpgOCivFc5XmGZui78Jc=; b=Oyb4RVs+AS4PTnRpalfbULmYl8Uegg18jfdPHTL77UNCAnlmO6i3bowIqEvMXr6QOh 04hi67oet0NWpJCeUOebuB63ICIonnSt2jniDJIL1mSQ8Wsj4ckcgnvu9bDIiGznL4X6 jNaWcv4qTHo4SiinZsBbjehPsOwEo9KZbD28nr4lWwyYLrnnsQEzyonofNPAhtRUInJs 0Pn7SyPUh9JAmUyjj21rE0DsNMYm5yedgqPDh900BAYtuQfqAMVXsBTAjfcamcUemPt+ APiCW+jItflg3wFhNX9ogXhjS1tPil05/SXkS4hZXszywSD1jFrcaS/RIpF3AZN9MP4b APsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0eaOA0Mqr3aYi2uDLHNW9A4jpgOCivFc5XmGZui78Jc=; b=HYqT6dxwZZehqrFVGIAXtAVjNmDSnZOYgpsJYwRJO9LqGQwqxxf5eIOMZzGUSd1uiO S5hz7v/7rfBddXWIkvxNFGJ1ciTqsladE2EDbKEYCPTk/U8GY4fYWp3WbgFuY4t5544G xEzJvOvyruJ+TFI5j/r30SRAFe2NXMiivL/UuGqTflx/zanbF9nu18RzF9j8GoOzlNVT d1exDJHhK/t2Brhws1Ob5duYQgwYSuMmkH3eDQ1Qe0qv/tKQdDRJExc7i3dSBDjzYJDR uHE3A4QpSQ3LEXXeLDQJ8NZ8rhcQv+iLzvFyAJFXNIlaejNK0ZPAPSSl59ceJkwvvQTm 53gA== X-Gm-Message-State: ACrzQf13k5ixGlZPKMECK8ANNyoP//q8YnE26sgBnoyUK9sHmA8YBVBB r9bwhbBEv3nhay5FtBStJRYzP6AMckHmjA== X-Google-Smtp-Source: AMsMyM41MDFPCUg4zfZfTSoKQoFHgTo2gHUUXGUuO59IFfCNPb7lcQqomaGZyMt81fn2KPQKf/JD2g== X-Received: by 2002:a5d:64ab:0:b0:231:44c1:32b0 with SMTP id m11-20020a5d64ab000000b0023144c132b0mr13029089wrp.255.1666370052077; Fri, 21 Oct 2022 09:34:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org, Aaron Lindsay Subject: [PATCH] Revert "accel/tcg: Init TCG cflags in vCPU thread handler" Date: Fri, 21 Oct 2022 17:34:09 +0100 Message-Id: <20221021163409.3674911-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666379453448100001 Content-Type: text/plain; charset="utf-8" Commit a82fd5a4ec24d was intended to be a code cleanup, but unfortunately it has a bug. It moves the initialization of the TCG cflags from the "start a new vcpu" function to the thread handler; this is fine when each vcpu has its own thread, but when we are doing round-robin of vcpus on a single thread we end up only initializing the cflags for CPU 0, not for any of the others. The most obvious effect of this bug is that running in icount mode with more than one CPU is broken; typically the guest hangs shortly after it brings up the secondary CPUs. This reverts commit a82fd5a4ec24d923ff1e6da128c0fd4a74079d99. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- accel/tcg/tcg-accel-ops-mttcg.c | 5 +++-- accel/tcg/tcg-accel-ops-rr.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttc= g.c index ba997f6cfe4..d50239e0e28 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -70,8 +70,6 @@ static void *mttcg_cpu_thread_fn(void *arg) assert(tcg_enabled()); g_assert(!icount_enabled()); =20 - tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); - rcu_register_thread(); force_rcu.notifier.notify =3D mttcg_force_rcu; force_rcu.cpu =3D cpu; @@ -141,6 +139,9 @@ void mttcg_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; =20 + g_assert(tcg_enabled()); + tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1); + cpu->thread =3D g_new0(QemuThread, 1); cpu->halt_cond =3D g_malloc0(sizeof(QemuCond)); qemu_cond_init(cpu->halt_cond); diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index cc8adc23802..1a72149f0e4 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -152,9 +152,7 @@ static void *rr_cpu_thread_fn(void *arg) Notifier force_rcu; CPUState *cpu =3D arg; =20 - g_assert(tcg_enabled()); - tcg_cpu_init_cflags(cpu, false); - + assert(tcg_enabled()); rcu_register_thread(); force_rcu.notify =3D rr_force_rcu; rcu_add_force_rcu_notifier(&force_rcu); @@ -277,6 +275,9 @@ void rr_start_vcpu_thread(CPUState *cpu) static QemuCond *single_tcg_halt_cond; static QemuThread *single_tcg_cpu_thread; =20 + g_assert(tcg_enabled()); + tcg_cpu_init_cflags(cpu, false); + if (!single_tcg_cpu_thread) { cpu->thread =3D g_new0(QemuThread, 1); cpu->halt_cond =3D g_new0(QemuCond, 1); --=20 2.25.1