system/cpus: rename qemu_mutex_lock_iothread() to bql_lock()

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 bql_lock(void)
- void bql_unlock(void)
- bool 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 <stefanha@redhat.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Fabiano Rosas <farosas@suse.de>
Acked-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Peter Xu <peterx@redhat.com>
Acked-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Acked-by: Hyman Huang <yong.huang@smartx.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-id: 20240102153529.486531-2-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2024-01-02 10:35:25 -05:00
parent 897a06c6d7
commit 195801d700
95 changed files with 529 additions and 529 deletions

View file

@ -1923,7 +1923,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
S390CPU *cpu = S390_CPU(cs);
int ret = 0;
qemu_mutex_lock_iothread();
bql_lock();
kvm_cpu_synchronize_state(cs);
@ -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();
bql_unlock();
if (ret == 0) {
ret = EXCP_INTERRUPT;

View file

@ -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();
bql_lock();
int r = sclp_service_call(env_archcpu(env), r1, r2);
qemu_mutex_unlock_iothread();
bql_unlock();
if (r < 0) {
tcg_s390_program_interrupt(env, -r, GETPC());
}
@ -117,9 +117,9 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
switch (num) {
case 0x500:
/* KVM hypercall */
qemu_mutex_lock_iothread();
bql_lock();
r = s390_virtio_hypercall(env);
qemu_mutex_unlock_iothread();
bql_unlock();
break;
case 0x44:
/* yield */
@ -127,9 +127,9 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
break;
case 0x308:
/* ipl */
qemu_mutex_lock_iothread();
bql_lock();
handle_diag_308(env, r1, r3, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
r = 0;
break;
case 0x288:
@ -185,7 +185,7 @@ static void update_ckc_timer(CPUS390XState *env)
/* stop the timer and remove pending CKC IRQs */
timer_del(env->tod_timer);
g_assert(qemu_mutex_iothread_locked());
g_assert(bql_locked());
env->pending_int &= ~INTERRUPT_EXT_CLOCK_COMPARATOR;
/* 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 = ckc;
qemu_mutex_lock_iothread();
bql_lock();
update_ckc_timer(env);
qemu_mutex_unlock_iothread();
bql_unlock();
}
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_low)
.low = tod_low,
};
qemu_mutex_lock_iothread();
bql_lock();
tdc->set(td, &tod, &error_abort);
qemu_mutex_unlock_iothread();
bql_unlock();
return 0;
}
@ -421,9 +421,9 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
int cc;
/* TODO: needed to inject interrupts - push further down */
qemu_mutex_lock_iothread();
bql_lock();
cc = handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3);
qemu_mutex_unlock_iothread();
bql_unlock();
return cc;
}
@ -433,92 +433,92 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
void HELPER(xsch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_xsch(cpu, r1, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(csch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_csch(cpu, r1, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(hsch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_hsch(cpu, r1, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(msch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_msch(cpu, r1, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(rchp)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_rchp(cpu, r1, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(rsch)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_rsch(cpu, r1, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(sal)(CPUS390XState *env, uint64_t r1)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_sal(cpu, r1, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(schm)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_schm(cpu, r1, r2, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(ssch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_ssch(cpu, r1, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(stcrw)(CPUS390XState *env, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_stcrw(cpu, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(stsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_stsch(cpu, r1, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)
@ -533,10 +533,10 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)
tcg_s390_program_interrupt(env, PGM_SPECIFICATION, ra);
}
qemu_mutex_lock_iothread();
bql_lock();
io = qemu_s390_flic_dequeue_io(flic, env->cregs[6]);
if (!io) {
qemu_mutex_unlock_iothread();
bql_unlock();
return 0;
}
@ -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();
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 addr)
}
g_free(io);
qemu_mutex_unlock_iothread();
bql_unlock();
return 1;
}
void HELPER(tsch)(CPUS390XState *env, uint64_t r1, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_tsch(cpu, r1, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(chsc)(CPUS390XState *env, uint64_t inst)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
ioinst_handle_chsc(cpu, inst >> 16, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
#endif
@ -726,27 +726,27 @@ void HELPER(clp)(CPUS390XState *env, uint32_t r2)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
clp_service_call(cpu, r2, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(pcilg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
pcilg_service_call(cpu, r1, r2, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(pcistg)(CPUS390XState *env, uint32_t r1, uint32_t r2)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
pcistg_service_call(cpu, r1, r2, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
@ -754,9 +754,9 @@ void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
stpcifc_service_call(cpu, r1, fiba, ar, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)
@ -764,9 +764,9 @@ void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)
S390CPU *cpu = env_archcpu(env);
int r;
qemu_mutex_lock_iothread();
bql_lock();
r = css_do_sic(cpu, (r3 >> 27) & 0x7, r1 & 0xffff);
qemu_mutex_unlock_iothread();
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, uint32_t r2)
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
rpcit_service_call(cpu, r1, r2, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, uint32_t r3,
@ -787,9 +787,9 @@ void HELPER(pcistb)(CPUS390XState *env, uint32_t r1, uint32_t r3,
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
pcistb_service_call(cpu, r1, r3, gaddr, ar, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
@ -797,8 +797,8 @@ void HELPER(mpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
{
S390CPU *cpu = env_archcpu(env);
qemu_mutex_lock_iothread();
bql_lock();
mpcifc_service_call(cpu, r1, fiba, ar, GETPC());
qemu_mutex_unlock_iothread();
bql_unlock();
}
#endif