From nobody Fri Nov 7 00:59:17 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544677697378820.1680834210116; Wed, 12 Dec 2018 21:08:17 -0800 (PST) Received: from localhost ([::1]:50438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJEE-0000Hu-7N for importer@patchew.org; Thu, 13 Dec 2018 00:08:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJC5-0007ER-Nz for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:05:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXJC1-0000qt-CQ for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:05:52 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:36021) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXJBv-0000ga-7M for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:05:46 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id AD15922120; Thu, 13 Dec 2018 00:05:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 13 Dec 2018 00:05:37 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 416D81045B; Thu, 13 Dec 2018 00:05:37 -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 :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=m0RsqdBcRI00mMaL2n/1cI5oOBO8vxQkDHXLWdKObTg=; b=zyaj7i4BUEWJ HykJDCDqTRGi3SIiTGXcU3CXCBW10s1hS9g2+1P1wSauNviRF3CAT6VMOtfVYjkK M9mj+3CfmAdMjBRIWz0Ce28vKqPYFGQTK3Tn99docp2AnKXwEJ9ze/a2jdwDVKj6 doqWOaf3HdnFw5ht9jrJUlUhcSWkPSc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=m0RsqdBcRI00mMaL2n/1cI5oOBO8vxQkDHXLWdKOb Tg=; b=yPuB7Qt3I3Mz+IIZB9gEZbhXYc46EtWa0ebAzPneDmG6pYMBcpzp1VrBD 3ojFzVIEEXeeDsRVep2jsI2HRAvLQBRshgPK5ekikpCWWqtqxGMJ8VA+gax2dlOa gMPxEcDVShHx5ErfMznNdYopQk2SEyenvOqFhCyWoqpq0BfacBP3ZnKdX8QzfEg5 0VccY9mppjA2w8uhkAOUiG1e/zM2DW43G5lJZh/qpVvvPbBMLohKsJG9Af2YmuZc WHRCLi3nOXm2xwq5FFhkX0FB+o7G+u06AZjNxW7aT0Yu+EE2xzT+No3QgLMFclUM ruUvCFtyFpBL4HGym1gTSwAHgs2kQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehuddgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkof gjfhggtgfgsehtkeertdertdejnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgr fdcuoegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvud einecurfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucev lhhushhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 00:03:42 -0500 Message-Id: <20181213050453.9677-3-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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 02/73] cpu: rename cpu->work_mutex to cpu->lock 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=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This lock will soon protect more fields of the struct. Give it a more appropriate name. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- include/qom/cpu.h | 5 +++-- cpus-common.c | 14 +++++++------- cpus.c | 4 ++-- qom/cpu.c | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 10a408c999..86ce773388 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -315,7 +315,7 @@ struct qemu_work_item; * @mem_io_pc: Host Program Counter at which the memory was accessed. * @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. - * @work_mutex: Lock to prevent multiple access to @work_list. + * @lock: Lock to prevent multiple access to per-CPU fields. * @work_list: List of pending asynchronous work. * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all ch= anges * to @trace_dstate). @@ -356,7 +356,8 @@ struct CPUState { int64_t icount_extra; sigjmp_buf jmp_env; =20 - QemuMutex work_mutex; + QemuMutex lock; + /* fields below protected by @lock */ QSIMPLEQ_HEAD(, qemu_work_item) work_list; =20 CPUAddressSpace *cpu_ases; diff --git a/cpus-common.c b/cpus-common.c index a2a6cd93a1..2913294cb7 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -115,10 +115,10 @@ struct qemu_work_item { =20 static void queue_work_on_cpu(CPUState *cpu, struct qemu_work_item *wi) { - qemu_mutex_lock(&cpu->work_mutex); + qemu_mutex_lock(&cpu->lock); QSIMPLEQ_INSERT_TAIL(&cpu->work_list, wi, node); wi->done =3D false; - qemu_mutex_unlock(&cpu->work_mutex); + qemu_mutex_unlock(&cpu->lock); =20 qemu_cpu_kick(cpu); } @@ -308,15 +308,15 @@ void process_queued_cpu_work(CPUState *cpu) { struct qemu_work_item *wi; =20 - qemu_mutex_lock(&cpu->work_mutex); + qemu_mutex_lock(&cpu->lock); if (QSIMPLEQ_EMPTY(&cpu->work_list)) { - qemu_mutex_unlock(&cpu->work_mutex); + qemu_mutex_unlock(&cpu->lock); return; } while (!QSIMPLEQ_EMPTY(&cpu->work_list)) { wi =3D QSIMPLEQ_FIRST(&cpu->work_list); QSIMPLEQ_REMOVE_HEAD(&cpu->work_list, node); - qemu_mutex_unlock(&cpu->work_mutex); + qemu_mutex_unlock(&cpu->lock); if (wi->exclusive) { /* Running work items outside the BQL avoids the following dea= dlock: * 1) start_exclusive() is called with the BQL taken while ano= ther @@ -332,13 +332,13 @@ void process_queued_cpu_work(CPUState *cpu) } else { wi->func(cpu, wi->data); } - qemu_mutex_lock(&cpu->work_mutex); + qemu_mutex_lock(&cpu->lock); if (wi->free) { g_free(wi); } else { atomic_mb_set(&wi->done, true); } } - qemu_mutex_unlock(&cpu->work_mutex); + qemu_mutex_unlock(&cpu->lock); qemu_cond_broadcast(&qemu_work_cond); } diff --git a/cpus.c b/cpus.c index 7531723d61..895013b56a 100644 --- a/cpus.c +++ b/cpus.c @@ -92,9 +92,9 @@ static inline bool cpu_work_list_empty(CPUState *cpu) { bool ret; =20 - qemu_mutex_lock(&cpu->work_mutex); + qemu_mutex_lock(&cpu->lock); ret =3D QSIMPLEQ_EMPTY(&cpu->work_list); - qemu_mutex_unlock(&cpu->work_mutex); + qemu_mutex_unlock(&cpu->lock); return ret; } =20 diff --git a/qom/cpu.c b/qom/cpu.c index eb270169ed..411b9b2eec 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -371,7 +371,7 @@ static void cpu_common_initfn(Object *obj) cpu->nr_cores =3D 1; cpu->nr_threads =3D 1; =20 - qemu_mutex_init(&cpu->work_mutex); + qemu_mutex_init(&cpu->lock); QSIMPLEQ_INIT(&cpu->work_list); QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); --=20 2.17.1