From nobody Fri Nov 7 23:11:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548812122648435.36743708499216; Tue, 29 Jan 2019 17:35:22 -0800 (PST) Received: from localhost ([127.0.0.1]:58444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goema-0004vh-L0 for importer@patchew.org; Tue, 29 Jan 2019 20:35:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goe44-0000Lm-0P for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:49:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goe43-0001Ys-3Q for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:49:15 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:37817) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goe42-0001E5-Qc for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:49:14 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6FE7A221DB; Tue, 29 Jan 2019 19:48:29 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 29 Jan 2019 19:48:29 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 17CCCE4559; Tue, 29 Jan 2019 19:48:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=HU4DBq1euOkxKqvmpnJ7nOAGXl/VDj/0ofGJKtJp3XQ=; b=cscdr 0VU00K2iUHryd3CSM2Im6tmaxpsgrgG7HndzS5Z3ZgufP/QJeotA8D89TuzB0imB Lfil2aSrG0LwrBFBOZ8ZFZHNr+eqT/l3HyUNbydJxbo2sP9xMLFmT7q8zA1VsGYx +k5yQIiZJqBa2F1OPzj0eKNfJ3XrOGWDezxfu0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=HU4DBq1euOkxKqvmpnJ7nOAGXl/VD j/0ofGJKtJp3XQ=; b=fRikTpOZulkAnOGhzQeVUgNm2kKlHzkTNlHPf2o/VZv8U BXwB24caWEnK5dkWz6AkbRY9YW9qMPpk4QMf0ykvv6LAQlFmmHwMWnhq9hqoc69q l23ec8Zpc7BWeyG5osjEizQ30sMnOS8bSnC6GqCpr0ORmN8KaShJTCYH2O87sgXy lrjD4IXCcLt3qd6Xmr5E6zY9FZJl60rUzfU5AVNzh4/AqkGHZe4NZ04a5c6Aa0K/ JjoqbnuNM/GhhWQyPGa0ugdNbVWoGNdbQ4CxSEgI05T/7dOuADlXPkbxIcHOB2Z0 x7CHC9HnLowT5rrrAM6kU8pv1sWkKM3S/yjFI/9MQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrjeefgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojg hfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcuoegt ohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeinecurf grrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhushht vghrufhiiigvpeduje X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 19:47:59 -0500 Message-Id: <20190130004811.27372-62-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190130004811.27372-1-cota@braap.org> References: <20190130004811.27372-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v6 61/73] cpu: call .cpu_has_work with the CPU lock held 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: Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/qom/cpu.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 4a87c1fef7..96a5d0cb94 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -85,7 +85,8 @@ struct TranslationBlock; * @parse_features: Callback to parse command line arguments. * @reset: Callback to reset the #CPUState to its initial state. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. - * @has_work: Callback for checking if there is work to do. + * @has_work: Callback for checking if there is work to do. Called with the + * CPU lock held. * @do_interrupt: Callback for interrupt handling. * @do_unassigned_access: Callback for unassigned access handling. * (this is deprecated: new targets should use do_transaction_failed inste= ad) @@ -795,9 +796,16 @@ const char *parse_cpu_model(const char *cpu_model); static inline bool cpu_has_work(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); + bool ret; =20 g_assert(cc->has_work); - return cc->has_work(cpu); + if (cpu_mutex_locked(cpu)) { + return cc->has_work(cpu); + } + cpu_mutex_lock(cpu); + ret =3D cc->has_work(cpu); + cpu_mutex_unlock(cpu); + return ret; } =20 /** --=20 2.17.1