From nobody Wed Nov 27 03:48:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1701293247; cv=none; d=zohomail.com; s=zohoarc; b=XRmuQjT+xUpLJrARfoqFQ2oTOd+LS7/nm4OoljIqmybaq4lMBIj0kxi3rHbLP65DzFsWBeHjNsrY5u00azuTol9f1kGCK/8ssR+QyQVsoXcJaoXhG4CeaR92bjuGiEUd3qMkQWMYIrb88z7UPHU/KIDbj4+qmXya+YmbaYo2N+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701293247; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6hqew74nJzMVhrPnvywfKIPbgvWI8jNXz53US0L/2fc=; b=YOoXpDdGVUxIAz0sPS0PpMJ4FhesT6yCTK4ihjboeJW9FnvIFwSdsqFyZYY0qKzrK9MiFGSu/PHohA6P/aZKS1gkmuofHYZjgeUSppz9gdLuj+Q5GtOPBzkxQBR7X6dqwihbGosVCt+EN2ZwhFIWIbKIWEuCzQ5zIoex8fA1RFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701293247362411.9566435129873; Wed, 29 Nov 2023 13:27:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644252.1005091 (Exim 4.92) (envelope-from ) id 1r8S5C-0001W8-SU; Wed, 29 Nov 2023 21:26:58 +0000 Received: by outflank-mailman (output) from mailman id 644252.1005091; Wed, 29 Nov 2023 21:26:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S5C-0001Vz-P5; Wed, 29 Nov 2023 21:26:58 +0000 Received: by outflank-mailman (input) for mailman id 644252; Wed, 29 Nov 2023 21:26:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S5A-0000jZ-7n for xen-devel@lists.xenproject.org; Wed, 29 Nov 2023 21:26:56 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 03639b9b-8efe-11ee-9b0f-b553b5be7939; Wed, 29 Nov 2023 22:26:53 +0100 (CET) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-YKOu9_xkN2eb9qmoDz-MDA-1; Wed, 29 Nov 2023 16:26:45 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E5BB82BAB5; Wed, 29 Nov 2023 21:26:35 +0000 (UTC) Received: from localhost (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 467B0492BF1; Wed, 29 Nov 2023 21:26:32 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 03639b9b-8efe-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701293212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6hqew74nJzMVhrPnvywfKIPbgvWI8jNXz53US0L/2fc=; b=by28i4XRSEMPs11TP1W9PGjI8HR+AQ5odowjAdUd8fAw522n/JZMhACBei3rapknJnPFC3 3VcBFSJJIVv968FWT0LK8foIHtRiyN0aKP5NbdlBo5RATX+s4BvGB1QxuYHAQdgIR3ToS8 Dteqcsp0+rmacMs2HzDJtXC+p8fCLc8= X-MC-Unique: YKOu9_xkN2eb9qmoDz-MDA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Jean-Christophe Dubois , Fabiano Rosas , qemu-s390x@nongnu.org, Song Gao , Marcel Apfelbaum , Thomas Huth , Hyman Huang , Marcelo Tosatti , David Woodhouse , Andrey Smirnov , Peter Maydell , Kevin Wolf , Ilya Leoshkevich , Artyom Tarasenko , Mark Cave-Ayland , Max Filippov , Alistair Francis , Paul Durrant , Jagannathan Raman , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-arm@nongnu.org, Jason Wang , Gerd Hoffmann , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , BALATON Zoltan , Daniel Henrique Barboza , Elena Ufimtseva , Aurelien Jarno , Hailiang Zhang , Roman Bolshakov , Huacai Chen , Fam Zheng , Eric Blake , Jiri Slaby , Alexander Graf , Liu Zhiwei , Weiwei Li , Eric Farman , Stafford Horne , David Hildenbrand , Markus Armbruster , Reinoud Zandijk , Palmer Dabbelt , Cameron Esfahani , xen-devel@lists.xenproject.org, Pavel Dovgalyuk , qemu-riscv@nongnu.org, Aleksandar Rikalo , John Snow , Sunil Muthuswamy , Michael Roth , David Gibson , "Michael S. Tsirkin" , Richard Henderson , Bin Meng , Stefano Stabellini , kvm@vger.kernel.org, Stefan Hajnoczi , qemu-block@nongnu.org, Halil Pasic , Peter Xu , Anthony Perard , Harsh Prateek Bora , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Borntraeger , Akihiko Odaki , Leonardo Bras , Nicholas Piggin , Jiaxun Yang Subject: [PATCH 1/6] system/cpus: rename qemu_mutex_lock_iothread() to qemu_bql_lock() Date: Wed, 29 Nov 2023 16:26:20 -0500 Message-ID: <20231129212625.1051502-2-stefanha@redhat.com> In-Reply-To: <20231129212625.1051502-1-stefanha@redhat.com> References: <20231129212625.1051502-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701293248903000001 Content-Type: text/plain; charset="utf-8" The Big QEMU Lock (BQL) has many names and they are confusing. The actual QemuMutex variable is called qemu_global_mutex but it's commonly referred to as the BQL in discussions and some code comments. The locking APIs, however, are called qemu_mutex_lock_iothread() and qemu_mutex_unlock_iothread(). The "iothread" name is historic and comes from when the main thread was split into into KVM vcpu threads and the "iothread" (now called the main loop thread). I have contributed to the confusion myself by introducing a separate --object iothread, a separate concept unrelated to the BQL. The "iothread" name is no longer appropriate for the BQL. Rename the locking APIs to: - void qemu_bql_lock(void) - void qemu_bql_unlock(void) - bool qemu_bql_locked(void) There are more APIs with "iothread" in their names. Subsequent patches will rename them. There are also comments and documentation that will be updated in later patches. Signed-off-by: Stefan Hajnoczi Acked-by: David Woodhouse Acked-by: Eric Farman Acked-by: Fabiano Rosas Acked-by: Peter Xu Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Harsh Prateek Bora Reviewed-by: Paul Durrant --- include/block/aio-wait.h | 2 +- include/qemu/main-loop.h | 26 +++--- accel/accel-blocker.c | 10 +-- accel/dummy-cpus.c | 8 +- accel/hvf/hvf-accel-ops.c | 4 +- accel/kvm/kvm-accel-ops.c | 4 +- accel/kvm/kvm-all.c | 22 ++--- accel/tcg/cpu-exec.c | 26 +++--- accel/tcg/cputlb.c | 16 ++-- accel/tcg/tcg-accel-ops-icount.c | 4 +- accel/tcg/tcg-accel-ops-mttcg.c | 12 +-- accel/tcg/tcg-accel-ops-rr.c | 14 ++-- accel/tcg/tcg-accel-ops.c | 2 +- accel/tcg/translate-all.c | 2 +- cpu-common.c | 4 +- dump/dump.c | 4 +- hw/core/cpu-common.c | 6 +- hw/i386/intel_iommu.c | 6 +- hw/i386/kvm/xen_evtchn.c | 16 ++-- hw/i386/kvm/xen_overlay.c | 2 +- hw/i386/kvm/xen_xenstore.c | 2 +- hw/intc/arm_gicv3_cpuif.c | 2 +- hw/intc/s390_flic.c | 18 ++-- hw/misc/edu.c | 4 +- hw/misc/imx6_src.c | 2 +- hw/misc/imx7_src.c | 2 +- hw/net/xen_nic.c | 8 +- hw/ppc/pegasos2.c | 2 +- hw/ppc/ppc.c | 4 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_rng.c | 4 +- hw/ppc/spapr_softmmu.c | 4 +- hw/remote/mpqemu-link.c | 12 +-- hw/remote/vfio-user-obj.c | 2 +- hw/s390x/s390-skeys.c | 2 +- migration/block-dirty-bitmap.c | 4 +- migration/block.c | 16 ++-- migration/colo.c | 60 +++++++------- migration/dirtyrate.c | 12 +-- migration/migration.c | 52 ++++++------ migration/ram.c | 12 +-- replay/replay-internal.c | 2 +- semihosting/console.c | 8 +- stubs/iothread-lock.c | 6 +- system/cpu-throttle.c | 4 +- system/cpus.c | 28 +++---- system/dirtylimit.c | 4 +- system/memory.c | 2 +- system/physmem.c | 8 +- system/runstate.c | 2 +- system/watchpoint.c | 4 +- target/arm/arm-powerctl.c | 14 ++-- target/arm/helper.c | 4 +- target/arm/hvf/hvf.c | 8 +- target/arm/kvm.c | 4 +- target/arm/kvm64.c | 4 +- target/arm/ptw.c | 6 +- target/arm/tcg/helper-a64.c | 8 +- target/arm/tcg/m_helper.c | 4 +- target/arm/tcg/op_helper.c | 24 +++--- target/arm/tcg/psci.c | 2 +- target/hppa/int_helper.c | 8 +- target/i386/hvf/hvf.c | 6 +- target/i386/kvm/hyperv.c | 4 +- target/i386/kvm/kvm.c | 28 +++---- target/i386/kvm/xen-emu.c | 14 ++-- target/i386/nvmm/nvmm-accel-ops.c | 4 +- target/i386/nvmm/nvmm-all.c | 20 ++--- target/i386/tcg/sysemu/fpu_helper.c | 6 +- target/i386/tcg/sysemu/misc_helper.c | 4 +- target/i386/whpx/whpx-accel-ops.c | 4 +- target/i386/whpx/whpx-all.c | 24 +++--- target/loongarch/csr_helper.c | 4 +- target/mips/kvm.c | 4 +- target/mips/tcg/sysemu/cp0_helper.c | 4 +- target/openrisc/sys_helper.c | 16 ++-- target/ppc/excp_helper.c | 12 +-- target/ppc/kvm.c | 4 +- target/ppc/misc_helper.c | 8 +- target/ppc/timebase_helper.c | 8 +- target/s390x/kvm/kvm.c | 4 +- target/s390x/tcg/misc_helper.c | 118 +++++++++++++-------------- target/sparc/int32_helper.c | 2 +- target/sparc/int64_helper.c | 6 +- target/sparc/win_helper.c | 20 ++--- target/xtensa/exc_helper.c | 8 +- ui/spice-core.c | 4 +- util/async.c | 2 +- util/main-loop.c | 8 +- util/rcu.c | 14 ++-- audio/coreaudio.m | 4 +- memory_ldst.c.inc | 18 ++-- target/i386/hvf/README.md | 2 +- ui/cocoa.m | 50 ++++++------ 94 files changed, 502 insertions(+), 502 deletions(-) diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h index 5449b6d742..f6ae91742c 100644 --- a/include/block/aio-wait.h +++ b/include/block/aio-wait.h @@ -151,7 +151,7 @@ static inline bool in_aio_context_home_thread(AioContex= t *ctx) } =20 if (ctx =3D=3D qemu_get_aio_context()) { - return qemu_mutex_iothread_locked(); + return qemu_bql_locked(); } else { return false; } diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 68e70e61aa..d6f75e57bd 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -248,7 +248,7 @@ GSource *iohandler_get_g_source(void); AioContext *iohandler_get_aio_context(void); =20 /** - * qemu_mutex_iothread_locked: Return lock status of the main loop mutex. + * qemu_bql_locked: Return lock status of the main loop mutex. * * The main loop mutex is the coarsest lock in QEMU, and as such it * must always be taken outside other locks. This function helps @@ -260,7 +260,7 @@ AioContext *iohandler_get_aio_context(void); * have a BQL. * Please instead refer to qemu_in_main_thread(). */ -bool qemu_mutex_iothread_locked(void); +bool qemu_bql_locked(void); =20 /** * qemu_in_main_thread: return whether it's possible to safely access @@ -312,7 +312,7 @@ bool qemu_in_main_thread(void); } while (0) =20 /** - * qemu_mutex_lock_iothread: Lock the main loop mutex. + * qemu_bql_lock: Lock the main loop mutex. * * This function locks the main loop mutex. The mutex is taken by * main() in vl.c and always taken except while waiting on @@ -321,15 +321,15 @@ bool qemu_in_main_thread(void); * qemu_bh_new(), qemu_set_fd_handler() and basically all other * functions documented in this file. * - * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread + * NOTE: tools currently are single-threaded and qemu_bql_lock * is a no-op there. */ -#define qemu_mutex_lock_iothread() \ - qemu_mutex_lock_iothread_impl(__FILE__, __LINE__) -void qemu_mutex_lock_iothread_impl(const char *file, int line); +#define qemu_bql_lock() \ + qemu_bql_lock_impl(__FILE__, __LINE__) +void qemu_bql_lock_impl(const char *file, int line); =20 /** - * qemu_mutex_unlock_iothread: Unlock the main loop mutex. + * qemu_bql_unlock: Unlock the main loop mutex. * * This function unlocks the main loop mutex. The mutex is taken by * main() in vl.c and always taken except while waiting on @@ -338,10 +338,10 @@ void qemu_mutex_lock_iothread_impl(const char *file, = int line); * because it prevents the main loop from processing callbacks, * including timers and bottom halves. * - * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread + * NOTE: tools currently are single-threaded and qemu_bql_unlock * is a no-op there. */ -void qemu_mutex_unlock_iothread(void); +void qemu_bql_unlock(void); =20 /** * QEMU_IOTHREAD_LOCK_GUARD @@ -353,17 +353,17 @@ typedef struct IOThreadLockAuto IOThreadLockAuto; static inline IOThreadLockAuto *qemu_iothread_auto_lock(const char *file, int line) { - if (qemu_mutex_iothread_locked()) { + if (qemu_bql_locked()) { return NULL; } - qemu_mutex_lock_iothread_impl(file, line); + qemu_bql_lock_impl(file, line); /* Anything non-NULL causes the cleanup function to be called */ return (IOThreadLockAuto *)(uintptr_t)1; } =20 static inline void qemu_iothread_auto_unlock(IOThreadLockAuto *l) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(IOThreadLockAuto, qemu_iothread_auto_unlock) diff --git a/accel/accel-blocker.c b/accel/accel-blocker.c index 1e7f423462..0e9e4a2142 100644 --- a/accel/accel-blocker.c +++ b/accel/accel-blocker.c @@ -41,7 +41,7 @@ void accel_blocker_init(void) =20 void accel_ioctl_begin(void) { - if (likely(qemu_mutex_iothread_locked())) { + if (likely(qemu_bql_locked())) { return; } =20 @@ -51,7 +51,7 @@ void accel_ioctl_begin(void) =20 void accel_ioctl_end(void) { - if (likely(qemu_mutex_iothread_locked())) { + if (likely(qemu_bql_locked())) { return; } =20 @@ -62,7 +62,7 @@ void accel_ioctl_end(void) =20 void accel_cpu_ioctl_begin(CPUState *cpu) { - if (unlikely(qemu_mutex_iothread_locked())) { + if (unlikely(qemu_bql_locked())) { return; } =20 @@ -72,7 +72,7 @@ void accel_cpu_ioctl_begin(CPUState *cpu) =20 void accel_cpu_ioctl_end(CPUState *cpu) { - if (unlikely(qemu_mutex_iothread_locked())) { + if (unlikely(qemu_bql_locked())) { return; } =20 @@ -105,7 +105,7 @@ void accel_ioctl_inhibit_begin(void) * We allow to inhibit only when holding the BQL, so we can identify * when an inhibitor wants to issue an ioctl easily. */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 /* Block further invocations of the ioctls outside the BQL. */ CPU_FOREACH(cpu) { diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c index b75c919ac3..7b4b26a152 100644 --- a/accel/dummy-cpus.c +++ b/accel/dummy-cpus.c @@ -24,7 +24,7 @@ static void *dummy_cpu_thread_fn(void *arg) =20 rcu_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); cpu->thread_id =3D qemu_get_thread_id(); cpu->neg.can_do_io =3D true; @@ -43,7 +43,7 @@ static void *dummy_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 do { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); #ifndef _WIN32 do { int sig; @@ -56,11 +56,11 @@ static void *dummy_cpu_thread_fn(void *arg) #else qemu_sem_wait(&cpu->sem); #endif - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_wait_io_event(cpu); } while (!cpu->unplug); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); rcu_unregister_thread(); return NULL; } diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index abe7adf7ee..caa4a00741 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -424,7 +424,7 @@ static void *hvf_cpu_thread_fn(void *arg) =20 rcu_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); =20 cpu->thread_id =3D qemu_get_thread_id(); @@ -449,7 +449,7 @@ static void *hvf_cpu_thread_fn(void *arg) =20 hvf_vcpu_destroy(cpu); cpu_thread_signal_destroyed(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); rcu_unregister_thread(); return NULL; } diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index 6195150a0b..92fdd3ddbd 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -33,7 +33,7 @@ static void *kvm_vcpu_thread_fn(void *arg) =20 rcu_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); cpu->thread_id =3D qemu_get_thread_id(); cpu->neg.can_do_io =3D true; @@ -58,7 +58,7 @@ static void *kvm_vcpu_thread_fn(void *arg) =20 kvm_destroy_vcpu(cpu); cpu_thread_signal_destroyed(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); rcu_unregister_thread(); return NULL; } diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e39a810a4e..760a160052 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -817,7 +817,7 @@ static void kvm_dirty_ring_flush(void) * should always be with BQL held, serialization is guaranteed. * However, let's be sure of it. */ - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); /* * First make sure to flush the hardware buffers by kicking all * vcpus out in a synchronous way. @@ -1402,9 +1402,9 @@ static void *kvm_dirty_ring_reaper_thread(void *data) trace_kvm_dirty_ring_reaper("wakeup"); r->reaper_state =3D KVM_DIRTY_RING_REAPER_REAPING; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); kvm_dirty_ring_reap(s, NULL); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 r->reaper_iteration++; } @@ -2828,7 +2828,7 @@ int kvm_cpu_exec(CPUState *cpu) return EXCP_HLT; } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); cpu_exec_start(cpu); =20 do { @@ -2868,11 +2868,11 @@ int kvm_cpu_exec(CPUState *cpu) =20 #ifdef KVM_HAVE_MCE_INJECTION if (unlikely(have_sigbus_pending)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); kvm_arch_on_sigbus_vcpu(cpu, pending_sigbus_code, pending_sigbus_addr); have_sigbus_pending =3D false; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif =20 @@ -2942,7 +2942,7 @@ int kvm_cpu_exec(CPUState *cpu) * still full. Got kicked by KVM_RESET_DIRTY_RINGS. */ trace_kvm_dirty_ring_full(cpu->cpu_index); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); /* * We throttle vCPU by making it sleep once it exit from kernel * due to dirty ring full. In the dirtylimit scenario, reaping @@ -2954,7 +2954,7 @@ int kvm_cpu_exec(CPUState *cpu) } else { kvm_dirty_ring_reap(kvm_state, NULL); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); dirtylimit_vcpu_execute(cpu); ret =3D 0; break; @@ -2970,9 +2970,9 @@ int kvm_cpu_exec(CPUState *cpu) break; case KVM_SYSTEM_EVENT_CRASH: kvm_cpu_synchronize_state(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_system_guest_panicked(cpu_get_crash_info(cpu)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); ret =3D 0; break; default: @@ -2989,7 +2989,7 @@ int kvm_cpu_exec(CPUState *cpu) } while (ret =3D=3D 0); =20 cpu_exec_end(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (ret < 0) { cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index c938eb96f8..9777182478 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -558,8 +558,8 @@ static void cpu_exec_longjmp_cleanup(CPUState *cpu) tcg_ctx->gen_tb =3D NULL; } #endif - if (qemu_mutex_iothread_locked()) { - qemu_mutex_unlock_iothread(); + if (qemu_bql_locked()) { + qemu_bql_unlock(); } assert_no_pages_locked(); } @@ -680,10 +680,10 @@ static inline bool cpu_handle_halt(CPUState *cpu) #if defined(TARGET_I386) if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { X86CPU *x86_cpu =3D X86_CPU(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); apic_poll_irq(x86_cpu->apic_state); cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif /* TARGET_I386 */ if (!cpu_has_work(cpu)) { @@ -749,9 +749,9 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) #else if (replay_exception()) { CPUClass *cc =3D CPU_GET_CLASS(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cc->tcg_ops->do_interrupt(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); cpu->exception_index =3D -1; =20 if (unlikely(cpu->singlestep_enabled)) { @@ -812,7 +812,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, =20 if (unlikely(qatomic_read(&cpu->interrupt_request))) { int interrupt_request; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); interrupt_request =3D cpu->interrupt_request; if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ @@ -821,7 +821,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu->interrupt_request &=3D ~CPU_INTERRUPT_DEBUG; cpu->exception_index =3D EXCP_DEBUG; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return true; } #if !defined(CONFIG_USER_ONLY) @@ -832,7 +832,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu->interrupt_request &=3D ~CPU_INTERRUPT_HALT; cpu->halted =3D 1; cpu->exception_index =3D EXCP_HLT; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return true; } #if defined(TARGET_I386) @@ -843,14 +843,14 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); cpu->exception_index =3D EXCP_HALTED; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return true; } #else else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return true; } #endif /* !TARGET_I386 */ @@ -873,7 +873,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, */ if (unlikely(cpu->singlestep_enabled)) { cpu->exception_index =3D EXCP_DEBUG; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return true; } cpu->exception_index =3D -1; @@ -892,7 +892,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } =20 /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */ - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* Finally, check if we need to exit to the main loop. */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index db3f93fda9..3c0b1658ee 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -2030,10 +2030,10 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTL= BEntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D int_ld_mmio_beN(cpu, full, ret_be, addr, size, mmu_idx, type, ra, mr, mr_offset); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return ret; } @@ -2054,12 +2054,12 @@ static Int128 do_ld16_mmio_beN(CPUState *cpu, CPUTL= BEntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); a =3D int_ld_mmio_beN(cpu, full, ret_be, addr, size - 8, mmu_idx, MMU_DATA_LOAD, ra, mr, mr_offset); b =3D int_ld_mmio_beN(cpu, full, ret_be, addr + size - 8, 8, mmu_idx, MMU_DATA_LOAD, ra, mr, mr_offset + size - 8); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return int128_make128(b, a); } @@ -2577,10 +2577,10 @@ static uint64_t do_st_mmio_leN(CPUState *cpu, CPUTL= BEntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D int_st_mmio_leN(cpu, full, val_le, addr, size, mmu_idx, ra, mr, mr_offset); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return ret; } @@ -2601,12 +2601,12 @@ static uint64_t do_st16_mmio_leN(CPUState *cpu, CPU= TLBEntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); int_st_mmio_leN(cpu, full, int128_getlo(val_le), addr, 8, mmu_idx, ra, mr, mr_offset); ret =3D int_st_mmio_leN(cpu, full, int128_gethi(val_le), addr + 8, size - 8, mmu_idx, ra, mr, mr_offset + 8); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return ret; } diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-ico= unt.c index b25685fb71..76b9bedc08 100644 --- a/accel/tcg/tcg-accel-ops-icount.c +++ b/accel/tcg/tcg-accel-ops-icount.c @@ -126,9 +126,9 @@ void icount_prepare_for_run(CPUState *cpu, int64_t cpu_= budget) * We're called without the iothread lock, so must take it while * we're calling timer handlers. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); icount_notify_aio_contexts(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttc= g.c index fac80095bb..d3575bdc8b 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -76,7 +76,7 @@ static void *mttcg_cpu_thread_fn(void *arg) rcu_add_force_rcu_notifier(&force_rcu.notifier); tcg_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); =20 cpu->thread_id =3D qemu_get_thread_id(); @@ -91,9 +91,9 @@ static void *mttcg_cpu_thread_fn(void *arg) do { if (cpu_can_run(cpu)) { int r; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); r =3D tcg_cpus_exec(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); switch (r) { case EXCP_DEBUG: cpu_handle_guest_debug(cpu); @@ -105,9 +105,9 @@ static void *mttcg_cpu_thread_fn(void *arg) */ break; case EXCP_ATOMIC: - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); cpu_exec_step_atomic(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); default: /* Ignore everything else? */ break; @@ -119,7 +119,7 @@ static void *mttcg_cpu_thread_fn(void *arg) } while (!cpu->unplug || cpu_can_run(cpu)); =20 tcg_cpus_destroy(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); rcu_remove_force_rcu_notifier(&force_rcu.notifier); rcu_unregister_thread(); return NULL; diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 611932f3c3..c21215a094 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -188,7 +188,7 @@ static void *rr_cpu_thread_fn(void *arg) rcu_add_force_rcu_notifier(&force_rcu); tcg_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); =20 cpu->thread_id =3D qemu_get_thread_id(); @@ -218,9 +218,9 @@ static void *rr_cpu_thread_fn(void *arg) /* Only used for icount_enabled() */ int64_t cpu_budget =3D 0; =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); replay_mutex_lock(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (icount_enabled()) { int cpu_count =3D rr_cpu_count(); @@ -254,7 +254,7 @@ static void *rr_cpu_thread_fn(void *arg) if (cpu_can_run(cpu)) { int r; =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (icount_enabled()) { icount_prepare_for_run(cpu, cpu_budget); } @@ -262,15 +262,15 @@ static void *rr_cpu_thread_fn(void *arg) if (icount_enabled()) { icount_process_data(cpu); } - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); break; } else if (r =3D=3D EXCP_ATOMIC) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); cpu_exec_step_atomic(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); break; } } else if (cpu->stop) { diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 1b57290682..2cc17faba3 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -88,7 +88,7 @@ static void tcg_cpu_reset_hold(CPUState *cpu) /* mask must never be zero, except for A20 change call */ void tcg_handle_interrupt(CPUState *cpu, int mask) { - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 cpu->interrupt_request |=3D mask; =20 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 79a88f5fb7..62e71b1617 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -649,7 +649,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) =20 void cpu_interrupt(CPUState *cpu, int mask) { - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); cpu->interrupt_request |=3D mask; qatomic_set(&cpu->neg.icount_decr.u16.high, -1); } diff --git a/cpu-common.c b/cpu-common.c index c81fd72d16..acafb27377 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -351,11 +351,11 @@ void process_queued_cpu_work(CPUState *cpu) * BQL, so it goes to sleep; start_exclusive() is sleeping too= , so * neither CPU can proceed. */ - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); start_exclusive(); wi->func(cpu, wi->data); end_exclusive(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } else { wi->func(cpu, wi->data); } diff --git a/dump/dump.c b/dump/dump.c index 4819050764..7fab6c07e7 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -108,11 +108,11 @@ static int dump_cleanup(DumpState *s) s->guest_note =3D NULL; if (s->resume) { if (s->detached) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } vm_start(); if (s->detached) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } migrate_del_blocker(&dump_migration_blocker); diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 82dae51a55..5c9efe90ad 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -70,14 +70,14 @@ CPUState *cpu_create(const char *typename) * BQL here if we need to. cpu_interrupt assumes it is held.*/ void cpu_reset_interrupt(CPUState *cpu, int mask) { - bool need_lock =3D !qemu_mutex_iothread_locked(); + bool need_lock =3D !qemu_bql_locked(); =20 if (need_lock) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } cpu->interrupt_request &=3D ~mask; if (need_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 5085a6fee3..bb3768a243 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1665,7 +1665,7 @@ static bool vtd_switch_address_space(VTDAddressSpace = *as) { bool use_iommu, pt; /* Whether we need to take the BQL on our own */ - bool take_bql =3D !qemu_mutex_iothread_locked(); + bool take_bql =3D !qemu_bql_locked(); =20 assert(as); =20 @@ -1683,7 +1683,7 @@ static bool vtd_switch_address_space(VTDAddressSpace = *as) * it. We'd better make sure we have had it already, or, take it. */ if (take_bql) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 /* Turn off first then on the other */ @@ -1738,7 +1738,7 @@ static bool vtd_switch_address_space(VTDAddressSpace = *as) } =20 if (take_bql) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 return use_iommu; diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 02b8cbf8df..07d0ff0253 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -425,7 +425,7 @@ void xen_evtchn_set_callback_level(int level) * effect immediately. That just leaves interdomain loopback as the ca= se * which uses the BH. */ - if (!qemu_mutex_iothread_locked()) { + if (!qemu_bql_locked()) { qemu_bh_schedule(s->gsi_bh); return; } @@ -459,7 +459,7 @@ int xen_evtchn_set_callback_param(uint64_t param) * We need the BQL because set_callback_pci_intx() may call into PCI c= ode, * and because we may need to manipulate the old and new GSI levels. */ - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); qemu_mutex_lock(&s->port_lock); =20 switch (type) { @@ -1037,7 +1037,7 @@ static int close_port(XenEvtchnState *s, evtchn_port_= t port, XenEvtchnPort *p =3D &s->port_table[port]; =20 /* Because it *might* be a PIRQ port */ - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 switch (p->type) { case EVTCHNSTAT_closed: @@ -1104,7 +1104,7 @@ int xen_evtchn_soft_reset(void) return -ENOTSUP; } =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 qemu_mutex_lock(&s->port_lock); =20 @@ -1601,7 +1601,7 @@ bool xen_evtchn_set_gsi(int gsi, int level) XenEvtchnState *s =3D xen_evtchn_singleton; int pirq; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 if (!s || gsi < 0 || gsi >=3D IOAPIC_NUM_PINS) { return false; @@ -1712,7 +1712,7 @@ void xen_evtchn_snoop_msi(PCIDevice *dev, bool is_msi= x, unsigned int vector, return; } =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 pirq =3D msi_pirq_target(addr, data); =20 @@ -1749,7 +1749,7 @@ int xen_evtchn_translate_pirq_msi(struct kvm_irq_rout= ing_entry *route, return 1; /* Not a PIRQ */ } =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 pirq =3D msi_pirq_target(address, data); if (!pirq || pirq >=3D s->nr_pirqs) { @@ -1796,7 +1796,7 @@ bool xen_evtchn_deliver_pirq_msi(uint64_t address, ui= nt32_t data) return false; } =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 pirq =3D msi_pirq_target(address, data); if (!pirq || pirq >=3D s->nr_pirqs) { diff --git a/hw/i386/kvm/xen_overlay.c b/hw/i386/kvm/xen_overlay.c index 39fda1b72c..7f05da1804 100644 --- a/hw/i386/kvm/xen_overlay.c +++ b/hw/i386/kvm/xen_overlay.c @@ -194,7 +194,7 @@ int xen_overlay_map_shinfo_page(uint64_t gpa) return -ENOENT; } =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 if (s->shinfo_gpa) { /* If removing shinfo page, turn the kernel magic off first */ diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 6e651960b3..cd56b4c32c 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1341,7 +1341,7 @@ static void fire_watch_cb(void *opaque, const char *p= ath, const char *token) { XenXenstoreState *s =3D opaque; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 /* * If there's a response pending, we obviously can't scribble over diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index ab1a00508e..a6d24cecfd 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -934,7 +934,7 @@ void gicv3_cpuif_update(GICv3CPUState *cs) ARMCPU *cpu =3D ARM_CPU(cs->cpu); CPUARMState *env =3D &cpu->env; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 trace_gicv3_cpuif_update(gicv3_redist_affid(cs), cs->hppi.irq, cs->hppi.grp, cs->hppi.prio); diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 74e02858d4..8550c6828d 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -106,7 +106,7 @@ static int qemu_s390_clear_io_flic(S390FLICState *fs, u= int16_t subchannel_id, QEMUS390FlicIO *cur, *next; uint8_t isc; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); if (!(flic->pending & FLIC_PENDING_IO)) { return 0; } @@ -223,7 +223,7 @@ uint32_t qemu_s390_flic_dequeue_service(QEMUS390FLICSta= te *flic) { uint32_t tmp; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); g_assert(flic->pending & FLIC_PENDING_SERVICE); tmp =3D flic->service_param; flic->service_param =3D 0; @@ -238,7 +238,7 @@ QEMUS390FlicIO *qemu_s390_flic_dequeue_io(QEMUS390FLICS= tate *flic, uint64_t cr6) QEMUS390FlicIO *io; uint8_t isc; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); if (!(flic->pending & CR6_TO_PENDING_IO(cr6))) { return NULL; } @@ -262,7 +262,7 @@ QEMUS390FlicIO *qemu_s390_flic_dequeue_io(QEMUS390FLICS= tate *flic, uint64_t cr6) =20 void qemu_s390_flic_dequeue_crw_mchk(QEMUS390FLICState *flic) { - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); g_assert(flic->pending & FLIC_PENDING_MCHK_CR); flic->pending &=3D ~FLIC_PENDING_MCHK_CR; } @@ -271,7 +271,7 @@ static void qemu_s390_inject_service(S390FLICState *fs,= uint32_t parm) { QEMUS390FLICState *flic =3D s390_get_qemu_flic(fs); =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); /* multiplexing is good enough for sclp - kvm does it internally as we= ll */ flic->service_param |=3D parm; flic->pending |=3D FLIC_PENDING_SERVICE; @@ -287,7 +287,7 @@ static void qemu_s390_inject_io(S390FLICState *fs, uint= 16_t subchannel_id, QEMUS390FLICState *flic =3D s390_get_qemu_flic(fs); QEMUS390FlicIO *io; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); io =3D g_new0(QEMUS390FlicIO, 1); io->id =3D subchannel_id; io->nr =3D subchannel_nr; @@ -304,7 +304,7 @@ static void qemu_s390_inject_crw_mchk(S390FLICState *fs) { QEMUS390FLICState *flic =3D s390_get_qemu_flic(fs); =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); flic->pending |=3D FLIC_PENDING_MCHK_CR; =20 qemu_s390_flic_notify(FLIC_PENDING_MCHK_CR); @@ -330,7 +330,7 @@ bool qemu_s390_flic_has_crw_mchk(QEMUS390FLICState *fli= c) =20 bool qemu_s390_flic_has_any(QEMUS390FLICState *flic) { - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); return !!flic->pending; } =20 @@ -340,7 +340,7 @@ static void qemu_s390_flic_reset(DeviceState *dev) QEMUS390FlicIO *cur, *next; int isc; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); flic->simm =3D 0; flic->nimm =3D 0; flic->pending =3D 0; diff --git a/hw/misc/edu.c b/hw/misc/edu.c index a1f8bc77e7..1c18383378 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -355,9 +355,9 @@ static void *edu_fact_thread(void *opaque) smp_mb__after_rmw(); =20 if (qatomic_read(&edu->status) & EDU_STATUS_IRQFACT) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); edu_raise_irq(edu, FACT_IRQ); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 diff --git a/hw/misc/imx6_src.c b/hw/misc/imx6_src.c index a9c64d06eb..6070acc244 100644 --- a/hw/misc/imx6_src.c +++ b/hw/misc/imx6_src.c @@ -131,7 +131,7 @@ static void imx6_clear_reset_bit(CPUState *cpu, run_on_= cpu_data data) struct SRCSCRResetInfo *ri =3D data.host_ptr; IMX6SRCState *s =3D ri->s; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 s->regs[SRC_SCR] =3D deposit32(s->regs[SRC_SCR], ri->reset_bit, 1, 0); DPRINTF("reg[%s] <=3D 0x%" PRIx32 "\n", diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c index 983251e86f..cf3d14c9b3 100644 --- a/hw/misc/imx7_src.c +++ b/hw/misc/imx7_src.c @@ -136,7 +136,7 @@ static void imx7_clear_reset_bit(CPUState *cpu, run_on_= cpu_data data) struct SRCSCRResetInfo *ri =3D data.host_ptr; IMX7SRCState *s =3D ri->s; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 s->regs[SRC_A7RCR0] =3D deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, = 1, 0); =20 diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 1e2b3baeb1..b2bac8b2ab 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -133,7 +133,7 @@ static bool net_tx_packets(struct XenNetDev *netdev) void *page; void *tmpbuf =3D NULL; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 for (;;) { rc =3D netdev->tx_ring.req_cons; @@ -260,7 +260,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const = uint8_t *buf, size_t size RING_IDX rc, rp; void *page; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 if (xen_device_backend_get_state(&netdev->xendev) !=3D XenbusStateConn= ected) { return -1; @@ -354,7 +354,7 @@ static bool xen_netdev_connect(XenDevice *xendev, Error= **errp) XenNetDev *netdev =3D XEN_NET_DEVICE(xendev); unsigned int port, rx_copy; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 if (xen_device_frontend_scanf(xendev, "tx-ring-ref", "%u", &netdev->tx_ring_ref) !=3D 1) { @@ -425,7 +425,7 @@ static void xen_netdev_disconnect(XenDevice *xendev, Er= ror **errp) =20 trace_xen_netdev_disconnect(netdev->dev); =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 netdev->tx_ring.sring =3D NULL; netdev->rx_ring.sring =3D NULL; diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 3203a4a728..aad2787a3f 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -515,7 +515,7 @@ static void pegasos2_hypercall(PPCVirtualHypervisor *vh= yp, PowerPCCPU *cpu) CPUPPCState *env =3D &cpu->env; =20 /* The TCG path should also be holding the BQL at this point */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 if (FIELD_EX64(env->msr, MSR, PR)) { qemu_log_mask(LOG_GUEST_ERROR, "Hypercall made with MSR[PR]=3D1\n"= ); diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index be167710a3..c8c3b43602 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -314,7 +314,7 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val) { PowerPCCPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 switch ((val >> 28) & 0x3) { case 0x0: @@ -334,7 +334,7 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val) break; } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* PowerPC 40x internal IRQ controller */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index df09aa9d6a..6322c34283 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1304,7 +1304,7 @@ static void emulate_spapr_hypercall(PPCVirtualHypervi= sor *vhyp, CPUPPCState *env =3D &cpu->env; =20 /* The TCG path should also be holding the BQL at this point */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 g_assert(!vhyp_cpu_in_nested(cpu)); =20 diff --git a/hw/ppc/spapr_rng.c b/hw/ppc/spapr_rng.c index df5c4b9687..e8c428b8bb 100644 --- a/hw/ppc/spapr_rng.c +++ b/hw/ppc/spapr_rng.c @@ -82,9 +82,9 @@ static target_ulong h_random(PowerPCCPU *cpu, SpaprMachin= eState *spapr, while (hrdata.received < 8) { rng_backend_request_entropy(rngstate->backend, 8 - hrdata.received, random_recv, &hrdata); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_sem_wait(&hrdata.sem); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 qemu_sem_destroy(&hrdata.sem); diff --git a/hw/ppc/spapr_softmmu.c b/hw/ppc/spapr_softmmu.c index 278666317e..96ffcb8fbc 100644 --- a/hw/ppc/spapr_softmmu.c +++ b/hw/ppc/spapr_softmmu.c @@ -334,7 +334,7 @@ static void *hpt_prepare_thread(void *opaque) pending->ret =3D H_NO_MEM; } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (SPAPR_MACHINE(qdev_get_machine())->pending_hpt =3D=3D pending) { /* Ready to go */ @@ -344,7 +344,7 @@ static void *hpt_prepare_thread(void *opaque) free_pending_hpt(pending); } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return NULL; } =20 diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c index 9bd98e8219..ffb2c25145 100644 --- a/hw/remote/mpqemu-link.c +++ b/hw/remote/mpqemu-link.c @@ -33,7 +33,7 @@ */ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp) { - bool iolock =3D qemu_mutex_iothread_locked(); + bool iolock =3D qemu_bql_locked(); bool iothread =3D qemu_in_iothread(); struct iovec send[2] =3D {}; int *fds =3D NULL; @@ -64,7 +64,7 @@ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Err= or **errp) * Also skip lock handling while in a co-routine in the main context. */ if (iolock && !iothread && !qemu_in_coroutine()) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 if (!qio_channel_writev_full_all(ioc, send, G_N_ELEMENTS(send), @@ -76,7 +76,7 @@ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Err= or **errp) =20 if (iolock && !iothread && !qemu_in_coroutine()) { /* See above comment why skip locking here. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 return ret; @@ -96,7 +96,7 @@ static ssize_t mpqemu_read(QIOChannel *ioc, void *buf, si= ze_t len, int **fds, size_t *nfds, Error **errp) { struct iovec iov =3D { .iov_base =3D buf, .iov_len =3D len }; - bool iolock =3D qemu_mutex_iothread_locked(); + bool iolock =3D qemu_bql_locked(); bool iothread =3D qemu_in_iothread(); int ret =3D -1; =20 @@ -107,13 +107,13 @@ static ssize_t mpqemu_read(QIOChannel *ioc, void *buf= , size_t len, int **fds, assert(qemu_in_coroutine() || !iothread); =20 if (iolock && !iothread && !qemu_in_coroutine()) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 ret =3D qio_channel_readv_full_all_eof(ioc, &iov, 1, fds, nfds, errp); =20 if (iolock && !iothread && !qemu_in_coroutine()) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 return (ret <=3D 0) ? ret : iov.iov_len; diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c index 8b10c32a3c..d0d0386d52 100644 --- a/hw/remote/vfio-user-obj.c +++ b/hw/remote/vfio-user-obj.c @@ -400,7 +400,7 @@ static int vfu_object_mr_rw(MemoryRegion *mr, uint8_t *= buf, hwaddr offset, } =20 if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); release_lock =3D false; } =20 diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 8f5159d85d..307344aa80 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -153,7 +153,7 @@ void qmp_dump_skeys(const char *filename, Error **errp) goto out; } =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); guest_phys_blocks_init(&guest_phys_blocks); guest_phys_blocks_append(&guest_phys_blocks); =20 diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 24347ab0f7..b5a2d377db 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -774,7 +774,7 @@ static void dirty_bitmap_state_pending(void *opaque, SaveBitmapState *dbms; uint64_t pending =3D 0; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 QSIMPLEQ_FOREACH(dbms, &s->dbms_list, entry) { uint64_t gran =3D bdrv_dirty_bitmap_granularity(dbms->bitmap); @@ -784,7 +784,7 @@ static void dirty_bitmap_state_pending(void *opaque, pending +=3D DIV_ROUND_UP(sectors * BDRV_SECTOR_SIZE, gran); } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 trace_dirty_bitmap_state_pending(pending); =20 diff --git a/migration/block.c b/migration/block.c index a15f9bddcb..87f36e6e35 100644 --- a/migration/block.c +++ b/migration/block.c @@ -269,7 +269,7 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevS= tate *bmds) int64_t count; =20 if (bmds->shared_base) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); aio_context_acquire(blk_get_aio_context(bb)); /* Skip unallocated sectors; intentionally treats failure or * partial sector as an allocated sector */ @@ -282,7 +282,7 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevS= tate *bmds) cur_sector +=3D count >> BDRV_SECTOR_BITS; } aio_context_release(blk_get_aio_context(bb)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 if (cur_sector >=3D total_sectors) { @@ -321,14 +321,14 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDe= vState *bmds) * This is ugly and will disappear when we make bdrv_* thread-safe, * without the need to acquire the AioContext. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); aio_context_acquire(blk_get_aio_context(bmds->blk)); bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector * BDRV_SECTOR_S= IZE, nr_sectors * BDRV_SECTOR_SIZE); blk->aiocb =3D blk_aio_preadv(bb, cur_sector * BDRV_SECTOR_SIZE, &blk-= >qiov, 0, blk_mig_read_cb, blk); aio_context_release(blk_get_aio_context(bmds->blk)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 bmds->cur_sector =3D cur_sector + nr_sectors; return (bmds->cur_sector >=3D total_sectors); @@ -786,9 +786,9 @@ static int block_save_iterate(QEMUFile *f, void *opaque) /* Always called with iothread lock taken for * simplicity, block_save_complete also calls it. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D blk_mig_save_dirty_block(f, 1); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } if (ret < 0) { return ret; @@ -860,9 +860,9 @@ static void block_state_pending(void *opaque, uint64_t = *must_precopy, /* Estimate pending number of bytes to send */ uint64_t pending; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); pending =3D get_remaining_dirty(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 blk_mig_lock(); pending +=3D block_mig_state.submitted * BLK_MIG_BLOCK_SIZE + diff --git a/migration/colo.c b/migration/colo.c index 4447e34914..2e68107cfa 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -420,13 +420,13 @@ static int colo_do_checkpoint_transaction(MigrationSt= ate *s, qio_channel_io_seek(QIO_CHANNEL(bioc), 0, 0, NULL); bioc->usage =3D 0; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if (failover_get_state() !=3D FAILOVER_STATUS_NONE) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); goto out; } vm_stop_force_state(RUN_STATE_COLO); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); trace_colo_vm_state_change("run", "stop"); /* * Failover request bh could be called after vm_stop_force_state(), @@ -435,23 +435,23 @@ static int colo_do_checkpoint_transaction(MigrationSt= ate *s, if (failover_get_state() !=3D FAILOVER_STATUS_NONE) { goto out; } - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 replication_do_checkpoint_all(&local_err); if (local_err) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); goto out; } =20 colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_er= r); if (local_err) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); goto out; } /* Note: device state is saved into buffer */ ret =3D qemu_save_device_state(fb); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (ret < 0) { goto out; } @@ -504,9 +504,9 @@ static int colo_do_checkpoint_transaction(MigrationStat= e *s, =20 ret =3D 0; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); vm_start(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); trace_colo_vm_state_change("stop", "run"); =20 out: @@ -557,15 +557,15 @@ static void colo_process_checkpoint(MigrationState *s) fb =3D qemu_file_new_output(QIO_CHANNEL(bioc)); object_unref(OBJECT(bioc)); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); replication_start_all(REPLICATION_MODE_PRIMARY, &local_err); if (local_err) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); goto out; } =20 vm_start(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); trace_colo_vm_state_change("stop", "run"); =20 timer_mod(s->colo_delay_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) + @@ -639,14 +639,14 @@ out: =20 void migrate_start_colo_process(MigrationState *s) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_event_init(&s->colo_checkpoint_event, false); s->colo_delay_timer =3D timer_new_ms(QEMU_CLOCK_HOST, colo_checkpoint_notify, s); =20 qemu_sem_init(&s->colo_exit_sem, 0); colo_process_checkpoint(s); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, @@ -657,9 +657,9 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, Error *local_err =3D NULL; int ret; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); vm_stop_force_state(RUN_STATE_COLO); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); trace_colo_vm_state_change("run", "stop"); =20 /* FIXME: This is unnecessary for periodic checkpoint mode */ @@ -677,10 +677,10 @@ static void colo_incoming_process_checkpoint(Migratio= nIncomingState *mis, return; } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_synchronize_all_states(); ret =3D qemu_loadvm_state_main(mis->from_src_file, mis); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (ret < 0) { error_setg(errp, "Load VM's live state (ram) error"); @@ -719,14 +719,14 @@ static void colo_incoming_process_checkpoint(Migratio= nIncomingState *mis, return; } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); vmstate_loading =3D true; colo_flush_ram_cache(); ret =3D qemu_load_device_state(fb); if (ret < 0) { error_setg(errp, "COLO: load device state failed"); vmstate_loading =3D false; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } =20 @@ -734,7 +734,7 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, if (local_err) { error_propagate(errp, local_err); vmstate_loading =3D false; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } =20 @@ -743,7 +743,7 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, if (local_err) { error_propagate(errp, local_err); vmstate_loading =3D false; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } /* Notify all filters of all NIC to do checkpoint */ @@ -752,13 +752,13 @@ static void colo_incoming_process_checkpoint(Migratio= nIncomingState *mis, if (local_err) { error_propagate(errp, local_err); vmstate_loading =3D false; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } =20 vmstate_loading =3D false; vm_start(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); trace_colo_vm_state_change("stop", "run"); =20 if (failover_get_state() =3D=3D FAILOVER_STATUS_RELAUNCH) { @@ -851,14 +851,14 @@ static void *colo_process_incoming_thread(void *opaqu= e) fb =3D qemu_file_new_input(QIO_CHANNEL(bioc)); object_unref(OBJECT(bioc)); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); replication_start_all(REPLICATION_MODE_SECONDARY, &local_err); if (local_err) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); goto out; } vm_start(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); trace_colo_vm_state_change("stop", "run"); =20 colo_send_message(mis->to_src_file, COLO_MESSAGE_CHECKPOINT_READY, @@ -920,7 +920,7 @@ int coroutine_fn colo_incoming_co(void) Error *local_err =3D NULL; QemuThread th; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 if (!migration_incoming_colo_enabled()) { return 0; @@ -940,10 +940,10 @@ int coroutine_fn colo_incoming_co(void) qemu_coroutine_yield(); mis->colo_incoming_co =3D NULL; =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); /* Wait checkpoint incoming thread exit before free resource */ qemu_thread_join(&th); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 /* We hold the global iothread lock, so it is safe here */ colo_release_ram_cache(); diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index 036ac017fc..1d705092cd 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -90,13 +90,13 @@ static int64_t do_calculate_dirtyrate(DirtyPageRecord d= irty_pages, =20 void global_dirty_log_change(unsigned int flag, bool start) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if (start) { memory_global_dirty_log_start(flag); } else { memory_global_dirty_log_stop(flag); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* @@ -106,12 +106,12 @@ void global_dirty_log_change(unsigned int flag, bool = start) */ static void global_dirty_log_sync(unsigned int flag, bool one_shot) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); memory_global_dirty_log_sync(false); if (one_shot) { memory_global_dirty_log_stop(flag); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat) @@ -610,7 +610,7 @@ static void calculate_dirtyrate_dirty_bitmap(struct Dir= tyRateConfig config) int64_t start_time; DirtyPageRecord dirty_pages; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE); =20 /* @@ -627,7 +627,7 @@ static void calculate_dirtyrate_dirty_bitmap(struct Dir= tyRateConfig config) * KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE cap is enabled. */ dirtyrate_manual_reset_protect(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 record_dirtypages_bitmap(&dirty_pages, true); =20 diff --git a/migration/migration.c b/migration/migration.c index 28a34c9068..b153133fba 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1293,12 +1293,12 @@ static void migrate_fd_cleanup(MigrationState *s) QEMUFile *tmp; =20 trace_migrate_fd_cleanup(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (s->migration_thread_running) { qemu_thread_join(&s->thread); s->migration_thread_running =3D false; } - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 multifd_save_cleanup(); qemu_mutex_lock(&s->qemu_file_lock); @@ -2410,7 +2410,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) } =20 trace_postcopy_start(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); trace_postcopy_start_set_run(); =20 migration_downtime_start(ms); @@ -2519,7 +2519,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) =20 migration_downtime_end(ms); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (migrate_postcopy_ram()) { /* @@ -2560,7 +2560,7 @@ fail: error_report_err(local_err); } } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return -1; } =20 @@ -2594,14 +2594,14 @@ static int migration_maybe_pause(MigrationState *s, * wait for the 'pause_sem' semaphore. */ if (s->state !=3D MIGRATION_STATUS_CANCELLING) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); migrate_set_state(&s->state, *current_active_state, MIGRATION_STATUS_PRE_SWITCHOVER); qemu_sem_wait(&s->pause_sem); migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER, new_state); *current_active_state =3D new_state; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 return s->state =3D=3D new_state ? 0 : -EINVAL; @@ -2612,7 +2612,7 @@ static int migration_completion_precopy(MigrationStat= e *s, { int ret; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); migration_downtime_start(s); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); =20 @@ -2640,7 +2640,7 @@ static int migration_completion_precopy(MigrationStat= e *s, ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file, false, s->block_inactive); out_unlock: - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return ret; } =20 @@ -2648,9 +2648,9 @@ static void migration_completion_postcopy(MigrationSt= ate *s) { trace_migration_completion_postcopy_end(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_savevm_state_complete_postcopy(s->to_dst_file); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 /* * Shutdown the postcopy fast path thread. This is only needed when d= est @@ -2674,14 +2674,14 @@ static void migration_completion_failed(MigrationSt= ate *s, */ Error *local_err =3D NULL; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); bdrv_activate_all(&local_err); if (local_err) { error_report_err(local_err); } else { s->block_inactive =3D false; } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 migrate_set_state(&s->state, current_active_state, @@ -3121,7 +3121,7 @@ static void migration_iteration_finish(MigrationState= *s) /* If we enabled cpu throttling for auto-converge, turn it off. */ cpu_throttle_stop(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); switch (s->state) { case MIGRATION_STATUS_COMPLETED: migration_calculate_complete(s); @@ -3152,7 +3152,7 @@ static void migration_iteration_finish(MigrationState= *s) break; } migrate_fd_cleanup_schedule(s); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 static void bg_migration_iteration_finish(MigrationState *s) @@ -3164,7 +3164,7 @@ static void bg_migration_iteration_finish(MigrationSt= ate *s) */ ram_write_tracking_stop(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); switch (s->state) { case MIGRATION_STATUS_COMPLETED: migration_calculate_complete(s); @@ -3183,7 +3183,7 @@ static void bg_migration_iteration_finish(MigrationSt= ate *s) } =20 migrate_fd_cleanup_schedule(s); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* @@ -3305,9 +3305,9 @@ static void *migration_thread(void *opaque) object_ref(OBJECT(s)); update_iteration_initial_status(s); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_savevm_state_header(s->to_dst_file); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 /* * If we opened the return path, we need to make sure dst has it @@ -3335,9 +3335,9 @@ static void *migration_thread(void *opaque) qemu_savevm_send_colo_enable(s->to_dst_file); } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_savevm_state_setup(s->to_dst_file); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); @@ -3448,10 +3448,10 @@ static void *bg_migration_thread(void *opaque) ram_write_tracking_prepare(); #endif =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_savevm_state_header(s->to_dst_file); qemu_savevm_state_setup(s->to_dst_file); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); @@ -3461,7 +3461,7 @@ static void *bg_migration_thread(void *opaque) trace_migration_thread_setup_complete(); migration_downtime_start(s); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 /* * If VM is currently in suspended state, then, to make a valid runsta= te @@ -3504,7 +3504,7 @@ static void *bg_migration_thread(void *opaque) s->vm_start_bh =3D qemu_bh_new(bg_migration_vm_start_bh, s); qemu_bh_schedule(s->vm_start_bh); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 while (migration_is_active(s)) { MigIterateState iter_state =3D bg_migration_iteration_run(s); @@ -3533,7 +3533,7 @@ fail: if (early_fail) { migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 bg_migration_iteration_finish(s); diff --git a/migration/ram.c b/migration/ram.c index 8c7886ab79..f274bcf655 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2984,9 +2984,9 @@ static int ram_save_setup(QEMUFile *f, void *opaque) migration_ops =3D g_malloc0(sizeof(MigrationOps)); migration_ops->ram_save_target_page =3D ram_save_target_page_legacy; =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); ret =3D multifd_send_sync_main(f); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if (ret < 0) { return ret; } @@ -3221,11 +3221,11 @@ static void ram_state_pending_exact(void *opaque, u= int64_t *must_precopy, uint64_t remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SI= ZE; =20 if (!migration_in_postcopy() && remaining_size < s->threshold_size) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); WITH_RCU_READ_LOCK_GUARD() { migration_bitmap_sync_precopy(rs, false); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; } =20 @@ -3453,7 +3453,7 @@ void colo_incoming_start_dirty_log(void) { RAMBlock *block =3D NULL; /* For memory_global_dirty_log_start below. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_mutex_lock_ramlist(); =20 memory_global_dirty_log_sync(false); @@ -3467,7 +3467,7 @@ void colo_incoming_start_dirty_log(void) } ram_state->migration_dirty_pages =3D 0; qemu_mutex_unlock_ramlist(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* It is need to hold the global lock to call this helper */ diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 77d0c82327..04c9c6374b 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -216,7 +216,7 @@ void replay_mutex_lock(void) { if (replay_mode !=3D REPLAY_MODE_NONE) { unsigned long id; - g_assert(!qemu_mutex_iothread_locked()); + g_assert(!qemu_bql_locked()); g_assert(!replay_mutex_locked()); qemu_mutex_lock(&lock); id =3D mutex_tail++; diff --git a/semihosting/console.c b/semihosting/console.c index 5d61e8207e..666285541d 100644 --- a/semihosting/console.c +++ b/semihosting/console.c @@ -43,7 +43,7 @@ static SemihostingConsole console; static int console_can_read(void *opaque) { SemihostingConsole *c =3D opaque; - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); return (int)fifo8_num_free(&c->fifo); } =20 @@ -58,7 +58,7 @@ static void console_wake_up(gpointer data, gpointer user_= data) static void console_read(void *opaque, const uint8_t *buf, int size) { SemihostingConsole *c =3D opaque; - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); while (size-- && !fifo8_is_full(&c->fifo)) { fifo8_push(&c->fifo, *buf++); } @@ -70,7 +70,7 @@ bool qemu_semihosting_console_ready(void) { SemihostingConsole *c =3D &console; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); return !fifo8_is_empty(&c->fifo); } =20 @@ -78,7 +78,7 @@ void qemu_semihosting_console_block_until_ready(CPUState = *cs) { SemihostingConsole *c =3D &console; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 /* Block if the fifo is completely empty. */ if (fifo8_is_empty(&c->fifo)) { diff --git a/stubs/iothread-lock.c b/stubs/iothread-lock.c index 5b45b7fc8b..1f24c3203a 100644 --- a/stubs/iothread-lock.c +++ b/stubs/iothread-lock.c @@ -1,15 +1,15 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" =20 -bool qemu_mutex_iothread_locked(void) +bool qemu_bql_locked(void) { return false; } =20 -void qemu_mutex_lock_iothread_impl(const char *file, int line) +void qemu_bql_lock_impl(const char *file, int line) { } =20 -void qemu_mutex_unlock_iothread(void) +void qemu_bql_unlock(void) { } diff --git a/system/cpu-throttle.c b/system/cpu-throttle.c index d9bb30a223..e98836311b 100644 --- a/system/cpu-throttle.c +++ b/system/cpu-throttle.c @@ -57,9 +57,9 @@ static void cpu_throttle_thread(CPUState *cpu, run_on_cpu= _data opaque) qemu_cond_timedwait_iothread(cpu->halt_cond, sleeptime_ns / SCALE_MS); } else { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); g_usleep(sleeptime_ns / SCALE_US); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } sleeptime_ns =3D endtime_ns - qemu_clock_get_ns(QEMU_CLOCK_REALTIM= E); } diff --git a/system/cpus.c b/system/cpus.c index a444a747f0..d5b98c11f5 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -481,35 +481,35 @@ bool qemu_in_vcpu_thread(void) return current_cpu && qemu_cpu_is_self(current_cpu); } =20 -QEMU_DEFINE_STATIC_CO_TLS(bool, iothread_locked) +QEMU_DEFINE_STATIC_CO_TLS(bool, bql_locked) =20 -bool qemu_mutex_iothread_locked(void) +bool qemu_bql_locked(void) { - return get_iothread_locked(); + return get_bql_locked(); } =20 bool qemu_in_main_thread(void) { - return qemu_mutex_iothread_locked(); + return qemu_bql_locked(); } =20 /* * The BQL is taken from so many places that it is worth profiling the * callers directly, instead of funneling them all through a single functi= on. */ -void qemu_mutex_lock_iothread_impl(const char *file, int line) +void qemu_bql_lock_impl(const char *file, int line) { QemuMutexLockFunc bql_lock =3D qatomic_read(&qemu_bql_mutex_lock_func); =20 - g_assert(!qemu_mutex_iothread_locked()); + g_assert(!qemu_bql_locked()); bql_lock(&qemu_global_mutex, file, line); - set_iothread_locked(true); + set_bql_locked(true); } =20 -void qemu_mutex_unlock_iothread(void) +void qemu_bql_unlock(void) { - g_assert(qemu_mutex_iothread_locked()); - set_iothread_locked(false); + g_assert(qemu_bql_locked()); + set_bql_locked(false); qemu_mutex_unlock(&qemu_global_mutex); } =20 @@ -577,9 +577,9 @@ void pause_all_vcpus(void) } } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); replay_mutex_lock(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 void cpu_resume(CPUState *cpu) @@ -608,9 +608,9 @@ void cpu_remove_sync(CPUState *cpu) cpu->stop =3D true; cpu->unplug =3D true; qemu_cpu_kick(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_thread_join(cpu->thread); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 void cpus_register_accel(const AccelOpsClass *ops) diff --git a/system/dirtylimit.c b/system/dirtylimit.c index 495c7a7082..f89bf6b61f 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -148,9 +148,9 @@ void vcpu_dirty_rate_stat_stop(void) { qatomic_set(&vcpu_dirty_rate_stat->running, 0); dirtylimit_state_unlock(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_thread_join(&vcpu_dirty_rate_stat->thread); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); dirtylimit_state_lock(); } =20 diff --git a/system/memory.c b/system/memory.c index 4d9cb0a7ff..8d78334cb2 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1119,7 +1119,7 @@ void memory_region_transaction_commit(void) AddressSpace *as; =20 assert(memory_region_transaction_depth); - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 --memory_region_transaction_depth; if (!memory_region_transaction_depth) { diff --git a/system/physmem.c b/system/physmem.c index a63853a7bc..c136675876 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2639,8 +2639,8 @@ bool prepare_mmio_access(MemoryRegion *mr) { bool release_lock =3D false; =20 - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); + if (!qemu_bql_locked()) { + qemu_bql_lock(); release_lock =3D true; } if (mr->flush_coalesced_mmio) { @@ -2721,7 +2721,7 @@ static MemTxResult flatview_write_continue(FlatView *= fv, hwaddr addr, } =20 if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); release_lock =3D false; } =20 @@ -2799,7 +2799,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwad= dr addr, } =20 if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); release_lock =3D false; } =20 diff --git a/system/runstate.c b/system/runstate.c index ea9d6c2a32..5718e6827c 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -810,7 +810,7 @@ void qemu_init_subsystems(void) =20 qemu_init_cpu_list(); qemu_init_cpu_loop(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 atexit(qemu_run_exit_notifiers); =20 diff --git a/system/watchpoint.c b/system/watchpoint.c index ba5ad13352..d9cc71dd33 100644 --- a/system/watchpoint.c +++ b/system/watchpoint.c @@ -155,9 +155,9 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, va= ddr len, * Now raise the debug interrupt so that it will * trigger after the current instruction. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } =20 diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c index c078849403..aec104834d 100644 --- a/target/arm/arm-powerctl.c +++ b/target/arm/arm-powerctl.c @@ -88,7 +88,7 @@ static void arm_set_cpu_on_async_work(CPUState *target_cp= u_state, g_free(info); =20 /* Finally set the power status */ - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); target_cpu->power_state =3D PSCI_ON; } =20 @@ -99,7 +99,7 @@ int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64= _t context_id, ARMCPU *target_cpu; struct CpuOnInfo *info; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 DPRINTF("cpu %" PRId64 " (EL %d, %s) @ 0x%" PRIx64 " with R0 =3D 0x%" = PRIx64 "\n", cpuid, target_el, target_aa64 ? "aarch64" : "aarch32", e= ntry, @@ -196,7 +196,7 @@ static void arm_set_cpu_on_and_reset_async_work(CPUStat= e *target_cpu_state, target_cpu_state->halted =3D 0; =20 /* Finally set the power status */ - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); target_cpu->power_state =3D PSCI_ON; } =20 @@ -205,7 +205,7 @@ int arm_set_cpu_on_and_reset(uint64_t cpuid) CPUState *target_cpu_state; ARMCPU *target_cpu; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 /* Retrieve the cpu we are powering up */ target_cpu_state =3D arm_get_cpu_by_id(cpuid); @@ -247,7 +247,7 @@ static void arm_set_cpu_off_async_work(CPUState *target= _cpu_state, { ARMCPU *target_cpu =3D ARM_CPU(target_cpu_state); =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); target_cpu->power_state =3D PSCI_OFF; target_cpu_state->halted =3D 1; target_cpu_state->exception_index =3D EXCP_HLT; @@ -258,7 +258,7 @@ int arm_set_cpu_off(uint64_t cpuid) CPUState *target_cpu_state; ARMCPU *target_cpu; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 DPRINTF("cpu %" PRId64 "\n", cpuid); =20 @@ -294,7 +294,7 @@ int arm_reset_cpu(uint64_t cpuid) CPUState *target_cpu_state; ARMCPU *target_cpu; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 DPRINTF("cpu %" PRId64 "\n", cpuid); =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index 2746d3fdac..f472043986 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5831,7 +5831,7 @@ static void do_hcr_write(CPUARMState *env, uint64_t v= alue, uint64_t valid_mask) * VFIQ are masked unless running at EL0 or EL1, and HCR * can only be written at EL2. */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); arm_cpu_update_virq(cpu); arm_cpu_update_vfiq(cpu); arm_cpu_update_vserr(cpu); @@ -11344,7 +11344,7 @@ void arm_cpu_do_interrupt(CPUState *cs) * BQL needs to be held for any modification of * cs->interrupt_request. */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 arm_call_pre_el_change_hook(cpu); =20 diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 757e13b0f9..017fd13c5d 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1718,9 +1718,9 @@ static void hvf_wait_for_ipi(CPUState *cpu, struct ti= mespec *ts) * sleeping. */ qatomic_set_mb(&cpu->thread_kicked, false); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); pselect(0, 0, 0, 0, ts, &cpu->accel->unblock_ipi_mask); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 static void hvf_wfi(CPUState *cpu) @@ -1821,7 +1821,7 @@ int hvf_vcpu_exec(CPUState *cpu) =20 flush_cpu_state(cpu); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); assert_hvf_ok(hv_vcpu_run(cpu->accel->fd)); =20 /* handle VMEXIT */ @@ -1830,7 +1830,7 @@ int hvf_vcpu_exec(CPUState *cpu) uint32_t ec =3D syn_get_ec(syndrome); =20 ret =3D 0; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); switch (exit_reason) { case HV_EXIT_REASON_EXCEPTION: /* This is the main one, handle below. */ diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7903e2ddde..431b82e509 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -833,7 +833,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_r= un *run) if (run->s.regs.device_irq_level !=3D cpu->device_irq_level) { switched_level =3D cpu->device_irq_level ^ run->s.regs.device_irq_= level; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (switched_level & KVM_ARM_DEV_EL1_VTIMER) { qemu_set_irq(cpu->gt_timer_outputs[GTIMER_VIRT], @@ -862,7 +862,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_r= un *run) =20 /* We also mark unknown levels as processed to not waste cycles */ cpu->device_irq_level =3D run->s.regs.device_irq_level; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 return MEMTXATTRS_UNSPECIFIED; diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 3c175c93a7..282dc5920e 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -1233,9 +1233,9 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_de= bug_exit_arch *debug_exit) env->exception.syndrome =3D debug_exit->hsr; env->exception.vaddress =3D debug_exit->far; env->exception.target_el =3D 1; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); arm_cpu_do_interrupt(cs); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return false; } diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 1762b058ae..e3cc0a7ab8 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -772,9 +772,9 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t= old_val, #if !TCG_OVERSIZED_GUEST # error "Unexpected configuration" #endif - bool locked =3D qemu_mutex_iothread_locked(); + bool locked =3D qemu_bql_locked(); if (!locked) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } if (ptw->out_be) { cur_val =3D ldq_be_p(host); @@ -788,7 +788,7 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t= old_val, } } if (!locked) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif =20 diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 8ad84623d3..22d453e6e0 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -809,9 +809,9 @@ void HELPER(exception_return)(CPUARMState *env, uint64_= t new_pc) goto illegal_return; } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); arm_call_pre_el_change_hook(env_archcpu(env)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (!return_to_aa64) { env->aarch64 =3D false; @@ -876,9 +876,9 @@ void HELPER(exception_return)(CPUARMState *env, uint64_= t new_pc) */ aarch64_sve_change_el(env, cur_el, new_el, return_to_aa64); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); arm_call_el_change_hook(env_archcpu(env)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return; =20 diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index a26adb75aa..5f38b9a4a1 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -374,7 +374,7 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) bool take_exception; =20 /* Take the iothread lock as we are going to touch the NVIC */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 /* Check the background context had access to the FPU */ if (!v7m_cpacr_pass(env, is_secure, is_priv)) { @@ -428,7 +428,7 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) take_exception =3D !stacked_ok && armv7m_nvic_can_take_pending_exception(env->nvic); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (take_exception) { raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC()); diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index ea08936a85..46a14aac52 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -427,9 +427,9 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t= val) { uint32_t mask; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); arm_call_pre_el_change_hook(env_archcpu(env)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 mask =3D aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isa= r); cpsr_write(env, val, mask, CPSRWriteExceptionReturn); @@ -442,9 +442,9 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t= val) env->regs[15] &=3D (env->thumb ? ~1 : ~3); arm_rebuild_hflags(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); arm_call_el_change_hook(env_archcpu(env)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* Access to user mode registers from privileged modes. */ @@ -803,9 +803,9 @@ void HELPER(set_cp_reg)(CPUARMState *env, const void *r= ip, uint32_t value) const ARMCPRegInfo *ri =3D rip; =20 if (ri->type & ARM_CP_IO) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ri->writefn(env, ri, value); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } else { ri->writefn(env, ri, value); } @@ -817,9 +817,9 @@ uint32_t HELPER(get_cp_reg)(CPUARMState *env, const voi= d *rip) uint32_t res; =20 if (ri->type & ARM_CP_IO) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); res =3D ri->readfn(env, ri); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } else { res =3D ri->readfn(env, ri); } @@ -832,9 +832,9 @@ void HELPER(set_cp_reg64)(CPUARMState *env, const void = *rip, uint64_t value) const ARMCPRegInfo *ri =3D rip; =20 if (ri->type & ARM_CP_IO) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ri->writefn(env, ri, value); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } else { ri->writefn(env, ri, value); } @@ -846,9 +846,9 @@ uint64_t HELPER(get_cp_reg64)(CPUARMState *env, const v= oid *rip) uint64_t res; =20 if (ri->type & ARM_CP_IO) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); res =3D ri->readfn(env, ri); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } else { res =3D ri->readfn(env, ri); } diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c index 6c1239bb96..51af10db99 100644 --- a/target/arm/tcg/psci.c +++ b/target/arm/tcg/psci.c @@ -107,7 +107,7 @@ void arm_handle_psci_call(ARMCPU *cpu) } target_cpu =3D ARM_CPU(target_cpu_state); =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); ret =3D target_cpu->power_state; break; default: diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 98e9d688f6..9ef8cf7ff4 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -84,17 +84,17 @@ void hppa_cpu_alarm_timer(void *opaque) void HELPER(write_eirr)(CPUHPPAState *env, target_ulong val) { env->cr[CR_EIRR] &=3D ~val; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); eval_interrupt(env_archcpu(env)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(write_eiem)(CPUHPPAState *env, target_ulong val) { env->cr[CR_EIEM] =3D val; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); eval_interrupt(env_archcpu(env)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void hppa_cpu_do_interrupt(CPUState *cs) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 20b9ca3ef5..2cc8b115f7 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -429,9 +429,9 @@ int hvf_vcpu_exec(CPUState *cpu) } vmx_update_tpr(cpu); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (!cpu_is_bsp(X86_CPU(cpu)) && cpu->halted) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); return EXCP_HLT; } =20 @@ -450,7 +450,7 @@ int hvf_vcpu_exec(CPUState *cpu) rip =3D rreg(cpu->accel->fd, HV_X86_RIP); env->eflags =3D rreg(cpu->accel->fd, HV_X86_RFLAGS); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 update_apic_tpr(cpu); current_cpu =3D cpu; diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c index e3ac978648..dcad09f6c9 100644 --- a/target/i386/kvm/hyperv.c +++ b/target/i386/kvm/hyperv.c @@ -45,9 +45,9 @@ void hyperv_x86_synic_update(X86CPU *cpu) =20 static void async_synic_update(CPUState *cs, run_on_cpu_data data) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); hyperv_x86_synic_update(X86_CPU(cs)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 11b8177eff..084f5e6b8b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -4705,9 +4705,9 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) /* Inject NMI */ if (cpu->interrupt_request & (CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) { if (cpu->interrupt_request & CPU_INTERRUPT_NMI) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu->interrupt_request &=3D ~CPU_INTERRUPT_NMI; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); DPRINTF("injected NMI\n"); ret =3D kvm_vcpu_ioctl(cpu, KVM_NMI); if (ret < 0) { @@ -4716,9 +4716,9 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) } } if (cpu->interrupt_request & CPU_INTERRUPT_SMI) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu->interrupt_request &=3D ~CPU_INTERRUPT_SMI; - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); DPRINTF("injected SMI\n"); ret =3D kvm_vcpu_ioctl(cpu, KVM_SMI); if (ret < 0) { @@ -4729,7 +4729,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) } =20 if (!kvm_pic_in_kernel()) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 /* Force the VCPU out of its inner loop to process any INIT requests @@ -4782,7 +4782,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) DPRINTF("setting tpr\n"); run->cr8 =3D cpu_get_apic_tpr(x86_cpu->apic_state); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 @@ -4830,12 +4830,12 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct = kvm_run *run) /* We need to protect the apic state against concurrent accesses from * different threads in case the userspace irqchip is used. */ if (!kvm_irqchip_in_kernel()) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } cpu_set_apic_tpr(x86_cpu->apic_state, run->cr8); cpu_set_apic_base(x86_cpu->apic_state, run->apic_base); if (!kvm_irqchip_in_kernel()) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } return cpu_get_mem_attrs(env); } @@ -5269,17 +5269,17 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_r= un *run) switch (run->exit_reason) { case KVM_EXIT_HLT: DPRINTF("handle_hlt\n"); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D kvm_handle_halt(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; case KVM_EXIT_SET_TPR: ret =3D 0; break; case KVM_EXIT_TPR_ACCESS: - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D kvm_handle_tpr_access(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; case KVM_EXIT_FAIL_ENTRY: code =3D run->fail_entry.hardware_entry_failure_reason; @@ -5305,9 +5305,9 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) break; case KVM_EXIT_DEBUG: DPRINTF("kvm_exit_debug\n"); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D kvm_handle_debug(cpu, &run->debug.arch); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; case KVM_EXIT_HYPERV: ret =3D kvm_hv_handle_exit(cpu, &run->hyperv); diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index c0631f9cf4..f79f5d270f 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -403,7 +403,7 @@ void kvm_xen_maybe_deassert_callback(CPUState *cs) =20 /* If the evtchn_upcall_pending flag is cleared, turn the GSI off. */ if (!vi->evtchn_upcall_pending) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); /* * Check again now we have the lock, because it may have been * asserted in the interim. And we don't want to take the lock @@ -413,7 +413,7 @@ void kvm_xen_maybe_deassert_callback(CPUState *cs) X86_CPU(cs)->env.xen_callback_asserted =3D false; xen_evtchn_set_callback_level(0); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 @@ -773,9 +773,9 @@ static bool handle_set_param(struct kvm_xen_exit *exit,= X86CPU *cpu, =20 switch (hp.index) { case HVM_PARAM_CALLBACK_IRQ: - qemu_mutex_lock_iothread(); + qemu_bql_lock(); err =3D xen_evtchn_set_callback_param(hp.value); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); xen_set_long_mode(exit->u.hcall.longmode); break; default: @@ -1408,7 +1408,7 @@ int kvm_xen_soft_reset(void) CPUState *cpu; int err; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 trace_kvm_xen_soft_reset(); =20 @@ -1481,9 +1481,9 @@ static int schedop_shutdown(CPUState *cs, uint64_t ar= g) break; =20 case SHUTDOWN_soft_reset: - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D kvm_xen_soft_reset(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; =20 default: diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-acce= l-ops.c index 6c46101ac1..387ccfcce5 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -25,7 +25,7 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg) =20 rcu_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); cpu->thread_id =3D qemu_get_thread_id(); current_cpu =3D cpu; @@ -55,7 +55,7 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg) =20 nvmm_destroy_vcpu(cpu); cpu_thread_signal_destroyed(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); rcu_unregister_thread(); return NULL; } diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index 7d752bc5e0..9fa5b2e34a 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -399,7 +399,7 @@ nvmm_vcpu_pre_run(CPUState *cpu) uint8_t tpr; int ret; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); if (tpr !=3D qcpu->tpr) { @@ -462,7 +462,7 @@ nvmm_vcpu_pre_run(CPUState *cpu) } } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* @@ -485,9 +485,9 @@ nvmm_vcpu_post_run(CPUState *cpu, struct nvmm_vcpu_exit= *exit) tpr =3D exit->exitstate.cr8; if (qcpu->tpr !=3D tpr) { qcpu->tpr =3D tpr; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_set_apic_tpr(x86_cpu->apic_state, qcpu->tpr); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 @@ -648,7 +648,7 @@ nvmm_handle_halted(struct nvmm_machine *mach, CPUState = *cpu, CPUX86State *env =3D cpu_env(cpu); int ret =3D 0; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) && @@ -658,7 +658,7 @@ nvmm_handle_halted(struct nvmm_machine *mach, CPUState = *cpu, ret =3D 1; } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return ret; } @@ -721,7 +721,7 @@ nvmm_vcpu_loop(CPUState *cpu) return 0; } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); cpu_exec_start(cpu); =20 /* @@ -806,16 +806,16 @@ nvmm_vcpu_loop(CPUState *cpu) error_report("NVMM: Unexpected VM exit code 0x%lx [hw=3D0x%lx]= ", exit->reason, exit->u.inv.hwcode); nvmm_get_registers(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_system_guest_panicked(cpu_get_crash_info(cpu)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); ret =3D -1; break; } } while (ret =3D=3D 0); =20 cpu_exec_end(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 qatomic_set(&cpu->exit_request, false); =20 diff --git a/target/i386/tcg/sysemu/fpu_helper.c b/target/i386/tcg/sysemu/f= pu_helper.c index 93506cdd94..4960e97ebc 100644 --- a/target/i386/tcg/sysemu/fpu_helper.c +++ b/target/i386/tcg/sysemu/fpu_helper.c @@ -32,9 +32,9 @@ void x86_register_ferr_irq(qemu_irq irq) void fpu_check_raise_ferr_irq(CPUX86State *env) { if (ferr_irq && !(env->hflags2 & HF2_IGNNE_MASK)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_irq_raise(ferr_irq); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } } @@ -49,7 +49,7 @@ void cpu_set_ignne(void) { CPUX86State *env =3D &X86_CPU(first_cpu)->env; =20 - assert(qemu_mutex_iothread_locked()); + assert(qemu_bql_locked()); =20 env->hflags2 |=3D HF2_IGNNE_MASK; /* diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index e1528b7f80..e859879f4f 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -118,9 +118,9 @@ void helper_write_crN(CPUX86State *env, int reg, target= _ulong t0) break; case 8: if (!(env->hflags2 & HF2_VINTR_MASK)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_set_apic_tpr(env_archcpu(env)->apic_state, t0); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } env->int_ctl =3D (env->int_ctl & ~V_TPR_MASK) | (t0 & V_TPR_MASK); =20 diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-acce= l-ops.c index 67cad86720..1f29346a88 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -25,7 +25,7 @@ static void *whpx_cpu_thread_fn(void *arg) =20 rcu_register_thread(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_thread_get_self(cpu->thread); cpu->thread_id =3D qemu_get_thread_id(); current_cpu =3D cpu; @@ -55,7 +55,7 @@ static void *whpx_cpu_thread_fn(void *arg) =20 whpx_destroy_vcpu(cpu); cpu_thread_signal_destroyed(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); rcu_unregister_thread(); return NULL; } diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index d29ba916a0..50057b22ee 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1324,7 +1324,7 @@ static int whpx_first_vcpu_starting(CPUState *cpu) struct whpx_state *whpx =3D &whpx_global; HRESULT hr; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 if (!QTAILQ_EMPTY(&cpu->breakpoints) || (whpx->breakpoints.breakpoints && @@ -1442,7 +1442,7 @@ static int whpx_handle_halt(CPUState *cpu) CPUX86State *env =3D cpu_env(cpu); int ret =3D 0; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) && !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) { @@ -1450,7 +1450,7 @@ static int whpx_handle_halt(CPUState *cpu) cpu->halted =3D true; ret =3D 1; } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return ret; } @@ -1472,7 +1472,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) memset(&new_int, 0, sizeof(new_int)); memset(reg_values, 0, sizeof(reg_values)); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 /* Inject NMI */ if (!vcpu->interruption_pending && @@ -1563,7 +1563,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) reg_count +=3D 1; } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); vcpu->ready_for_pic_interrupt =3D false; =20 if (reg_count) { @@ -1590,9 +1590,9 @@ static void whpx_vcpu_post_run(CPUState *cpu) uint64_t tpr =3D vcpu->exit_ctx.VpContext.Cr8; if (vcpu->tpr !=3D tpr) { vcpu->tpr =3D tpr; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_set_apic_tpr(x86_cpu->apic_state, whpx_cr8_to_apic_tpr(vcpu->t= pr)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 vcpu->interruption_pending =3D @@ -1652,7 +1652,7 @@ static int whpx_vcpu_run(CPUState *cpu) WhpxStepMode exclusive_step_mode =3D WHPX_STEP_NONE; int ret; =20 - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 if (whpx->running_cpus++ =3D=3D 0) { /* Insert breakpoints into memory, update exception exit bitmap. */ @@ -1690,7 +1690,7 @@ static int whpx_vcpu_run(CPUState *cpu) } } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (exclusive_step_mode !=3D WHPX_STEP_NONE) { start_exclusive(); @@ -2028,9 +2028,9 @@ static int whpx_vcpu_run(CPUState *cpu) error_report("WHPX: Unexpected VP exit code %d", vcpu->exit_ctx.ExitReason); whpx_get_registers(cpu); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); qemu_system_guest_panicked(cpu_get_crash_info(cpu)); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; } =20 @@ -2055,7 +2055,7 @@ static int whpx_vcpu_run(CPUState *cpu) cpu_exec_end(cpu); } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); current_cpu =3D cpu; =20 if (--whpx->running_cpus =3D=3D 0) { diff --git a/target/loongarch/csr_helper.c b/target/loongarch/csr_helper.c index 55341551a5..fa3f08335e 100644 --- a/target/loongarch/csr_helper.c +++ b/target/loongarch/csr_helper.c @@ -89,9 +89,9 @@ target_ulong helper_csrwr_ticlr(CPULoongArchState *env, t= arget_ulong val) int64_t old_v =3D 0; =20 if (val & 0x1) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); loongarch_cpu_set_irq(cpu, IRQ_TIMER, 0); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } return old_v; } diff --git a/target/mips/kvm.c b/target/mips/kvm.c index e22e24ed97..7e2bac9a84 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -138,7 +138,7 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) int r; struct kvm_mips_interrupt intr; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if ((cs->interrupt_request & CPU_INTERRUPT_HARD) && cpu_mips_io_interrupts_pending(cpu)) { @@ -151,7 +151,7 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) } } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) diff --git a/target/mips/tcg/sysemu/cp0_helper.c b/target/mips/tcg/sysemu/c= p0_helper.c index d349548743..fe87b72a2c 100644 --- a/target/mips/tcg/sysemu/cp0_helper.c +++ b/target/mips/tcg/sysemu/cp0_helper.c @@ -59,9 +59,9 @@ static inline void mips_vpe_wake(MIPSCPU *c) * because there might be other conditions that state that c should * be sleeping. */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_interrupt(CPU(c), CPU_INTERRUPT_WAKE); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 static inline void mips_vpe_sleep(MIPSCPU *cpu) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 782a5751b7..1e9a55cec1 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -160,20 +160,20 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulon= g spr, target_ulong rb) break; case TO_SPR(9, 0): /* PICMR */ env->picmr =3D rb; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if (env->picsr & env->picmr) { cpu_interrupt(cs, CPU_INTERRUPT_HARD); } else { cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; case TO_SPR(9, 2): /* PICSR */ env->picsr &=3D ~rb; break; case TO_SPR(10, 0): /* TTMR */ { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if ((env->ttmr & TTMR_M) ^ (rb & TTMR_M)) { switch (rb & TTMR_M) { case TIMER_NONE: @@ -198,15 +198,15 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulon= g spr, target_ulong rb) cs->interrupt_request &=3D ~CPU_INTERRUPT_TIMER; } cpu_openrisc_timer_update(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } break; =20 case TO_SPR(10, 1): /* TTCR */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_openrisc_count_set(cpu, rb); cpu_openrisc_timer_update(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; } #endif @@ -347,9 +347,9 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, targe= t_ulong rd, return env->ttmr; =20 case TO_SPR(10, 1): /* TTCR */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_openrisc_count_update(cpu); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return cpu_openrisc_count_get(cpu); } #endif diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index a42743a3e0..0a1c942831 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -3056,7 +3056,7 @@ void helper_msgsnd(target_ulong rb) return; } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *cenv =3D &cpu->env; @@ -3065,7 +3065,7 @@ void helper_msgsnd(target_ulong rb) ppc_set_irq(cpu, irq, 1); } } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 /* Server Processor Control */ @@ -3093,7 +3093,7 @@ static void book3s_msgsnd_common(int pir, int irq) { CPUState *cs; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *cenv =3D &cpu->env; @@ -3103,7 +3103,7 @@ static void book3s_msgsnd_common(int pir, int irq) ppc_set_irq(cpu, irq, 1); } } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void helper_book3s_msgsnd(target_ulong rb) @@ -3157,14 +3157,14 @@ void helper_book3s_msgsndp(CPUPPCState *env, target= _ulong rb) } =20 /* Does iothread need to be locked for walking CPU list? */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); THREAD_SIBLING_FOREACH(cs, ccs) { PowerPCCPU *ccpu =3D POWERPC_CPU(ccs); uint32_t thread_id =3D ppc_cpu_tir(ccpu); =20 if (ttir =3D=3D thread_id) { ppc_set_irq(ccpu, PPC_INTERRUPT_DOORBELL, 1); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return; } } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 9b1abe2fc4..132834505c 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1656,7 +1656,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) CPUPPCState *env =3D &cpu->env; int ret; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 switch (run->exit_reason) { case KVM_EXIT_DCR: @@ -1715,7 +1715,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) break; } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return ret; } =20 diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index a05bdf78c9..41ef14bf24 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -238,7 +238,7 @@ target_ulong helper_load_dpdes(CPUPPCState *env) return dpdes; } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); THREAD_SIBLING_FOREACH(cs, ccs) { PowerPCCPU *ccpu =3D POWERPC_CPU(ccs); CPUPPCState *cenv =3D &ccpu->env; @@ -248,7 +248,7 @@ target_ulong helper_load_dpdes(CPUPPCState *env) dpdes |=3D (0x1 << thread_id); } } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return dpdes; } @@ -278,14 +278,14 @@ void helper_store_dpdes(CPUPPCState *env, target_ulon= g val) } =20 /* Does iothread need to be locked for walking CPU list? */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); THREAD_SIBLING_FOREACH(cs, ccs) { PowerPCCPU *ccpu =3D POWERPC_CPU(ccs); uint32_t thread_id =3D ppc_cpu_tir(ccpu); =20 ppc_set_irq(cpu, PPC_INTERRUPT_DOORBELL, val & (0x1 << thread_id)); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif /* defined(TARGET_PPC64) */ =20 diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 08a6b47ee0..4cc0572fad 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -173,9 +173,9 @@ target_ulong helper_load_dcr(CPUPPCState *env, target_u= long dcrn) } else { int ret; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D ppc_dcr_read(env->dcr_env, (uint32_t)dcrn, &val); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (unlikely(ret !=3D 0)) { qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n", (uint32_t)dcrn, (uint32_t)dcrn); @@ -196,9 +196,9 @@ void helper_store_dcr(CPUPPCState *env, target_ulong dc= rn, target_ulong val) POWERPC_EXCP_INVAL_INVAL, GETPC()); } else { int ret; - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ret =3D ppc_dcr_write(env->dcr_env, (uint32_t)dcrn, (uint32_t)val); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (unlikely(ret !=3D 0)) { qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n", (uint32_t)dcrn, (uint32_t)dcrn); diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 33ab3551f4..27533d0401 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1923,7 +1923,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) S390CPU *cpu =3D S390_CPU(cs); int ret =3D 0; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 kvm_cpu_synchronize_state(cs); =20 @@ -1947,7 +1947,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) fprintf(stderr, "Unknown KVM exit: %d\n", run->exit_reason); break; } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (ret =3D=3D 0) { ret =3D EXCP_INTERRUPT; diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c index 6aa7907438..4be69c5ae8 100644 --- a/target/s390x/tcg/misc_helper.c +++ b/target/s390x/tcg/misc_helper.c @@ -101,9 +101,9 @@ uint64_t HELPER(stck)(CPUS390XState *env) /* SCLP service call */ uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); int r =3D sclp_service_call(env_archcpu(env), r1, r2); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); if (r < 0) { tcg_s390_program_interrupt(env, -r, GETPC()); } @@ -117,9 +117,9 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint= 32_t r3, uint32_t num) switch (num) { case 0x500: /* KVM hypercall */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); r =3D s390_virtio_hypercall(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); break; case 0x44: /* yield */ @@ -127,9 +127,9 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint= 32_t r3, uint32_t num) break; case 0x308: /* ipl */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); handle_diag_308(env, r1, r3, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); r =3D 0; break; case 0x288: @@ -185,7 +185,7 @@ static void update_ckc_timer(CPUS390XState *env) =20 /* stop the timer and remove pending CKC IRQs */ timer_del(env->tod_timer); - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); env->pending_int &=3D ~INTERRUPT_EXT_CLOCK_COMPARATOR; =20 /* the tod has to exceed the ckc, this can never happen if ckc is all = 1's */ @@ -207,9 +207,9 @@ void HELPER(sckc)(CPUS390XState *env, uint64_t ckc) { env->ckc =3D ckc; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); update_ckc_timer(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) @@ -229,9 +229,9 @@ uint32_t HELPER(sck)(CPUS390XState *env, uint64_t tod_l= ow) .low =3D tod_low, }; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); tdc->set(td, &tod, &error_abort); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return 0; } =20 @@ -421,9 +421,9 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t orde= r_code, uint32_t r1, int cc; =20 /* TODO: needed to inject interrupts - push further down */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cc =3D handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 return cc; } @@ -433,92 +433,92 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t or= der_code, uint32_t r1, void HELPER(xsch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_xsch(cpu, r1, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(csch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_csch(cpu, r1, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(hsch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_hsch(cpu, r1, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(msch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_msch(cpu, r1, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(rchp)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_rchp(cpu, r1, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(rsch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_rsch(cpu, r1, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(sal)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_sal(cpu, r1, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(schm)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint64_t i= nst) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_schm(cpu, r1, r2, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(ssch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_ssch(cpu, r1, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(stcrw)(CPUS390XState *env, uint64_t inst) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_stcrw(cpu, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(stsch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_stsch(cpu, r1, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr) @@ -533,10 +533,10 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t add= r) tcg_s390_program_interrupt(env, PGM_SPECIFICATION, ra); } =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); io =3D qemu_s390_flic_dequeue_io(flic, env->cregs[6]); if (!io) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return 0; } =20 @@ -554,7 +554,7 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr) if (s390_cpu_virt_mem_write(cpu, addr, 0, &intc, sizeof(intc))) { /* writing failed, reinject and properly clean up */ s390_io_interrupt(io->id, io->nr, io->parm, io->word); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); g_free(io); s390_cpu_virt_mem_handle_exc(cpu, ra); return 0; @@ -570,24 +570,24 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t add= r) } =20 g_free(io); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return 1; } =20 void HELPER(tsch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_tsch(cpu, r1, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(chsc)(CPUS390XState *env, uint64_t inst) { S390CPU *cpu =3D env_archcpu(env); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); ioinst_handle_chsc(cpu, inst >> 16, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif =20 @@ -726,27 +726,27 @@ void HELPER(clp)(CPUS390XState *env, uint32_t r2) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); clp_service_call(cpu, r2, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(pcilg)(CPUS390XState *env, uint32_t r1, uint32_t r2) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); pcilg_service_call(cpu, r1, r2, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(pcistg)(CPUS390XState *env, uint32_t r1, uint32_t r2) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); pcistg_service_call(cpu, r1, r2, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba, @@ -754,9 +754,9 @@ void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, u= int64_t fiba, { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); stpcifc_service_call(cpu, r1, fiba, ar, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3) @@ -764,9 +764,9 @@ void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint6= 4_t r3) S390CPU *cpu =3D env_archcpu(env); int r; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); r =3D css_do_sic(cpu, (r3 >> 27) & 0x7, r1 & 0xffff); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); /* css_do_sic() may actually return a PGM_xxx value to inject */ if (r) { tcg_s390_program_interrupt(env, -r, GETPC()); @@ -777,9 +777,9 @@ void HELPER(rpcit)(CPUS390XState *env, uint32_t r1, uin= t32_t r2) { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); rpcit_service_call(cpu, r1, r2, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, uint32_t r3, @@ -787,9 +787,9 @@ void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, ui= nt32_t r3, { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); pcistb_service_call(cpu, r1, r3, gaddr, ar, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba, @@ -797,8 +797,8 @@ void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, ui= nt64_t fiba, { S390CPU *cpu =3D env_archcpu(env); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); mpcifc_service_call(cpu, r1, fiba, ar, GETPC()); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 1563613582..3fd28a04e7 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -70,7 +70,7 @@ void cpu_check_irqs(CPUSPARCState *env) CPUState *cs; =20 /* We should be holding the BQL before we mess with IRQs */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 if (env->pil_in && (env->interrupt_index =3D=3D 0 || (env->interrupt_index & ~15) =3D=3D TT_EXTINT)) { diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 1b4155f5f3..dacbbf6b5b 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -69,7 +69,7 @@ void cpu_check_irqs(CPUSPARCState *env) (env->softint & ~(SOFTINT_TIMER | SOFTINT_STIMER)); =20 /* We should be holding the BQL before we mess with IRQs */ - g_assert(qemu_mutex_iothread_locked()); + g_assert(qemu_bql_locked()); =20 /* TT_IVEC has a higher priority (16) than TT_EXTINT (31..17) */ if (env->ivec_status & 0x20) { @@ -267,9 +267,9 @@ static bool do_modify_softint(CPUSPARCState *env, uint3= 2_t value) env->softint =3D value; #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_check_irqs(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif return true; diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c index 16d1c70fe7..ba666ec50e 100644 --- a/target/sparc/win_helper.c +++ b/target/sparc/win_helper.c @@ -179,9 +179,9 @@ void helper_wrpsr(CPUSPARCState *env, target_ulong new_= psr) cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC()); } else { /* cpu_put_psr may trigger interrupts, hence BQL */ - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_put_psr(env, new_psr); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 @@ -407,9 +407,9 @@ void helper_wrpstate(CPUSPARCState *env, target_ulong n= ew_state) =20 #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_check_irqs(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif } @@ -422,9 +422,9 @@ void helper_wrpil(CPUSPARCState *env, target_ulong new_= pil) env->psrpil =3D new_pil; =20 if (cpu_interrupts_enabled(env)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_check_irqs(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif } @@ -451,9 +451,9 @@ void helper_done(CPUSPARCState *env) =20 #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_check_irqs(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif } @@ -480,9 +480,9 @@ void helper_retry(CPUSPARCState *env) =20 #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); cpu_check_irqs(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } #endif } diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 91354884f7..405387decb 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -105,9 +105,9 @@ void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, ui= nt32_t intlevel) env->sregs[PS] =3D (env->sregs[PS] & ~PS_INTLEVEL) | (intlevel << PS_INTLEVEL_SHIFT); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); check_interrupts(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 if (env->pending_irq_level) { cpu_loop_exit(cpu); @@ -120,9 +120,9 @@ void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, ui= nt32_t intlevel) =20 void HELPER(check_interrupts)(CPUXtensaState *env) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); check_interrupts(env); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 void HELPER(intset)(CPUXtensaState *env, uint32_t v) diff --git a/ui/spice-core.c b/ui/spice-core.c index db21db2c94..1d895d2fe8 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -222,7 +222,7 @@ static void channel_event(int event, SpiceChannelEventI= nfo *info) */ bool need_lock =3D !qemu_thread_is_self(&me); if (need_lock) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 if (info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) { @@ -260,7 +260,7 @@ static void channel_event(int event, SpiceChannelEventI= nfo *info) } =20 if (need_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 qapi_free_SpiceServerInfo(server); diff --git a/util/async.c b/util/async.c index 8f90ddc304..49d07b3c73 100644 --- a/util/async.c +++ b/util/async.c @@ -741,7 +741,7 @@ AioContext *qemu_get_current_aio_context(void) if (ctx) { return ctx; } - if (qemu_mutex_iothread_locked()) { + if (qemu_bql_locked()) { /* Possibly in a vCPU thread. */ return qemu_get_aio_context(); } diff --git a/util/main-loop.c b/util/main-loop.c index 797b640c41..921fab3f32 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -302,13 +302,13 @@ static int os_host_main_loop_wait(int64_t timeout) =20 glib_pollfds_fill(&timeout); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); replay_mutex_unlock(); =20 ret =3D qemu_poll_ns((GPollFD *)gpollfds->data, gpollfds->len, timeout= ); =20 replay_mutex_lock(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 glib_pollfds_poll(); =20 @@ -517,7 +517,7 @@ static int os_host_main_loop_wait(int64_t timeout) =20 poll_timeout_ns =3D qemu_soonest_timeout(poll_timeout_ns, timeout); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); =20 replay_mutex_unlock(); =20 @@ -525,7 +525,7 @@ static int os_host_main_loop_wait(int64_t timeout) =20 replay_mutex_lock(); =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); if (g_poll_ret > 0) { for (i =3D 0; i < w->num; i++) { w->revents[i] =3D poll_fds[n_poll_fds + i].revents; diff --git a/util/rcu.c b/util/rcu.c index e587bcc483..8331f24288 100644 --- a/util/rcu.c +++ b/util/rcu.c @@ -283,24 +283,24 @@ static void *call_rcu_thread(void *opaque) =20 qatomic_sub(&rcu_call_count, n); synchronize_rcu(); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); while (n > 0) { node =3D try_dequeue(); while (!node) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_event_reset(&rcu_call_ready_event); node =3D try_dequeue(); if (!node) { qemu_event_wait(&rcu_call_ready_event); node =3D try_dequeue(); } - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 n--; node->func(node); } - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } abort(); } @@ -337,13 +337,13 @@ static void drain_rcu_callback(struct rcu_head *node) void drain_call_rcu(void) { struct rcu_drain rcu_drain; - bool locked =3D qemu_mutex_iothread_locked(); + bool locked =3D qemu_bql_locked(); =20 memset(&rcu_drain, 0, sizeof(struct rcu_drain)); qemu_event_init(&rcu_drain.drain_complete_event, false); =20 if (locked) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } =20 =20 @@ -365,7 +365,7 @@ void drain_call_rcu(void) qatomic_dec(&in_drain_call_rcu); =20 if (locked) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 } diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 8cd129a27d..866d7a9436 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -547,7 +547,7 @@ static OSStatus handle_voice_change( { coreaudioVoiceOut *core =3D in_client_data; =20 - qemu_mutex_lock_iothread(); + qemu_bql_lock(); =20 if (core->outputDeviceID) { fini_out_device(core); @@ -557,7 +557,7 @@ static OSStatus handle_voice_change( update_device_playback_state(core); } =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); return 0; } =20 diff --git a/memory_ldst.c.inc b/memory_ldst.c.inc index 84b868f294..cd8a629816 100644 --- a/memory_ldst.c.inc +++ b/memory_ldst.c.inc @@ -61,7 +61,7 @@ static inline uint32_t glue(address_space_ldl_internal, S= UFFIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); return val; @@ -130,7 +130,7 @@ static inline uint64_t glue(address_space_ldq_internal,= SUFFIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); return val; @@ -186,7 +186,7 @@ uint8_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); return val; @@ -234,7 +234,7 @@ static inline uint16_t glue(address_space_lduw_internal= , SUFFIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); return val; @@ -295,7 +295,7 @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); } @@ -339,7 +339,7 @@ static inline void glue(address_space_stl_internal, SUF= FIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); } @@ -391,7 +391,7 @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); } @@ -435,7 +435,7 @@ static inline void glue(address_space_stw_internal, SUF= FIX)(ARG1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); } @@ -499,7 +499,7 @@ static void glue(address_space_stq_internal, SUFFIX)(AR= G1_DECL, *result =3D r; } if (release_lock) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } RCU_READ_UNLOCK(); } diff --git a/target/i386/hvf/README.md b/target/i386/hvf/README.md index 2d33477aca..679b93b630 100644 --- a/target/i386/hvf/README.md +++ b/target/i386/hvf/README.md @@ -4,4 +4,4 @@ These sources (and ../hvf-all.c) are adapted from Veertu In= c's vdhh (Veertu Desk =20 1. Adapt to our current QEMU's `CPUState` structure and `address_space_rw`= API; many struct members have been moved around (emulated x86 state, xsave= _buf) due to historical differences + QEMU needing to handle more emulation= targets. 2. Removal of `apic_page` and hyperv-related functionality. -3. More relaxed use of `qemu_mutex_lock_iothread`. +3. More relaxed use of `qemu_bql_lock`. diff --git a/ui/cocoa.m b/ui/cocoa.m index cd069da696..8a7d0a6f0c 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -117,29 +117,29 @@ static void cocoa_switch(DisplayChangeListener *dcl, typedef void (^CodeBlock)(void); typedef bool (^BoolCodeBlock)(void); =20 -static void with_iothread_lock(CodeBlock block) +static void with_bql(CodeBlock block) { - bool locked =3D qemu_mutex_iothread_locked(); + bool locked =3D qemu_bql_locked(); if (!locked) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } block(); if (!locked) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } } =20 -static bool bool_with_iothread_lock(BoolCodeBlock block) +static bool bool_with_bql(BoolCodeBlock block) { - bool locked =3D qemu_mutex_iothread_locked(); + bool locked =3D qemu_bql_locked(); bool val; =20 if (!locked) { - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } val =3D block(); if (!locked) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); } return val; } @@ -605,7 +605,7 @@ - (void) updateUIInfo return; } =20 - with_iothread_lock(^{ + with_bql(^{ [self updateUIInfoLocked]; }); } @@ -790,7 +790,7 @@ - (void) handleMonitorInput:(NSEvent *)event =20 - (bool) handleEvent:(NSEvent *)event { - return bool_with_iothread_lock(^{ + return bool_with_bql(^{ return [self handleEventLocked:event]; }); } @@ -1182,7 +1182,7 @@ - (QEMUScreen) gscreen {return screen;} */ - (void) raiseAllKeys { - with_iothread_lock(^{ + with_bql(^{ qkbd_state_lift_all_keys(kbd); }); } @@ -1282,7 +1282,7 @@ - (void)applicationWillTerminate:(NSNotification *)aN= otification { COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n"); =20 - with_iothread_lock(^{ + with_bql(^{ shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); }); @@ -1420,7 +1420,7 @@ - (void)displayConsole:(id)sender /* Pause the guest */ - (void)pauseQEMU:(id)sender { - with_iothread_lock(^{ + with_bql(^{ qmp_stop(NULL); }); [sender setEnabled: NO]; @@ -1431,7 +1431,7 @@ - (void)pauseQEMU:(id)sender /* Resume running the guest operating system */ - (void)resumeQEMU:(id) sender { - with_iothread_lock(^{ + with_bql(^{ qmp_cont(NULL); }); [sender setEnabled: NO]; @@ -1461,7 +1461,7 @@ - (void)removePause /* Restarts QEMU */ - (void)restartQEMU:(id)sender { - with_iothread_lock(^{ + with_bql(^{ qmp_system_reset(NULL); }); } @@ -1469,7 +1469,7 @@ - (void)restartQEMU:(id)sender /* Powers down QEMU */ - (void)powerDownQEMU:(id)sender { - with_iothread_lock(^{ + with_bql(^{ qmp_system_powerdown(NULL); }); } @@ -1488,7 +1488,7 @@ - (void)ejectDeviceMedia:(id)sender } =20 __block Error *err =3D NULL; - with_iothread_lock(^{ + with_bql(^{ qmp_eject([drive cStringUsingEncoding: NSASCIIStringEncoding], NULL, false, false, &err); }); @@ -1523,7 +1523,7 @@ - (void)changeDeviceMedia:(id)sender } =20 __block Error *err =3D NULL; - with_iothread_lock(^{ + with_bql(^{ qmp_blockdev_change_medium([drive cStringUsingEncoding: NSASCIIStringEncoding], NULL, @@ -1605,7 +1605,7 @@ - (void)adjustSpeed:(id)sender // get the throttle percentage throttle_pct =3D [sender tag]; =20 - with_iothread_lock(^{ + with_bql(^{ cpu_throttle_set(throttle_pct); }); COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(),= '%'); @@ -1819,7 +1819,7 @@ - (void)pasteboard:(NSPasteboard *)sender provideData= ForType:(NSPasteboardType)t return; } =20 - with_iothread_lock(^{ + with_bql(^{ QemuClipboardInfo *info =3D qemu_clipboard_info_ref(cbinfo); qemu_event_reset(&cbevent); qemu_clipboard_request(info, QEMU_CLIPBOARD_TYPE_TEXT); @@ -1827,9 +1827,9 @@ - (void)pasteboard:(NSPasteboard *)sender provideData= ForType:(NSPasteboardType)t while (info =3D=3D cbinfo && info->types[QEMU_CLIPBOARD_TYPE_TEXT].available && info->types[QEMU_CLIPBOARD_TYPE_TEXT].data =3D=3D NULL) { - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_event_wait(&cbevent); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); } =20 if (info =3D=3D cbinfo) { @@ -1927,9 +1927,9 @@ static void cocoa_clipboard_request(QemuClipboardInfo= *info, int status; =20 COCOA_DEBUG("Second thread: calling qemu_default_main()\n"); - qemu_mutex_lock_iothread(); + qemu_bql_lock(); status =3D qemu_default_main(); - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n"); [cbowner release]; exit(status); @@ -1941,7 +1941,7 @@ static int cocoa_main(void) =20 COCOA_DEBUG("Entered %s()\n", __func__); =20 - qemu_mutex_unlock_iothread(); + qemu_bql_unlock(); qemu_thread_create(&thread, "qemu_main", call_qemu_main, NULL, QEMU_THREAD_DETACHED); =20 --=20 2.42.0 From nobody Wed Nov 27 03:48:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1701293227; cv=none; d=zohomail.com; s=zohoarc; b=cXuGfmKfK4vcODQPrdoSwmtp1/Iu/hSzKb61UrPKf8MTkOhB8NkHjcTWLAkwItXeasPBpHPaPiS+aRRFkdWBwKiuZ2Q7QPRdf8FK7n2B7awhhJPINegGTkaGjtyvnIYsnlWkte95R/Vk+67uzO66UIqF9DaEiMk+v9nKlISwRAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701293227; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aRXyTaHypebwyOUnVd682fvvQLv7a/HZq8MmldgnYg0=; b=TvXHqwoPht4s6woDdsApqUEM++ftPJltnh34kpWHEMKJtTh+GgVbP8xWQg0/zldG+9X50AfbZhnt3dZpSXF8sIejPbUyoIT0fcGpC0+evO8bLaGjW3rZj15VWdDbPt0dzLzncbwcfx2ZfgGDS3SO8zAQ0gb6OwxoVvofP/pnQtA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701293227616390.96684461805137; Wed, 29 Nov 2023 13:27:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644248.1005062 (Exim 4.92) (envelope-from ) id 1r8S53-0000Tq-S5; Wed, 29 Nov 2023 21:26:49 +0000 Received: by outflank-mailman (output) from mailman id 644248.1005062; Wed, 29 Nov 2023 21:26:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S53-0000Tj-NK; Wed, 29 Nov 2023 21:26:49 +0000 Received: by outflank-mailman (input) for mailman id 644248; Wed, 29 Nov 2023 21:26:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S52-00008d-SH for xen-devel@lists.xenproject.org; Wed, 29 Nov 2023 21:26:48 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 000d1d83-8efe-11ee-98e4-6d05b1d4d9a1; Wed, 29 Nov 2023 22:26:48 +0100 (CET) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-VPB8p9y3P4KteZhh_p8yNg-1; Wed, 29 Nov 2023 16:26:44 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58F31836EF1; Wed, 29 Nov 2023 21:26:38 +0000 (UTC) Received: from localhost (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01B912166B26; Wed, 29 Nov 2023 21:26:36 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 000d1d83-8efe-11ee-98e4-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701293206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aRXyTaHypebwyOUnVd682fvvQLv7a/HZq8MmldgnYg0=; b=Iy2QWiMAD+l3+xKeZd10nLBnrq/p1GjcjyjesLFNyIY8mNKwmmo7HMVH68x9ExwU10PcXI tqbkbiyKXRXiSU/MY1vEpJ4prQeA/jcvPZ1PhWjo+OsXxXhTOEr6db1+W+S7vrwddsBCLb LvsG2MUd0fMGwfT+bWDK6PiGtiVk/Zs= X-MC-Unique: VPB8p9y3P4KteZhh_p8yNg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Jean-Christophe Dubois , Fabiano Rosas , qemu-s390x@nongnu.org, Song Gao , Marcel Apfelbaum , Thomas Huth , Hyman Huang , Marcelo Tosatti , David Woodhouse , Andrey Smirnov , Peter Maydell , Kevin Wolf , Ilya Leoshkevich , Artyom Tarasenko , Mark Cave-Ayland , Max Filippov , Alistair Francis , Paul Durrant , Jagannathan Raman , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-arm@nongnu.org, Jason Wang , Gerd Hoffmann , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , BALATON Zoltan , Daniel Henrique Barboza , Elena Ufimtseva , Aurelien Jarno , Hailiang Zhang , Roman Bolshakov , Huacai Chen , Fam Zheng , Eric Blake , Jiri Slaby , Alexander Graf , Liu Zhiwei , Weiwei Li , Eric Farman , Stafford Horne , David Hildenbrand , Markus Armbruster , Reinoud Zandijk , Palmer Dabbelt , Cameron Esfahani , xen-devel@lists.xenproject.org, Pavel Dovgalyuk , qemu-riscv@nongnu.org, Aleksandar Rikalo , John Snow , Sunil Muthuswamy , Michael Roth , David Gibson , "Michael S. Tsirkin" , Richard Henderson , Bin Meng , Stefano Stabellini , kvm@vger.kernel.org, Stefan Hajnoczi , qemu-block@nongnu.org, Halil Pasic , Peter Xu , Anthony Perard , Harsh Prateek Bora , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Borntraeger , Akihiko Odaki , Leonardo Bras , Nicholas Piggin , Jiaxun Yang Subject: [PATCH 2/6] qemu/main-loop: rename QEMU_IOTHREAD_LOCK_GUARD to QEMU_BQL_LOCK_GUARD Date: Wed, 29 Nov 2023 16:26:21 -0500 Message-ID: <20231129212625.1051502-3-stefanha@redhat.com> In-Reply-To: <20231129212625.1051502-1-stefanha@redhat.com> References: <20231129212625.1051502-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701293228789000004 Content-Type: text/plain; charset="utf-8" The name "iothread" is overloaded. Use the term Big QEMU Lock (BQL) instead, it is already widely used and unambiguous. Signed-off-by: Stefan Hajnoczi Acked-by: David Woodhouse Acked-by: Ilya Leoshkevich Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Paul Durrant --- include/qemu/main-loop.h | 20 ++++++++++---------- hw/i386/kvm/xen_evtchn.c | 14 +++++++------- hw/i386/kvm/xen_gnttab.c | 2 +- hw/mips/mips_int.c | 2 +- hw/ppc/ppc.c | 2 +- target/i386/kvm/xen-emu.c | 2 +- target/ppc/excp_helper.c | 2 +- target/ppc/helper_regs.c | 2 +- target/riscv/cpu_helper.c | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index d6f75e57bd..0b6a3e4824 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -344,13 +344,13 @@ void qemu_bql_lock_impl(const char *file, int line); void qemu_bql_unlock(void); =20 /** - * QEMU_IOTHREAD_LOCK_GUARD + * QEMU_BQL_LOCK_GUARD * - * Wrap a block of code in a conditional qemu_mutex_{lock,unlock}_iothread. + * Wrap a block of code in a conditional qemu_bql_{lock,unlock}. */ -typedef struct IOThreadLockAuto IOThreadLockAuto; +typedef struct BQLLockAuto BQLLockAuto; =20 -static inline IOThreadLockAuto *qemu_iothread_auto_lock(const char *file, +static inline BQLLockAuto *qemu_bql_auto_lock(const char *file, int line) { if (qemu_bql_locked()) { @@ -358,19 +358,19 @@ static inline IOThreadLockAuto *qemu_iothread_auto_lo= ck(const char *file, } qemu_bql_lock_impl(file, line); /* Anything non-NULL causes the cleanup function to be called */ - return (IOThreadLockAuto *)(uintptr_t)1; + return (BQLLockAuto *)(uintptr_t)1; } =20 -static inline void qemu_iothread_auto_unlock(IOThreadLockAuto *l) +static inline void qemu_bql_auto_unlock(BQLLockAuto *l) { qemu_bql_unlock(); } =20 -G_DEFINE_AUTOPTR_CLEANUP_FUNC(IOThreadLockAuto, qemu_iothread_auto_unlock) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(BQLLockAuto, qemu_bql_auto_unlock) =20 -#define QEMU_IOTHREAD_LOCK_GUARD() \ - g_autoptr(IOThreadLockAuto) _iothread_lock_auto __attribute__((unused)= ) \ - =3D qemu_iothread_auto_lock(__FILE__, __LINE__) +#define QEMU_BQL_LOCK_GUARD() \ + g_autoptr(BQLLockAuto) _bql_lock_auto __attribute__((unused)) \ + =3D qemu_bql_auto_lock(__FILE__, __LINE__) =20 /* * qemu_cond_wait_iothread: Wait on condition for the main loop mutex diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 07d0ff0253..3ab686bd79 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -1127,7 +1127,7 @@ int xen_evtchn_reset_op(struct evtchn_reset *reset) return -ESRCH; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); return xen_evtchn_soft_reset(); } =20 @@ -1145,7 +1145,7 @@ int xen_evtchn_close_op(struct evtchn_close *close) return -EINVAL; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); qemu_mutex_lock(&s->port_lock); =20 ret =3D close_port(s, close->port, &flush_kvm_routes); @@ -1272,7 +1272,7 @@ int xen_evtchn_bind_pirq_op(struct evtchn_bind_pirq *= pirq) return -EINVAL; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 if (s->pirq[pirq->pirq].port) { return -EBUSY; @@ -1824,7 +1824,7 @@ int xen_physdev_map_pirq(struct physdev_map_pirq *map) return -ENOTSUP; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); QEMU_LOCK_GUARD(&s->port_lock); =20 if (map->domid !=3D DOMID_SELF && map->domid !=3D xen_domid) { @@ -1884,7 +1884,7 @@ int xen_physdev_unmap_pirq(struct physdev_unmap_pirq = *unmap) return -EINVAL; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); qemu_mutex_lock(&s->port_lock); =20 if (!pirq_inuse(s, pirq)) { @@ -1924,7 +1924,7 @@ int xen_physdev_eoi_pirq(struct physdev_eoi *eoi) return -ENOTSUP; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); QEMU_LOCK_GUARD(&s->port_lock); =20 if (!pirq_inuse(s, pirq)) { @@ -1956,7 +1956,7 @@ int xen_physdev_query_pirq(struct physdev_irq_status_= query *query) return -ENOTSUP; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); QEMU_LOCK_GUARD(&s->port_lock); =20 if (!pirq_inuse(s, pirq)) { diff --git a/hw/i386/kvm/xen_gnttab.c b/hw/i386/kvm/xen_gnttab.c index 0a24f53f20..ee5f8cf257 100644 --- a/hw/i386/kvm/xen_gnttab.c +++ b/hw/i386/kvm/xen_gnttab.c @@ -176,7 +176,7 @@ int xen_gnttab_map_page(uint64_t idx, uint64_t gfn) return -EINVAL; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); QEMU_LOCK_GUARD(&s->gnt_lock); =20 xen_overlay_do_map_page(&s->gnt_aliases[idx], gpa); diff --git a/hw/mips/mips_int.c b/hw/mips/mips_int.c index 6c32e466a3..c2454f9724 100644 --- a/hw/mips/mips_int.c +++ b/hw/mips/mips_int.c @@ -36,7 +36,7 @@ static void cpu_mips_irq_request(void *opaque, int irq, i= nt level) return; } =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 if (level) { env->CP0_Cause |=3D 1 << (irq + CP0Ca_IP); diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index c8c3b43602..ce7d3692c4 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -47,7 +47,7 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) unsigned int old_pending; =20 /* We may already have the BQL if coming from the reset path */ - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 old_pending =3D env->pending_interrupts; =20 diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index f79f5d270f..be8a1fef58 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -581,7 +581,7 @@ static int xen_set_shared_info(uint64_t gfn) uint64_t gpa =3D gfn << TARGET_PAGE_BITS; int i, err; =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 /* * The xen_overlay device tells KVM about it too, since it had to diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 0a1c942831..2122f89990 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2222,7 +2222,7 @@ static int ppc_next_unmasked_interrupt(CPUPPCState *e= nv) void ppc_maybe_interrupt(CPUPPCState *env) { CPUState *cs =3D env_cpu(env); - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 if (ppc_next_unmasked_interrupt(env)) { cpu_interrupt(cs, CPU_INTERRUPT_HARD); diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index f380342d4d..b92e3a223a 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -244,7 +244,7 @@ void cpu_interrupt_exittb(CPUState *cs) * unless running with TCG. */ if (tcg_enabled()) { - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); cpu_interrupt(cs, CPU_INTERRUPT_EXITTB); } } diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index e7e23b34f4..fa73bb8ce9 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -655,7 +655,7 @@ void riscv_cpu_interrupt(CPURISCVState *env) uint64_t gein, vsgein =3D 0, vstip =3D 0, irqf =3D 0; CPUState *cs =3D env_cpu(env); =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 if (env->virt_enabled) { gein =3D get_field(env->hstatus, HSTATUS_VGEIN); @@ -681,7 +681,7 @@ uint64_t riscv_cpu_update_mip(CPURISCVState *env, uint6= 4_t mask, uint64_t value) /* No need to update mip for VSTIP */ mask =3D ((mask =3D=3D MIP_VSTIP) && env->vstime_irq) ? 0 : mask; =20 - QEMU_IOTHREAD_LOCK_GUARD(); + QEMU_BQL_LOCK_GUARD(); =20 env->mip =3D (env->mip & ~mask) | (value & mask); =20 --=20 2.42.0 From nobody Wed Nov 27 03:48:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1701293236; cv=none; d=zohomail.com; s=zohoarc; b=EZZyq9WmOrf6rJK3hoJ8sO0ghKblkFINVktGQnyPhuijJnVJXekrf4JajU8OlJ3RO5JID9IXIahOPIZv4m/iiO12Q6a5O3wadXgZBCE95zRUAOoR1b1nIBc47fdkaD9YWbreemKCPkhaHl62DpRUfkXZIuGZfxbKk3IXIJknr3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701293236; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DG7+f00gCNxrB4UkczfVTSYAisk/aHQSNhsUg/07D1c=; b=X6SjCnLMzWDDQI6dPBr4hQ+TqtxrgPPI4WtKDDIPMTgxnw7zwFA3AsiVbDwc8uhLQOOhX3VralLowK5VLm6dcOz68kBdVIOJQiPXmYZJKC8LwM2VWtDc+Zcu6b86exyHPOsrr0zRlDigD06eG4CGGR8LDm70d1Nog5oGlATplAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701293236431879.5423089340759; Wed, 29 Nov 2023 13:27:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644249.1005071 (Exim 4.92) (envelope-from ) id 1r8S56-0000m2-2K; Wed, 29 Nov 2023 21:26:52 +0000 Received: by outflank-mailman (output) from mailman id 644249.1005071; Wed, 29 Nov 2023 21:26:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S55-0000lv-Vs; Wed, 29 Nov 2023 21:26:51 +0000 Received: by outflank-mailman (input) for mailman id 644249; Wed, 29 Nov 2023 21:26:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S54-0000jZ-W5 for xen-devel@lists.xenproject.org; Wed, 29 Nov 2023 21:26:50 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 009e999b-8efe-11ee-9b0f-b553b5be7939; Wed, 29 Nov 2023 22:26:49 +0100 (CET) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-55r8XQSHMnC_rWqi5-T4vw-1; Wed, 29 Nov 2023 16:26:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37B5C83DCD6; Wed, 29 Nov 2023 21:26:41 +0000 (UTC) Received: from localhost (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE2DB2026D66; Wed, 29 Nov 2023 21:26:39 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 009e999b-8efe-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701293207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DG7+f00gCNxrB4UkczfVTSYAisk/aHQSNhsUg/07D1c=; b=B7c5wAM1/bWOy42gsnsuG/h7vuN7+qRD52vLHMJ3FRiL5HDyNLjkbU3ZJmThO1TZ+YTNw1 AXFP/FLWDs8VK9hPgXB4bNO7QGYj0QTnhzL1s6hiaDzOWFA+7LzRwmz/brPIzBtX/WuEu6 +3/BPc4np2o1EUNDHdx8QrN9mgOSbvQ= X-MC-Unique: 55r8XQSHMnC_rWqi5-T4vw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Jean-Christophe Dubois , Fabiano Rosas , qemu-s390x@nongnu.org, Song Gao , Marcel Apfelbaum , Thomas Huth , Hyman Huang , Marcelo Tosatti , David Woodhouse , Andrey Smirnov , Peter Maydell , Kevin Wolf , Ilya Leoshkevich , Artyom Tarasenko , Mark Cave-Ayland , Max Filippov , Alistair Francis , Paul Durrant , Jagannathan Raman , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-arm@nongnu.org, Jason Wang , Gerd Hoffmann , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , BALATON Zoltan , Daniel Henrique Barboza , Elena Ufimtseva , Aurelien Jarno , Hailiang Zhang , Roman Bolshakov , Huacai Chen , Fam Zheng , Eric Blake , Jiri Slaby , Alexander Graf , Liu Zhiwei , Weiwei Li , Eric Farman , Stafford Horne , David Hildenbrand , Markus Armbruster , Reinoud Zandijk , Palmer Dabbelt , Cameron Esfahani , xen-devel@lists.xenproject.org, Pavel Dovgalyuk , qemu-riscv@nongnu.org, Aleksandar Rikalo , John Snow , Sunil Muthuswamy , Michael Roth , David Gibson , "Michael S. Tsirkin" , Richard Henderson , Bin Meng , Stefano Stabellini , kvm@vger.kernel.org, Stefan Hajnoczi , qemu-block@nongnu.org, Halil Pasic , Peter Xu , Anthony Perard , Harsh Prateek Bora , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Borntraeger , Akihiko Odaki , Leonardo Bras , Nicholas Piggin , Jiaxun Yang Subject: [PATCH 3/6] qemu/main-loop: rename qemu_cond_wait_iothread() to qemu_cond_wait_bql() Date: Wed, 29 Nov 2023 16:26:22 -0500 Message-ID: <20231129212625.1051502-4-stefanha@redhat.com> In-Reply-To: <20231129212625.1051502-1-stefanha@redhat.com> References: <20231129212625.1051502-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701293236747000001 Content-Type: text/plain; charset="utf-8" The name "iothread" is overloaded. Use the term Big QEMU Lock (BQL) instead, it is already widely used and unambiguous. Signed-off-by: Stefan Hajnoczi Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/main-loop.h | 8 ++++---- accel/tcg/tcg-accel-ops-rr.c | 4 ++-- hw/display/virtio-gpu.c | 2 +- hw/ppc/spapr_events.c | 2 +- system/cpu-throttle.c | 2 +- system/cpus.c | 4 ++-- target/i386/nvmm/nvmm-accel-ops.c | 2 +- target/i386/whpx/whpx-accel-ops.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 0b6a3e4824..ec2a70f041 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -373,17 +373,17 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(BQLLockAuto, qemu_bql_a= uto_unlock) =3D qemu_bql_auto_lock(__FILE__, __LINE__) =20 /* - * qemu_cond_wait_iothread: Wait on condition for the main loop mutex + * qemu_cond_wait_bql: Wait on condition for the main loop mutex * * This function atomically releases the main loop mutex and causes * the calling thread to block on the condition. */ -void qemu_cond_wait_iothread(QemuCond *cond); +void qemu_cond_wait_bql(QemuCond *cond); =20 /* - * qemu_cond_timedwait_iothread: like the previous, but with timeout + * qemu_cond_timedwait_bql: like the previous, but with timeout */ -void qemu_cond_timedwait_iothread(QemuCond *cond, int ms); +void qemu_cond_timedwait_bql(QemuCond *cond, int ms); =20 /* internal interfaces */ =20 diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index c21215a094..1e5a688085 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -111,7 +111,7 @@ static void rr_wait_io_event(void) =20 while (all_cpu_threads_idle()) { rr_stop_kick_timer(); - qemu_cond_wait_iothread(first_cpu->halt_cond); + qemu_cond_wait_bql(first_cpu->halt_cond); } =20 rr_start_kick_timer(); @@ -198,7 +198,7 @@ static void *rr_cpu_thread_fn(void *arg) =20 /* wait for initial kick-off after machine start */ while (first_cpu->stopped) { - qemu_cond_wait_iothread(first_cpu->halt_cond); + qemu_cond_wait_bql(first_cpu->halt_cond); =20 /* process any pending work */ CPU_FOREACH(cpu) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index b016d3bac8..67c5be1a4e 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1512,7 +1512,7 @@ void virtio_gpu_reset(VirtIODevice *vdev) g->reset_finished =3D false; qemu_bh_schedule(g->reset_bh); while (!g->reset_finished) { - qemu_cond_wait_iothread(&g->reset_cond); + qemu_cond_wait_bql(&g->reset_cond); } } else { virtio_gpu_reset_bh(g); diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index deb4641505..cb0eeee587 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -899,7 +899,7 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovere= d) } return; } - qemu_cond_wait_iothread(&spapr->fwnmi_machine_check_interlock_cond= ); + qemu_cond_wait_bql(&spapr->fwnmi_machine_check_interlock_cond); if (spapr->fwnmi_machine_check_addr =3D=3D -1) { /* * If the machine was reset while waiting for the interlock, diff --git a/system/cpu-throttle.c b/system/cpu-throttle.c index e98836311b..1d2b73369e 100644 --- a/system/cpu-throttle.c +++ b/system/cpu-throttle.c @@ -54,7 +54,7 @@ static void cpu_throttle_thread(CPUState *cpu, run_on_cpu= _data opaque) endtime_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + sleeptime_ns; while (sleeptime_ns > 0 && !cpu->stop) { if (sleeptime_ns > SCALE_MS) { - qemu_cond_timedwait_iothread(cpu->halt_cond, + qemu_cond_timedwait_bql(cpu->halt_cond, sleeptime_ns / SCALE_MS); } else { qemu_bql_unlock(); diff --git a/system/cpus.c b/system/cpus.c index d5b98c11f5..eb24a4db8e 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -513,12 +513,12 @@ void qemu_bql_unlock(void) qemu_mutex_unlock(&qemu_global_mutex); } =20 -void qemu_cond_wait_iothread(QemuCond *cond) +void qemu_cond_wait_bql(QemuCond *cond) { qemu_cond_wait(cond, &qemu_global_mutex); } =20 -void qemu_cond_timedwait_iothread(QemuCond *cond, int ms) +void qemu_cond_timedwait_bql(QemuCond *cond, int ms) { qemu_cond_timedwait(cond, &qemu_global_mutex, ms); } diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-acce= l-ops.c index 387ccfcce5..0fe8a76820 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -48,7 +48,7 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg) } } while (cpu_thread_is_idle(cpu)) { - qemu_cond_wait_iothread(cpu->halt_cond); + qemu_cond_wait_bql(cpu->halt_cond); } qemu_wait_io_event_common(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-acce= l-ops.c index 1f29346a88..d8bec46081 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -48,7 +48,7 @@ static void *whpx_cpu_thread_fn(void *arg) } } while (cpu_thread_is_idle(cpu)) { - qemu_cond_wait_iothread(cpu->halt_cond); + qemu_cond_wait_bql(cpu->halt_cond); } qemu_wait_io_event_common(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); --=20 2.42.0 From nobody Wed Nov 27 03:48:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1701293228; cv=none; d=zohomail.com; s=zohoarc; b=S845TsAAHOWMmJ0E6HNp1rFOfoF8hnyZJ9gQFBWzs2DBHd02pUxnFl2lA+ez6NqxNp9MAf+QrgEL4tRD+9I95x8z1b7elQOaI8YTHEMxnQ52nelKuKDoiYISnfuMrRNwtzMQfbBtyuY3l92vnN2N5QIGwbe9hHg/PeiORmRUfYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701293228; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xnTMhuYWY4rKexdgAFG5bYrl78FXKUVZK+idLclmJ2E=; b=lyeC7h3Nw6C55yjRNAReQtvWWfsCSy6j3+n1hHfVexrFOPbK3RAMN9jhahAccWdZWAdkmXmaoRWqvq40AhemOPm/DJan6XXrDBDZo+IvsF0mvoKDpOD9YR4o1eGEKg3lA3FVpohcjuw5TdaY8DAedUki+PoELd/MjaWHKjiQG90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701293228010882.3187485873738; Wed, 29 Nov 2023 13:27:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644250.1005076 (Exim 4.92) (envelope-from ) id 1r8S56-0000pF-EF; Wed, 29 Nov 2023 21:26:52 +0000 Received: by outflank-mailman (output) from mailman id 644250.1005076; Wed, 29 Nov 2023 21:26:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S56-0000op-AK; Wed, 29 Nov 2023 21:26:52 +0000 Received: by outflank-mailman (input) for mailman id 644250; Wed, 29 Nov 2023 21:26:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S55-00008d-C2 for xen-devel@lists.xenproject.org; Wed, 29 Nov 2023 21:26:51 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 01b267cf-8efe-11ee-98e4-6d05b1d4d9a1; Wed, 29 Nov 2023 22:26:50 +0100 (CET) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-yAhr-UrSN4qD-XoM_Pt1Aw-1; Wed, 29 Nov 2023 16:26:46 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBD3F1E441DC; Wed, 29 Nov 2023 21:26:43 +0000 (UTC) Received: from localhost (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C9BA2026D4C; Wed, 29 Nov 2023 21:26:42 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 01b267cf-8efe-11ee-98e4-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701293209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xnTMhuYWY4rKexdgAFG5bYrl78FXKUVZK+idLclmJ2E=; b=BjnmLQapKIUOutu3xmOlymOKKbUvpgx9ZhlujCr6TU2hEpSjYTwkypttx+uYuTHijeIzSs IS/SgmCNzdNLTHiybQ0QmAdk4oo2+xjb2lWVJMumhX4FjANF8rz/gFXhf6adllizLye8Cw DZLhDCjhhdVRSlZPLR/8PLo9llYmlGE= X-MC-Unique: yAhr-UrSN4qD-XoM_Pt1Aw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Jean-Christophe Dubois , Fabiano Rosas , qemu-s390x@nongnu.org, Song Gao , Marcel Apfelbaum , Thomas Huth , Hyman Huang , Marcelo Tosatti , David Woodhouse , Andrey Smirnov , Peter Maydell , Kevin Wolf , Ilya Leoshkevich , Artyom Tarasenko , Mark Cave-Ayland , Max Filippov , Alistair Francis , Paul Durrant , Jagannathan Raman , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-arm@nongnu.org, Jason Wang , Gerd Hoffmann , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , BALATON Zoltan , Daniel Henrique Barboza , Elena Ufimtseva , Aurelien Jarno , Hailiang Zhang , Roman Bolshakov , Huacai Chen , Fam Zheng , Eric Blake , Jiri Slaby , Alexander Graf , Liu Zhiwei , Weiwei Li , Eric Farman , Stafford Horne , David Hildenbrand , Markus Armbruster , Reinoud Zandijk , Palmer Dabbelt , Cameron Esfahani , xen-devel@lists.xenproject.org, Pavel Dovgalyuk , qemu-riscv@nongnu.org, Aleksandar Rikalo , John Snow , Sunil Muthuswamy , Michael Roth , David Gibson , "Michael S. Tsirkin" , Richard Henderson , Bin Meng , Stefano Stabellini , kvm@vger.kernel.org, Stefan Hajnoczi , qemu-block@nongnu.org, Halil Pasic , Peter Xu , Anthony Perard , Harsh Prateek Bora , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Borntraeger , Akihiko Odaki , Leonardo Bras , Nicholas Piggin , Jiaxun Yang Subject: [PATCH 4/6] system/cpus: rename qemu_global_mutex to qemu_bql Date: Wed, 29 Nov 2023 16:26:23 -0500 Message-ID: <20231129212625.1051502-5-stefanha@redhat.com> In-Reply-To: <20231129212625.1051502-1-stefanha@redhat.com> References: <20231129212625.1051502-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701293228753000003 Content-Type: text/plain; charset="utf-8" The APIs using qemu_global_mutex now follow the Big QEMU Lock (BQL) nomenclature. It's a little strange that the actual QemuMutex variable that embodies the BQL is called qemu_global_mutex instead of qemu_bql. Rename it for consistency. Signed-off-by: Stefan Hajnoczi Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- system/cpus.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/system/cpus.c b/system/cpus.c index eb24a4db8e..138720a540 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -65,7 +65,7 @@ =20 #endif /* CONFIG_LINUX */ =20 -static QemuMutex qemu_global_mutex; +static QemuMutex qemu_bql; =20 /* * The chosen accelerator is supposed to register this. @@ -389,14 +389,14 @@ void qemu_init_cpu_loop(void) qemu_init_sigbus(); qemu_cond_init(&qemu_cpu_cond); qemu_cond_init(&qemu_pause_cond); - qemu_mutex_init(&qemu_global_mutex); + qemu_mutex_init(&qemu_bql); =20 qemu_thread_get_self(&io_thread); } =20 void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) { - do_run_on_cpu(cpu, func, data, &qemu_global_mutex); + do_run_on_cpu(cpu, func, data, &qemu_bql); } =20 static void qemu_cpu_stop(CPUState *cpu, bool exit) @@ -428,7 +428,7 @@ void qemu_wait_io_event(CPUState *cpu) slept =3D true; qemu_plugin_vcpu_idle_cb(cpu); } - qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); + qemu_cond_wait(cpu->halt_cond, &qemu_bql); } if (slept) { qemu_plugin_vcpu_resume_cb(cpu); @@ -502,7 +502,7 @@ void qemu_bql_lock_impl(const char *file, int line) QemuMutexLockFunc bql_lock =3D qatomic_read(&qemu_bql_mutex_lock_func); =20 g_assert(!qemu_bql_locked()); - bql_lock(&qemu_global_mutex, file, line); + bql_lock(&qemu_bql, file, line); set_bql_locked(true); } =20 @@ -510,17 +510,17 @@ void qemu_bql_unlock(void) { g_assert(qemu_bql_locked()); set_bql_locked(false); - qemu_mutex_unlock(&qemu_global_mutex); + qemu_mutex_unlock(&qemu_bql); } =20 void qemu_cond_wait_bql(QemuCond *cond) { - qemu_cond_wait(cond, &qemu_global_mutex); + qemu_cond_wait(cond, &qemu_bql); } =20 void qemu_cond_timedwait_bql(QemuCond *cond, int ms) { - qemu_cond_timedwait(cond, &qemu_global_mutex, ms); + qemu_cond_timedwait(cond, &qemu_bql, ms); } =20 /* signal CPU creation */ @@ -571,7 +571,7 @@ void pause_all_vcpus(void) replay_mutex_unlock(); =20 while (!all_vcpus_paused()) { - qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex); + qemu_cond_wait(&qemu_pause_cond, &qemu_bql); CPU_FOREACH(cpu) { qemu_cpu_kick(cpu); } @@ -649,7 +649,7 @@ void qemu_init_vcpu(CPUState *cpu) cpus_accel->create_vcpu_thread(cpu); =20 while (!cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); + qemu_cond_wait(&qemu_cpu_cond, &qemu_bql); } } =20 --=20 2.42.0 From nobody Wed Nov 27 03:48:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1701293239; cv=none; d=zohomail.com; s=zohoarc; b=Tpf2oaZRYj6py8CK9CeuxoqdZWQRwUWfFZ7ts1EBLNMKpwhiqXeCuiDNaroa/ninB3sCnaq6UsPzUGn1AsaO+3u6wSAf9udpFiYxvoiu7VNKZdBGuS7/ne/P/7/HIkTh48zGUB3QH3S3ehOBzJkIZ+tZ6yAgTry1LRXMDzRqTFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701293239; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HQwz+mgd+DCyta0fx7JwmRDq3fNNytwcrXDBy/aTKCk=; b=MQJAGVgMcXI1rg0GAA6iCjj48OAe6O53ZLRGJzD0iNhQc1QmEJAZ3U4ZRHrL8wSwfPy1zmmugQ2DV1WDD5kLuYDpBA/br4B4hIqdnLBJAJGAvwa/xPJChBy3rIdCI+Mv2LBtzRyXaJX/41FQrndzTtEPY27pENBYquuV9E0RnMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701293239556605.0721954850046; Wed, 29 Nov 2023 13:27:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644253.1005097 (Exim 4.92) (envelope-from ) id 1r8S5D-0001a5-DY; Wed, 29 Nov 2023 21:26:59 +0000 Received: by outflank-mailman (output) from mailman id 644253.1005097; Wed, 29 Nov 2023 21:26:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S5D-0001ZD-3Z; Wed, 29 Nov 2023 21:26:59 +0000 Received: by outflank-mailman (input) for mailman id 644253; Wed, 29 Nov 2023 21:26:57 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S5B-00008d-5I for xen-devel@lists.xenproject.org; Wed, 29 Nov 2023 21:26:57 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 04242735-8efe-11ee-98e4-6d05b1d4d9a1; Wed, 29 Nov 2023 22:26:54 +0100 (CET) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-pKoCs9J4N3errD6WxcCduA-1; Wed, 29 Nov 2023 16:26:49 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC00138049FE; Wed, 29 Nov 2023 21:26:46 +0000 (UTC) Received: from localhost (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61097492BFE; Wed, 29 Nov 2023 21:26:45 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 04242735-8efe-11ee-98e4-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701293213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQwz+mgd+DCyta0fx7JwmRDq3fNNytwcrXDBy/aTKCk=; b=DZ4eyDlkBKil6RMzlZwLCJLlLKxWnrZQp3ftfoGPOYnO8GBx0YRIdfzkMWRaj7t7d8U1gr vq3AT2/RmL17Z4Gp0J69BV94js3sHAOCf9F7cs2Bitj0xf2eivA30flhLIed2I2sf72jIK 3zrjp5QuIpwjlfVTglABeayH+LIrHBc= X-MC-Unique: pKoCs9J4N3errD6WxcCduA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Jean-Christophe Dubois , Fabiano Rosas , qemu-s390x@nongnu.org, Song Gao , Marcel Apfelbaum , Thomas Huth , Hyman Huang , Marcelo Tosatti , David Woodhouse , Andrey Smirnov , Peter Maydell , Kevin Wolf , Ilya Leoshkevich , Artyom Tarasenko , Mark Cave-Ayland , Max Filippov , Alistair Francis , Paul Durrant , Jagannathan Raman , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-arm@nongnu.org, Jason Wang , Gerd Hoffmann , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , BALATON Zoltan , Daniel Henrique Barboza , Elena Ufimtseva , Aurelien Jarno , Hailiang Zhang , Roman Bolshakov , Huacai Chen , Fam Zheng , Eric Blake , Jiri Slaby , Alexander Graf , Liu Zhiwei , Weiwei Li , Eric Farman , Stafford Horne , David Hildenbrand , Markus Armbruster , Reinoud Zandijk , Palmer Dabbelt , Cameron Esfahani , xen-devel@lists.xenproject.org, Pavel Dovgalyuk , qemu-riscv@nongnu.org, Aleksandar Rikalo , John Snow , Sunil Muthuswamy , Michael Roth , David Gibson , "Michael S. Tsirkin" , Richard Henderson , Bin Meng , Stefano Stabellini , kvm@vger.kernel.org, Stefan Hajnoczi , qemu-block@nongnu.org, Halil Pasic , Peter Xu , Anthony Perard , Harsh Prateek Bora , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Borntraeger , Akihiko Odaki , Leonardo Bras , Nicholas Piggin , Jiaxun Yang Subject: [PATCH 5/6] Replace "iothread lock" with "BQL" in comments Date: Wed, 29 Nov 2023 16:26:24 -0500 Message-ID: <20231129212625.1051502-6-stefanha@redhat.com> In-Reply-To: <20231129212625.1051502-1-stefanha@redhat.com> References: <20231129212625.1051502-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701293240764000001 Content-Type: text/plain; charset="utf-8" The term "iothread lock" is obsolete. The APIs use Big QEMU Lock (BQL) in their names. Update the code comments to use "BQL" instead of "iothread lock". Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/reset.rst | 2 +- hw/display/qxl.h | 2 +- include/exec/cpu-common.h | 2 +- include/exec/memory.h | 4 ++-- include/exec/ramblock.h | 2 +- include/migration/register.h | 8 ++++---- target/arm/internals.h | 4 ++-- accel/tcg/cputlb.c | 4 ++-- accel/tcg/tcg-accel-ops-icount.c | 2 +- hw/remote/mpqemu-link.c | 2 +- migration/block-dirty-bitmap.c | 10 +++++----- migration/block.c | 24 ++++++++++++------------ migration/colo.c | 2 +- migration/migration.c | 2 +- migration/ram.c | 4 ++-- system/physmem.c | 6 +++--- target/arm/helper.c | 2 +- target/arm/tcg/m_helper.c | 2 +- ui/spice-core.c | 2 +- util/rcu.c | 2 +- audio/coreaudio.m | 4 ++-- ui/cocoa.m | 6 +++--- 22 files changed, 49 insertions(+), 49 deletions(-) diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst index 38ed1790f7..d4e79718ba 100644 --- a/docs/devel/reset.rst +++ b/docs/devel/reset.rst @@ -19,7 +19,7 @@ Triggering reset =20 This section documents the APIs which "users" of a resettable object shoul= d use to control it. All resettable control functions must be called while holdi= ng -the iothread lock. +the BQL. =20 You can apply a reset to an object using ``resettable_assert_reset()``. Yo= u need to call ``resettable_release_reset()`` to release the object from reset. To diff --git a/hw/display/qxl.h b/hw/display/qxl.h index fdac14edad..e0a85a5ca4 100644 --- a/hw/display/qxl.h +++ b/hw/display/qxl.h @@ -159,7 +159,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(PCIQXLDevice, PCI_QXL) * * Use with care; by the time this function returns, the returned pointer = is * not protected by RCU anymore. If the caller is not within an RCU criti= cal - * section and does not hold the iothread lock, it must have other means of + * section and does not hold the BQL, it must have other means of * protecting the pointer, such as a reference to the region that includes * the incoming ram_addr_t. * diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 41115d8919..fef3138d29 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -92,7 +92,7 @@ RAMBlock *qemu_ram_block_by_name(const char *name); * * By the time this function returns, the returned pointer is not protected * by RCU anymore. If the caller is not within an RCU critical section and - * does not hold the iothread lock, it must have other means of protecting= the + * does not hold the BQL, it must have other means of protecting the * pointer, such as a reference to the memory region that owns the RAMBloc= k. */ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, diff --git a/include/exec/memory.h b/include/exec/memory.h index 831f7c996d..ad6466b07e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1962,7 +1962,7 @@ int memory_region_get_fd(MemoryRegion *mr); * * Use with care; by the time this function returns, the returned pointer = is * not protected by RCU anymore. If the caller is not within an RCU criti= cal - * section and does not hold the iothread lock, it must have other means of + * section and does not hold the BQL, it must have other means of * protecting the pointer, such as a reference to the region that includes * the incoming ram_addr_t. * @@ -1979,7 +1979,7 @@ MemoryRegion *memory_region_from_host(void *ptr, ram_= addr_t *offset); * * Use with care; by the time this function returns, the returned pointer = is * not protected by RCU anymore. If the caller is not within an RCU criti= cal - * section and does not hold the iothread lock, it must have other means of + * section and does not hold the BQL, it must have other means of * protecting the pointer, such as a reference to the region that includes * the incoming ram_addr_t. * diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index 69c6a53902..a2bc0a345d 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -34,7 +34,7 @@ struct RAMBlock { ram_addr_t max_length; void (*resized)(const char*, uint64_t length, void *host); uint32_t flags; - /* Protected by iothread lock. */ + /* Protected by BQL. */ char idstr[256]; /* RCU-enabled, writes protected by the ramlist lock */ QLIST_ENTRY(RAMBlock) next; diff --git a/include/migration/register.h b/include/migration/register.h index fed1d04a3c..9ab1f79512 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -17,7 +17,7 @@ #include "hw/vmstate-if.h" =20 typedef struct SaveVMHandlers { - /* This runs inside the iothread lock. */ + /* This runs inside the BQL. */ SaveStateHandler *save_state; =20 /* @@ -30,7 +30,7 @@ typedef struct SaveVMHandlers { int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); =20 - /* This runs both outside and inside the iothread lock. */ + /* This runs both outside and inside the BQL. */ bool (*is_active)(void *opaque); bool (*has_postcopy)(void *opaque); =20 @@ -43,14 +43,14 @@ typedef struct SaveVMHandlers { */ bool (*is_active_iterate)(void *opaque); =20 - /* This runs outside the iothread lock in the migration case, and + /* This runs outside the BQL in the migration case, and * within the lock in the savevm case. The callback had better only * use data that is local to the migration thread or protected * by other locks. */ int (*save_live_iterate)(QEMUFile *f, void *opaque); =20 - /* This runs outside the iothread lock! */ + /* This runs outside the BQL! */ /* Note for save_live_pending: * must_precopy: * - must be migrated in precopy or in stopped state diff --git a/target/arm/internals.h b/target/arm/internals.h index 143d57c0fe..71d6c70bf3 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -940,7 +940,7 @@ static inline const char *aarch32_mode_name(uint32_t ps= r) * * Update the CPU_INTERRUPT_VIRQ bit in cs->interrupt_request, following * a change to either the input VIRQ line from the GIC or the HCR_EL2.VI b= it. - * Must be called with the iothread lock held. + * Must be called with the BQL held. */ void arm_cpu_update_virq(ARMCPU *cpu); =20 @@ -949,7 +949,7 @@ void arm_cpu_update_virq(ARMCPU *cpu); * * Update the CPU_INTERRUPT_VFIQ bit in cs->interrupt_request, following * a change to either the input VFIQ line from the GIC or the HCR_EL2.VF b= it. - * Must be called with the iothread lock held. + * Must be called with the BQL held. */ void arm_cpu_update_vfiq(ARMCPU *cpu); =20 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 3c0b1658ee..a23d77e762 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1975,7 +1975,7 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr a= ddr, MemOpIdx oi, * @size: number of bytes * @mmu_idx: virtual address context * @ra: return address into tcg generated code, or 0 - * Context: iothread lock held + * Context: BQL held * * Load @size bytes from @addr, which is memory-mapped i/o. * The bytes are concatenated in big-endian order with @ret_be. @@ -2521,7 +2521,7 @@ static Int128 do_ld16_mmu(CPUState *cpu, vaddr addr, * @size: number of bytes * @mmu_idx: virtual address context * @ra: return address into tcg generated code, or 0 - * Context: iothread lock held + * Context: BQL held * * Store @size bytes at @addr, which is memory-mapped i/o. * The bytes to store are extracted in little-endian order from @val_le; diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-ico= unt.c index 76b9bedc08..c886d16218 100644 --- a/accel/tcg/tcg-accel-ops-icount.c +++ b/accel/tcg/tcg-accel-ops-icount.c @@ -123,7 +123,7 @@ void icount_prepare_for_run(CPUState *cpu, int64_t cpu_= budget) =20 if (cpu->icount_budget =3D=3D 0) { /* - * We're called without the iothread lock, so must take it while + * We're called without the BQL, so must take it while * we're calling timer handlers. */ qemu_bql_lock(); diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c index ffb2c25145..c6c8821313 100644 --- a/hw/remote/mpqemu-link.c +++ b/hw/remote/mpqemu-link.c @@ -58,7 +58,7 @@ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Err= or **errp) assert(qemu_in_coroutine() || !iothread); =20 /* - * Skip unlocking/locking iothread lock when the IOThread is running + * Skip unlocking/locking BQL when the IOThread is running * in co-routine context. Co-routine context is asserted above * for IOThread case. * Also skip lock handling while in a co-routine in the main context. diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index b5a2d377db..f8bc70b45d 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -464,7 +464,7 @@ static void send_bitmap_bits(QEMUFile *f, DBMSaveState = *s, g_free(buf); } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ static void dirty_bitmap_do_save_cleanup(DBMSaveState *s) { SaveBitmapState *dbms; @@ -479,7 +479,7 @@ static void dirty_bitmap_do_save_cleanup(DBMSaveState *= s) } } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, const char *bs_name, GHashTable *alias_map) { @@ -598,7 +598,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, return 0; } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ static int init_dirty_bitmap_migration(DBMSaveState *s) { BlockDriverState *bs; @@ -607,7 +607,7 @@ static int init_dirty_bitmap_migration(DBMSaveState *s) BlockBackend *blk; GHashTable *alias_map =3D NULL; =20 - /* Runs in the migration thread, but holds the iothread lock */ + /* Runs in the migration thread, but holds the BQL */ GLOBAL_STATE_CODE(); GRAPH_RDLOCK_GUARD_MAINLOOP(); =20 @@ -742,7 +742,7 @@ static int dirty_bitmap_save_iterate(QEMUFile *f, void = *opaque) return s->bulk_completed; } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ =20 static int dirty_bitmap_save_complete(QEMUFile *f, void *opaque) { diff --git a/migration/block.c b/migration/block.c index 87f36e6e35..464510e889 100644 --- a/migration/block.c +++ b/migration/block.c @@ -66,7 +66,7 @@ typedef struct BlkMigDevState { /* Protected by block migration lock. */ int64_t completed_sectors; =20 - /* During migration this is protected by iothread lock / AioContext. + /* During migration this is protected by BQL / AioContext. * Allocation and free happen during setup and cleanup respectively. */ BdrvDirtyBitmap *dirty_bitmap; @@ -101,7 +101,7 @@ typedef struct BlkMigState { int prev_progress; int bulk_completed; =20 - /* Lock must be taken _inside_ the iothread lock and any AioContexts. = */ + /* Lock must be taken _inside_ the BQL and any AioContexts. */ QemuMutex lock; } BlkMigState; =20 @@ -117,7 +117,7 @@ static void blk_mig_unlock(void) qemu_mutex_unlock(&block_mig_state.lock); } =20 -/* Must run outside of the iothread lock during the bulk phase, +/* Must run outside of the BQL during the bulk phase, * or the VM will stall. */ =20 @@ -334,7 +334,7 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevS= tate *bmds) return (bmds->cur_sector >=3D total_sectors); } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ =20 static int set_dirty_tracking(void) { @@ -361,7 +361,7 @@ fail: return ret; } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ =20 static void unset_dirty_tracking(void) { @@ -512,7 +512,7 @@ static void blk_mig_reset_dirty_cursor(void) } } =20 -/* Called with iothread lock and AioContext taken. */ +/* Called with BQL and AioContext taken. */ =20 static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, int is_async) @@ -594,7 +594,7 @@ error: return ret; } =20 -/* Called with iothread lock taken. +/* Called with BQL taken. * * return value: * 0: too much data for max_downtime @@ -658,7 +658,7 @@ static int flush_blks(QEMUFile *f) return ret; } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ =20 static int64_t get_remaining_dirty(void) { @@ -676,7 +676,7 @@ static int64_t get_remaining_dirty(void) =20 =20 =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ static void block_migration_cleanup_bmds(void) { BlkMigDevState *bmds; @@ -706,7 +706,7 @@ static void block_migration_cleanup_bmds(void) } } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ static void block_migration_cleanup(void *opaque) { BlkMigBlock *blk; @@ -783,7 +783,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque) } ret =3D 0; } else { - /* Always called with iothread lock taken for + /* Always called with BQL taken for * simplicity, block_save_complete also calls it. */ qemu_bql_lock(); @@ -811,7 +811,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque) return (delta_bytes > 0); } =20 -/* Called with iothread lock taken. */ +/* Called with BQL taken. */ =20 static int block_save_complete(QEMUFile *f, void *opaque) { diff --git a/migration/colo.c b/migration/colo.c index 2e68107cfa..44c789b82b 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -945,7 +945,7 @@ int coroutine_fn colo_incoming_co(void) qemu_thread_join(&th); qemu_bql_lock(); =20 - /* We hold the global iothread lock, so it is safe here */ + /* We hold the global BQL, so it is safe here */ colo_release_ram_cache(); =20 return 0; diff --git a/migration/migration.c b/migration/migration.c index b153133fba..ceb5b69c0c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2566,7 +2566,7 @@ fail: =20 /** * migration_maybe_pause: Pause if required to by - * migrate_pause_before_switchover called with the iothread locked + * migrate_pause_before_switchover called with the BQL locked * Returns: 0 on success */ static int migration_maybe_pause(MigrationState *s, diff --git a/migration/ram.c b/migration/ram.c index f274bcf655..0884affa54 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2395,7 +2395,7 @@ static void ram_save_cleanup(void *opaque) =20 /* We don't use dirty log with background snapshots */ if (!migrate_background_snapshot()) { - /* caller have hold iothread lock or is in a bh, so there is + /* caller have hold BQL or is in a bh, so there is * no writing race against the migration bitmap */ if (global_dirty_tracking & GLOBAL_DIRTY_MIGRATION) { @@ -3131,7 +3131,7 @@ out: * * Returns zero to indicate success or negative on error * - * Called with iothread lock + * Called with BQL * * @f: QEMUFile where to send the data * @opaque: RAMState pointer diff --git a/system/physmem.c b/system/physmem.c index c136675876..9d0cd31ef5 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -799,7 +799,7 @@ static RAMBlock *qemu_get_ram_block(ram_addr_t addr) abort(); =20 found: - /* It is safe to write mru_block outside the iothread lock. This + /* It is safe to write mru_block outside the BQL. This * is what happens: * * mru_block =3D xxx @@ -1597,7 +1597,7 @@ int qemu_ram_get_fd(RAMBlock *rb) return rb->fd; } =20 -/* Called with iothread lock held. */ +/* Called with BQL held. */ void qemu_ram_set_idstr(RAMBlock *new_block, const char *name, DeviceState= *dev) { RAMBlock *block; @@ -1625,7 +1625,7 @@ void qemu_ram_set_idstr(RAMBlock *new_block, const ch= ar *name, DeviceState *dev) } } =20 -/* Called with iothread lock held. */ +/* Called with BQL held. */ void qemu_ram_unset_idstr(RAMBlock *block) { /* FIXME: arch_init.c assumes that this is not called throughout diff --git a/target/arm/helper.c b/target/arm/helper.c index f472043986..1262a33844 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5824,7 +5824,7 @@ static void do_hcr_write(CPUARMState *env, uint64_t v= alue, uint64_t valid_mask) * Updates to VI and VF require us to update the status of * virtual interrupts, which are the logical OR of these bits * and the state of the input lines from the GIC. (This requires - * that we have the iothread lock, which is done by marking the + * that we have the BQL, which is done by marking the * reginfo structs as ARM_CP_IO.) * Note that if a write to HCR pends a VIRQ or VFIQ it is never * possible for it to be taken immediately, because VIRQ and diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 5f38b9a4a1..78c339b526 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -373,7 +373,7 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) bool ts =3D is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MAS= K); bool take_exception; =20 - /* Take the iothread lock as we are going to touch the NVIC */ + /* Take the BQL as we are going to touch the NVIC */ qemu_bql_lock(); =20 /* Check the background context had access to the FPU */ diff --git a/ui/spice-core.c b/ui/spice-core.c index 1d895d2fe8..40923bfa58 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -217,7 +217,7 @@ static void channel_event(int event, SpiceChannelEventI= nfo *info) * not do that. It isn't that easy to fix it in spice and even * when it is fixed we still should cover the already released * spice versions. So detect that we've been called from another - * thread and grab the iothread lock if so before calling qemu + * thread and grab the BQL if so before calling qemu * functions. */ bool need_lock =3D !qemu_thread_is_self(&me); diff --git a/util/rcu.c b/util/rcu.c index 8331f24288..88fc7479b2 100644 --- a/util/rcu.c +++ b/util/rcu.c @@ -409,7 +409,7 @@ static void rcu_init_complete(void) =20 qemu_event_init(&rcu_call_ready_event, false); =20 - /* The caller is assumed to have iothread lock, so the call_rcu thread + /* The caller is assumed to have BQL, so the call_rcu thread * must have been quiescent even after forking, just recreate it. */ qemu_thread_create(&thread, "call_rcu", call_rcu_thread, diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 866d7a9436..b192fc6e83 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -299,7 +299,7 @@ static ret_type glue(coreaudio_, name)args_decl = \ #undef COREAUDIO_WRAPPER_FUNC =20 /* - * callback to feed audiooutput buffer. called without iothread lock. + * callback to feed audiooutput buffer. called without BQL. * allowed to lock "buf_mutex", but disallowed to have any other locks. */ static OSStatus audioDeviceIOProc( @@ -538,7 +538,7 @@ static void update_device_playback_state(coreaudioVoice= Out *core) } } =20 -/* called without iothread lock. */ +/* called without BQL. */ static OSStatus handle_voice_change( AudioObjectID in_object_id, UInt32 in_number_addresses, diff --git a/ui/cocoa.m b/ui/cocoa.m index 8a7d0a6f0c..51e41a6333 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -113,7 +113,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static QemuClipboardInfo *cbinfo; static QemuEvent cbevent; =20 -// Utility functions to run specified code block with iothread lock held +// Utility functions to run specified code block with BQL held typedef void (^CodeBlock)(void); typedef bool (^BoolCodeBlock)(void); =20 @@ -548,7 +548,7 @@ - (void) setContentDimensions =20 - (void) updateUIInfoLocked { - /* Must be called with the iothread lock, i.e. via updateUIInfo */ + /* Must be called with the BQL, i.e. via updateUIInfo */ NSSize frameSize; QemuUIInfo info; =20 @@ -2075,7 +2075,7 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) * Create the menu entries which depend on QEMU state (for consoles * and removable devices). These make calls back into QEMU functions, * which is OK because at this point we know that the second thread - * holds the iothread lock and is synchronously waiting for us to + * holds the BQL and is synchronously waiting for us to * finish. */ add_console_menu_entries(); --=20 2.42.0 From nobody Wed Nov 27 03:48:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1701293245; cv=none; d=zohomail.com; s=zohoarc; b=f9bXlJMqb5WoWLBGprPJoHnoyzCiuPqkarEi+r7CiF0HWLEVgmkW73stDlGHfHquWGWAe1m4j0/9WDF3q458OxUBSqAf1lWqGmo9HRXP0Ihv90q28ZoVbxT6LKvOLpvxgmRS84HnG9E0nWLPZv8hhbUDzNkP6ztxHHHyV/uEaVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701293245; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BpLNXxP4Yehpq7UvX9OuyGYKLdha9NvrROrpeAtoX0o=; b=F3mFUGwuPsHMsH4syJv4LEiHpok3+NzfMemhExxFDrY3n+KjRkqf4X5j1q4vQlFi7hX73UmzQEs504DtE78caP5EDhm0pFnBk7Ii0BN8eVtc/reWFRYw3h5oLxN7888HbMvqFclXBN7nDd2DIL6RqB4p1R6UzKfX6Knyt4hM+yk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701293245296762.1090151085707; Wed, 29 Nov 2023 13:27:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644254.1005104 (Exim 4.92) (envelope-from ) id 1r8S5E-0001nR-2K; Wed, 29 Nov 2023 21:27:00 +0000 Received: by outflank-mailman (output) from mailman id 644254.1005104; Wed, 29 Nov 2023 21:27:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S5D-0001j0-Nu; Wed, 29 Nov 2023 21:26:59 +0000 Received: by outflank-mailman (input) for mailman id 644254; Wed, 29 Nov 2023 21:26:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8S5C-00008d-5Z for xen-devel@lists.xenproject.org; Wed, 29 Nov 2023 21:26:58 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0489934e-8efe-11ee-98e4-6d05b1d4d9a1; Wed, 29 Nov 2023 22:26:55 +0100 (CET) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-FSUOmW5LOtChOrGn_QBs1g-1; Wed, 29 Nov 2023 16:26:51 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63A1138049F9; Wed, 29 Nov 2023 21:26:49 +0000 (UTC) Received: from localhost (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41F60492BE0; Wed, 29 Nov 2023 21:26:48 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0489934e-8efe-11ee-98e4-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701293214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BpLNXxP4Yehpq7UvX9OuyGYKLdha9NvrROrpeAtoX0o=; b=Gu8Ymmv44Elij5mK8jFXcUituPCnDLYAJpD9KXKFLVX9MubljpeNOfIwTcsSvP9jqYTB1P LoyVPmeqlu8HMZqSUUsezu+7M6v0GUxt0cKJNErFjcdaKZYaG1Qhrje96yCL7jQiJ2WsVf C4GQj6L64KW/yT8mcvzvDN1y5Fb5OHc= X-MC-Unique: FSUOmW5LOtChOrGn_QBs1g-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Jean-Christophe Dubois , Fabiano Rosas , qemu-s390x@nongnu.org, Song Gao , Marcel Apfelbaum , Thomas Huth , Hyman Huang , Marcelo Tosatti , David Woodhouse , Andrey Smirnov , Peter Maydell , Kevin Wolf , Ilya Leoshkevich , Artyom Tarasenko , Mark Cave-Ayland , Max Filippov , Alistair Francis , Paul Durrant , Jagannathan Raman , Juan Quintela , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-arm@nongnu.org, Jason Wang , Gerd Hoffmann , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , BALATON Zoltan , Daniel Henrique Barboza , Elena Ufimtseva , Aurelien Jarno , Hailiang Zhang , Roman Bolshakov , Huacai Chen , Fam Zheng , Eric Blake , Jiri Slaby , Alexander Graf , Liu Zhiwei , Weiwei Li , Eric Farman , Stafford Horne , David Hildenbrand , Markus Armbruster , Reinoud Zandijk , Palmer Dabbelt , Cameron Esfahani , xen-devel@lists.xenproject.org, Pavel Dovgalyuk , qemu-riscv@nongnu.org, Aleksandar Rikalo , John Snow , Sunil Muthuswamy , Michael Roth , David Gibson , "Michael S. Tsirkin" , Richard Henderson , Bin Meng , Stefano Stabellini , kvm@vger.kernel.org, Stefan Hajnoczi , qemu-block@nongnu.org, Halil Pasic , Peter Xu , Anthony Perard , Harsh Prateek Bora , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Borntraeger , Akihiko Odaki , Leonardo Bras , Nicholas Piggin , Jiaxun Yang Subject: [PATCH 6/6] Rename "QEMU global mutex" to "BQL" in comments and docs Date: Wed, 29 Nov 2023 16:26:25 -0500 Message-ID: <20231129212625.1051502-7-stefanha@redhat.com> In-Reply-To: <20231129212625.1051502-1-stefanha@redhat.com> References: <20231129212625.1051502-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701293246787000001 Content-Type: text/plain; charset="utf-8" The term "QEMU global mutex" is identical to the more widely used Big QEMU Lock ("BQL"). Update the code comments and documentation to use "BQL" instead of "QEMU global mutex". Signed-off-by: Stefan Hajnoczi Acked-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/multi-thread-tcg.rst | 7 +++---- docs/devel/qapi-code-gen.rst | 2 +- docs/devel/replay.rst | 2 +- docs/devel/multiple-iothreads.txt | 16 ++++++++-------- include/block/blockjob.h | 6 +++--- include/io/task.h | 2 +- include/qemu/coroutine-core.h | 2 +- include/qemu/coroutine.h | 2 +- hw/block/dataplane/virtio-blk.c | 8 ++++---- hw/block/virtio-blk.c | 2 +- hw/scsi/virtio-scsi-dataplane.c | 6 +++--- net/tap.c | 2 +- 12 files changed, 28 insertions(+), 29 deletions(-) diff --git a/docs/devel/multi-thread-tcg.rst b/docs/devel/multi-thread-tcg.= rst index c9541a7b20..7302c3bf53 100644 --- a/docs/devel/multi-thread-tcg.rst +++ b/docs/devel/multi-thread-tcg.rst @@ -226,10 +226,9 @@ instruction. This could be a future optimisation. Emulated hardware state ----------------------- =20 -Currently thanks to KVM work any access to IO memory is automatically -protected by the global iothread mutex, also known as the BQL (Big -QEMU Lock). Any IO region that doesn't use global mutex is expected to -do its own locking. +Currently thanks to KVM work any access to IO memory is automatically prot= ected +by the BQL (Big QEMU Lock). Any IO region that doesn't use the BQL is expe= cted +to do its own locking. =20 However IO memory isn't the only way emulated hardware state can be modified. Some architectures have model specific registers that diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index 7f78183cd4..ea8228518c 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -594,7 +594,7 @@ blocking the guest and other background operations. Coroutine safety can be hard to prove, similar to thread safety. Common pitfalls are: =20 -- The global mutex isn't held across ``qemu_coroutine_yield()``, so +- The BQL isn't held across ``qemu_coroutine_yield()``, so operations that used to assume that they execute atomically may have to be more careful to protect against changes in the global state. =20 diff --git a/docs/devel/replay.rst b/docs/devel/replay.rst index 0244be8b9c..effd856f0c 100644 --- a/docs/devel/replay.rst +++ b/docs/devel/replay.rst @@ -184,7 +184,7 @@ modes. Reading and writing requests are created by CPU thread of QEMU. Later these requests proceed to block layer which creates "bottom halves". Bottom halves consist of callback and its parameters. They are processed when -main loop locks the global mutex. These locks are not synchronized with +main loop locks the BQL. These locks are not synchronized with replaying process because main loop also processes the events that do not affect the virtual machine state (like user interaction with monitor). =20 diff --git a/docs/devel/multiple-iothreads.txt b/docs/devel/multiple-iothre= ads.txt index a3e949f6b3..828e5527a3 100644 --- a/docs/devel/multiple-iothreads.txt +++ b/docs/devel/multiple-iothreads.txt @@ -5,7 +5,7 @@ the COPYING file in the top-level directory. =20 =20 This document explains the IOThread feature and how to write code that runs -outside the QEMU global mutex. +outside the BQL. =20 The main loop and IOThreads --------------------------- @@ -29,13 +29,13 @@ scalability bottleneck on hosts with many CPUs. Work c= an be spread across several IOThreads instead of just one main loop. When set up correctly th= is can improve I/O latency and reduce jitter seen by the guest. =20 -The main loop is also deeply associated with the QEMU global mutex, which = is a -scalability bottleneck in itself. vCPU threads and the main loop use the = QEMU -global mutex to serialize execution of QEMU code. This mutex is necessary -because a lot of QEMU's code historically was not thread-safe. +The main loop is also deeply associated with the BQL, which is a +scalability bottleneck in itself. vCPU threads and the main loop use the = BQL +to serialize execution of QEMU code. This mutex is necessary because a lo= t of +QEMU's code historically was not thread-safe. =20 The fact that all I/O processing is done in a single main loop and that the -QEMU global mutex is contended by all vCPU threads and the main loop expla= in +BQL is contended by all vCPU threads and the main loop explain why it is desirable to place work into IOThreads. =20 The experimental virtio-blk data-plane implementation has been benchmarked= and @@ -66,7 +66,7 @@ There are several old APIs that use the main loop AioCont= ext: =20 Since they implicitly work on the main loop they cannot be used in code th= at runs in an IOThread. They might cause a crash or deadlock if called from = an -IOThread since the QEMU global mutex is not held. +IOThread since the BQL is not held. =20 Instead, use the AioContext functions directly (see include/block/aio.h): * aio_set_fd_handler() - monitor a file descriptor @@ -105,7 +105,7 @@ used in the block layer and can lead to hangs. =20 There is currently no lock ordering rule if a thread needs to acquire mult= iple AioContexts simultaneously. Therefore, it is only safe for code holding t= he -QEMU global mutex to acquire other AioContexts. +BQL to acquire other AioContexts. =20 Side note: the best way to schedule a function call across threads is to c= all aio_bh_schedule_oneshot(). No acquire/release or locking is needed. diff --git a/include/block/blockjob.h b/include/block/blockjob.h index e594c10d23..b2bc7c04d6 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -54,7 +54,7 @@ typedef struct BlockJob { =20 /** * Speed that was set with @block_job_set_speed. - * Always modified and read under QEMU global mutex (GLOBAL_STATE_CODE= ). + * Always modified and read under BQL (GLOBAL_STATE_CODE). */ int64_t speed; =20 @@ -66,7 +66,7 @@ typedef struct BlockJob { =20 /** * Block other operations when block job is running. - * Always modified and read under QEMU global mutex (GLOBAL_STATE_CODE= ). + * Always modified and read under BQL (GLOBAL_STATE_CODE). */ Error *blocker; =20 @@ -89,7 +89,7 @@ typedef struct BlockJob { =20 /** * BlockDriverStates that are involved in this block job. - * Always modified and read under QEMU global mutex (GLOBAL_STATE_CODE= ). + * Always modified and read under BQL (GLOBAL_STATE_CODE). */ GSList *nodes; } BlockJob; diff --git a/include/io/task.h b/include/io/task.h index dc7d32ebd0..0b5342ee84 100644 --- a/include/io/task.h +++ b/include/io/task.h @@ -149,7 +149,7 @@ typedef void (*QIOTaskWorker)(QIOTask *task, * lookups) to be easily run non-blocking. Reporting the * results in the main thread context means that the caller * typically does not need to be concerned about thread - * safety wrt the QEMU global mutex. + * safety wrt the BQL. * * For example, the socket_listen() method will block the caller * while DNS lookups take place if given a name, instead of IP diff --git a/include/qemu/coroutine-core.h b/include/qemu/coroutine-core.h index 230bb56517..503bad6e0e 100644 --- a/include/qemu/coroutine-core.h +++ b/include/qemu/coroutine-core.h @@ -22,7 +22,7 @@ * rather than callbacks, for operations that need to give up control while * waiting for events to complete. * - * These functions are re-entrant and may be used outside the global mutex. + * These functions are re-entrant and may be used outside the BQL. * * Functions that execute in coroutine context cannot be called * directly from normal functions. Use @coroutine_fn to mark such diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index a65be6697f..e6aff45301 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -26,7 +26,7 @@ * rather than callbacks, for operations that need to give up control while * waiting for events to complete. * - * These functions are re-entrant and may be used outside the global mutex. + * These functions are re-entrant and may be used outside the BQL. * * Functions that execute in coroutine context cannot be called * directly from normal functions. Use @coroutine_fn to mark such diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index f83bb0f116..eafc573407 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -47,7 +47,7 @@ void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s= , VirtQueue *vq) virtio_notify_irqfd(s->vdev, vq); } =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, VirtIOBlockDataPlane **dataplane, Error **errp) @@ -100,7 +100,7 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, V= irtIOBlkConf *conf, return true; } =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s) { VirtIOBlock *vblk; @@ -117,7 +117,7 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane= *s) g_free(s); } =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ int virtio_blk_data_plane_start(VirtIODevice *vdev) { VirtIOBlock *vblk =3D VIRTIO_BLK(vdev); @@ -261,7 +261,7 @@ static void virtio_blk_data_plane_stop_bh(void *opaque) } } =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ void virtio_blk_data_plane_stop(VirtIODevice *vdev) { VirtIOBlock *vblk =3D VIRTIO_BLK(vdev); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index a1f8e15522..2a5f6544cc 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1500,7 +1500,7 @@ static void virtio_blk_resize(void *opaque) VirtIODevice *vdev =3D VIRTIO_DEVICE(opaque); =20 /* - * virtio_notify_config() needs to acquire the global mutex, + * virtio_notify_config() needs to acquire the BQL, * so it can't be called from an iothread. Instead, schedule * it to be run in the main context BH. */ diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 1e684beebe..56ecc5b12e 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -20,7 +20,7 @@ #include "scsi/constants.h" #include "hw/virtio/virtio-bus.h" =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp) { VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(s); @@ -93,7 +93,7 @@ static void virtio_scsi_dataplane_stop_bh(void *opaque) } } =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ int virtio_scsi_dataplane_start(VirtIODevice *vdev) { int i; @@ -191,7 +191,7 @@ fail_guest_notifiers: return -ENOSYS; } =20 -/* Context: QEMU global mutex held */ +/* Context: BQL held */ void virtio_scsi_dataplane_stop(VirtIODevice *vdev) { BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); diff --git a/net/tap.c b/net/tap.c index c23d0323c2..c698b70475 100644 --- a/net/tap.c +++ b/net/tap.c @@ -219,7 +219,7 @@ static void tap_send(void *opaque) =20 /* * When the host keeps receiving more packets while tap_send() is - * running we can hog the QEMU global mutex. Limit the number of + * running we can hog the BQL. Limit the number of * packets that are processed per tap_send() callback to prevent * stalling the guest. */ --=20 2.42.0