[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v4 57/71] accel/tcg: convert to cpu_interrupt_requ
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [RFC v4 57/71] accel/tcg: convert to cpu_interrupt_request |
Date: |
Wed, 31 Oct 2018 16:46:33 +0000 |
User-agent: |
mu4e 1.1.0; emacs 26.1.50 |
Emilio G. Cota <address@hidden> writes:
> Signed-off-by: Emilio G. Cota <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
> ---
> accel/tcg/cpu-exec.c | 15 ++++++++-------
> accel/tcg/tcg-all.c | 12 +++++++++---
> accel/tcg/translate-all.c | 2 +-
> 3 files changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index f37c9b1e94..d590f1f6c0 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -428,7 +428,7 @@ static inline bool cpu_handle_halt_locked(CPUState *cpu)
>
> if (cpu_halted(cpu)) {
> #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY)
> - if ((cpu->interrupt_request & CPU_INTERRUPT_POLL)
> + if ((cpu_interrupt_request(cpu) & CPU_INTERRUPT_POLL)
> && replay_interrupt()) {
> X86CPU *x86_cpu = X86_CPU(cpu);
>
> @@ -540,16 +540,17 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
> */
> atomic_mb_set(&cpu->icount_decr.u16.high, 0);
>
> - if (unlikely(atomic_read(&cpu->interrupt_request))) {
> + if (unlikely(cpu_interrupt_request(cpu))) {
> int interrupt_request;
> +
> qemu_mutex_lock_iothread();
> - interrupt_request = cpu->interrupt_request;
> + interrupt_request = cpu_interrupt_request(cpu);
> if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
> /* Mask out external interrupts for this step. */
> interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK;
> }
> if (interrupt_request & CPU_INTERRUPT_DEBUG) {
> - cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
> + cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG);
> cpu->exception_index = EXCP_DEBUG;
> qemu_mutex_unlock_iothread();
> return true;
> @@ -558,7 +559,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
> /* Do nothing */
> } else if (interrupt_request & CPU_INTERRUPT_HALT) {
> replay_interrupt();
> - cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
> + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT);
> cpu_halted_set(cpu, 1);
> cpu->exception_index = EXCP_HLT;
> qemu_mutex_unlock_iothread();
> @@ -595,10 +596,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
> }
> /* The target hook may have updated the 'cpu->interrupt_request';
> * reload the 'interrupt_request' value */
> - interrupt_request = cpu->interrupt_request;
> + interrupt_request = cpu_interrupt_request(cpu);
> }
> if (interrupt_request & CPU_INTERRUPT_EXITTB) {
> - cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB;
> + cpu_reset_interrupt(cpu, CPU_INTERRUPT_EXITTB);
> /* ensure that no TB jump will be modified as
> the program flow was changed */
> *last_tb = NULL;
> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
> index 3d25bdcc17..4e2fe70350 100644
> --- a/accel/tcg/tcg-all.c
> +++ b/accel/tcg/tcg-all.c
> @@ -39,10 +39,16 @@ unsigned long tcg_tb_size;
> static void tcg_handle_interrupt(CPUState *cpu, int mask)
> {
> int old_mask;
> - g_assert(qemu_mutex_iothread_locked());
>
> - old_mask = cpu->interrupt_request;
> - cpu->interrupt_request |= mask;
> + if (!cpu_mutex_locked(cpu)) {
> + cpu_mutex_lock(cpu);
> + old_mask = cpu_interrupt_request(cpu);
> + cpu_interrupt_request_or(cpu, mask);
> + cpu_mutex_unlock(cpu);
> + } else {
> + old_mask = cpu_interrupt_request(cpu);
> + cpu_interrupt_request_or(cpu, mask);
> + }
>
> /*
> * If called from iothread context, wake the target cpu in
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index 356dcd0948..038d82fdb5 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -2340,7 +2340,7 @@ void dump_opcount_info(FILE *f, fprintf_function
> cpu_fprintf)
> void cpu_interrupt(CPUState *cpu, int mask)
> {
> g_assert(qemu_mutex_iothread_locked());
> - cpu->interrupt_request |= mask;
> + cpu_interrupt_request_or(cpu, mask);
> atomic_set(&cpu->icount_decr.u16.high, -1);
> }
--
Alex Bennée
- [Qemu-devel] [RFC v4 01/71] cpu: convert queued work to a QSIMPLEQ, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 71/71] cpus-common: wait on the CPU lock for exclusive work completion, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 67/71] cpus-common: release BQL earlier in run_on_cpu, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 57/71] accel/tcg: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 61/71] mips: convert to cpu_has_work_with_iothread_lock, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 65/71] xtensa: convert to cpu_has_work_with_iothread_lock, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 64/71] sparc: convert to cpu_has_work_with_iothread_lock, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 69/71] cputlb: queue async flush jobs without the BQL, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 50/71] s390x: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/25
- [Qemu-devel] [RFC v4 62/71] s390x: convert to cpu_has_work_with_iothread_lock, Emilio G. Cota, 2018/10/25