From patchwork Thu Dec 13 05:04:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 1012599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=braap.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=braap.org header.i=@braap.org header.b="Ii5q5h4r"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Haw1oGZm"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FjTM2XDlz9s47 for ; Thu, 13 Dec 2018 16:50:47 +1100 (AEDT) Received: from localhost ([::1]:50672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJtU-00058W-Oq for incoming@patchwork.ozlabs.org; Thu, 13 Dec 2018 00:50:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJCy-0007yo-E4 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXJCw-00028d-KA for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:48 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:57759) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXJCw-0001ov-86 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:46 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 071AD22011; Thu, 13 Dec 2018 00:05:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 13 Dec 2018 00:05:51 -0500 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=S68KGeUr0V7f/I7/aN+QNDMcPx/tu3uI+WYiiiq283E=; b=Ii5q5 h4rkLn6CeOyPzwrGnjKhb1o4GoGqmgqkel7JTuBu+oLO05K+6U2qsIu40FHUXeCb 2CzECCuHO042FSysP8TZVq+YymNip+wIQuwxM8Ygwdq2VuLV412IhwlxiuaGj3FR wMEoe9VLKgRf0Qs+Pvq6BOEfuWeKgc+pqgKdow= 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=S68KGeUr0V7f/I7/aN+QNDMcPx/tu 3uI+WYiiiq283E=; b=Haw1oGZmoLbM7KnMtxpOnP5K3gx5Kc4fP6L48C9Org9WE qf0pW/e5/eaiBBTgrEHIELcD4N6je7L9oyM3CvoVmIUfsxPinhpQP50Pbz0kkXdA 9ZV36HF4xBKNUpJxFzwEN2c8Cx2kHQoFGjE7RlsyMXHZkPCxDWce5FxUpCrNDxcH 8YSbxFgpGI7fI7/DXge09oef8TDMjqSvZ8O7AwlAx85TMQQJtZypbHn7ewpLUK3o LZv0E9hmkS0LNUCUMcGL4gy9MA3o2rfDT+4ucmjAdttH2DWySCpFpGgizD+dolTw svGinh+rbDPirQAoOqSCe72r+TVGSnGUGIc4c2TeA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehuddgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkof gjfhestddtredtredttdenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohhtrgdfuceo tghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvdduieenuc frrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecuvehluhhs thgvrhfuihiivgepke X-ME-Proxy: Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A56A910084; Thu, 13 Dec 2018 00:05:50 -0500 (EST) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 00:04:41 -0500 Message-Id: <20181213050453.9677-62-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213050453.9677-1-cota@braap.org> References: <20181213050453.9677-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v5 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 95747f5abf..8d4160689f 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -84,7 +84,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 instead) @@ -787,9 +788,16 @@ const char *parse_cpu_model(const char *cpu_model); static inline bool cpu_has_work(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); + bool ret; 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 = cc->has_work(cpu); + cpu_mutex_unlock(cpu); + return ret; } /**