qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 17/47] accel/tcg: Remove cpu_neg()
Date: Tue,  3 Oct 2023 10:30:22 -0700	[thread overview]
Message-ID: <20231003173052.1601813-18-richard.henderson@linaro.org> (raw)
In-Reply-To: <20231003173052.1601813-1-richard.henderson@linaro.org>

Now that CPUNegativeOffsetState is part of CPUState,
we can reference it directly.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-all.h           | 11 -----------
 include/exec/exec-all.h          |  2 +-
 accel/tcg/cpu-exec.c             | 14 +++++++-------
 accel/tcg/tcg-accel-ops-icount.c |  6 +++---
 accel/tcg/tcg-accel-ops.c        |  2 +-
 accel/tcg/translate-all.c        |  6 +++---
 softmmu/icount.c                 |  2 +-
 7 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 25cd63e1b8..114ec70359 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -471,17 +471,6 @@ static inline CPUNegativeOffsetState *env_neg(CPUArchState *env)
     return &env_cpu(env)->neg;
 }
 
-/**
- * cpu_neg(cpu)
- * @cpu: The generic CPUState
- *
- * Return the CPUNegativeOffsetState associated with the cpu.
- */
-static inline CPUNegativeOffsetState *cpu_neg(CPUState *cpu)
-{
-    return &cpu->neg;
-}
-
 /**
  * env_tlb(env)
  * @env: The architecture environment
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index b2f5cd4c2a..2e4d337805 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -71,7 +71,7 @@ G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc);
  */
 static inline bool cpu_loop_exit_requested(CPUState *cpu)
 {
-    return (int32_t)qatomic_read(&cpu_neg(cpu)->icount_decr.u32) < 0;
+    return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0;
 }
 
 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index de60fdb612..3a18dd84ef 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -73,7 +73,7 @@ static void align_clocks(SyncClocks *sc, CPUState *cpu)
         return;
     }
 
-    cpu_icount = cpu->icount_extra + cpu_neg(cpu)->icount_decr.u16.low;
+    cpu_icount = cpu->icount_extra + cpu->neg.icount_decr.u16.low;
     sc->diff_clk += icount_to_ns(sc->last_cpu_icount - cpu_icount);
     sc->last_cpu_icount = cpu_icount;
 
@@ -124,7 +124,7 @@ static void init_delay_params(SyncClocks *sc, CPUState *cpu)
     sc->realtime_clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT);
     sc->diff_clk = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - sc->realtime_clock;
     sc->last_cpu_icount
-        = cpu->icount_extra + cpu_neg(cpu)->icount_decr.u16.low;
+        = cpu->icount_extra + cpu->neg.icount_decr.u16.low;
     if (sc->diff_clk < max_delay) {
         max_delay = sc->diff_clk;
     }
@@ -717,7 +717,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
     if (cpu->exception_index < 0) {
 #ifndef CONFIG_USER_ONLY
         if (replay_has_exception()
-            && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) {
+            && cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0) {
             /* Execute just one insn to trigger exception pending in the log */
             cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT)
                 | CF_LAST_IO | CF_NOIRQ | 1;
@@ -807,7 +807,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
      * Ensure zeroing happens before reading cpu->exit_request or
      * cpu->interrupt_request (see also smp_wmb in cpu_exit())
      */
-    qatomic_set_mb(&cpu_neg(cpu)->icount_decr.u16.high, 0);
+    qatomic_set_mb(&cpu->neg.icount_decr.u16.high, 0);
 
     if (unlikely(qatomic_read(&cpu->interrupt_request))) {
         int interrupt_request;
@@ -898,7 +898,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
     if (unlikely(qatomic_read(&cpu->exit_request))
         || (icount_enabled()
             && (cpu->cflags_next_tb == -1 || cpu->cflags_next_tb & CF_USE_ICOUNT)
-            && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0)) {
+            && cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0)) {
         qatomic_set(&cpu->exit_request, 0);
         if (cpu->exception_index == -1) {
             cpu->exception_index = EXCP_INTERRUPT;
@@ -923,7 +923,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
     }
 
     *last_tb = NULL;
-    insns_left = qatomic_read(&cpu_neg(cpu)->icount_decr.u32);
+    insns_left = qatomic_read(&cpu->neg.icount_decr.u32);
     if (insns_left < 0) {
         /* Something asked us to stop executing chained TBs; just
          * continue round the main loop. Whatever requested the exit
@@ -942,7 +942,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
     icount_update(cpu);
     /* Refill decrementer and continue execution.  */
     insns_left = MIN(0xffff, cpu->icount_budget);
-    cpu_neg(cpu)->icount_decr.u16.low = insns_left;
+    cpu->neg.icount_decr.u16.low = insns_left;
     cpu->icount_extra = cpu->icount_budget - insns_left;
 
     /*
diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-icount.c
index 0af643b217..b25685fb71 100644
--- a/accel/tcg/tcg-accel-ops-icount.c
+++ b/accel/tcg/tcg-accel-ops-icount.c
@@ -111,14 +111,14 @@ void icount_prepare_for_run(CPUState *cpu, int64_t cpu_budget)
      * each vCPU execution. However u16.high can be raised
      * asynchronously by cpu_exit/cpu_interrupt/tcg_handle_interrupt
      */
-    g_assert(cpu_neg(cpu)->icount_decr.u16.low == 0);
+    g_assert(cpu->neg.icount_decr.u16.low == 0);
     g_assert(cpu->icount_extra == 0);
 
     replay_mutex_lock();
 
     cpu->icount_budget = MIN(icount_get_limit(), cpu_budget);
     insns_left = MIN(0xffff, cpu->icount_budget);
-    cpu_neg(cpu)->icount_decr.u16.low = insns_left;
+    cpu->neg.icount_decr.u16.low = insns_left;
     cpu->icount_extra = cpu->icount_budget - insns_left;
 
     if (cpu->icount_budget == 0) {
@@ -138,7 +138,7 @@ void icount_process_data(CPUState *cpu)
     icount_update(cpu);
 
     /* Reset the counters */
-    cpu_neg(cpu)->icount_decr.u16.low = 0;
+    cpu->neg.icount_decr.u16.low = 0;
     cpu->icount_extra = 0;
     cpu->icount_budget = 0;
 
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 3973591508..d885cc1d3c 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -91,7 +91,7 @@ void tcg_handle_interrupt(CPUState *cpu, int mask)
     if (!qemu_cpu_is_self(cpu)) {
         qemu_cpu_kick(cpu);
     } else {
-        qatomic_set(&cpu_neg(cpu)->icount_decr.u16.high, -1);
+        qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
     }
 }
 
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 098d99b5d4..ed0c7ef7ce 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -214,7 +214,7 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
          * Reset the cycle counter to the start of the block and
          * shift if to the number of actually executed instructions.
          */
-        cpu_neg(cpu)->icount_decr.u16.low += insns_left;
+        cpu->neg.icount_decr.u16.low += insns_left;
     }
 
     cpu->cc->tcg_ops->restore_state_to_opc(cpu, tb, data);
@@ -623,7 +623,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
     cc = CPU_GET_CLASS(cpu);
     if (cc->tcg_ops->io_recompile_replay_branch &&
         cc->tcg_ops->io_recompile_replay_branch(cpu, tb)) {
-        cpu_neg(cpu)->icount_decr.u16.low++;
+        cpu->neg.icount_decr.u16.low++;
         n = 2;
     }
 
@@ -779,7 +779,7 @@ void cpu_interrupt(CPUState *cpu, int mask)
 {
     g_assert(qemu_mutex_iothread_locked());
     cpu->interrupt_request |= mask;
-    qatomic_set(&cpu_neg(cpu)->icount_decr.u16.high, -1);
+    qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
 }
 
 #endif /* CONFIG_USER_ONLY */
diff --git a/softmmu/icount.c b/softmmu/icount.c
index 956d15e343..4527bfbd6e 100644
--- a/softmmu/icount.c
+++ b/softmmu/icount.c
@@ -75,7 +75,7 @@ static void icount_enable_adaptive(void)
 static int64_t icount_get_executed(CPUState *cpu)
 {
     return (cpu->icount_budget -
-            (cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra));
+            (cpu->neg.icount_decr.u16.low + cpu->icount_extra));
 }
 
 /*
-- 
2.34.1



  parent reply	other threads:[~2023-10-03 17:38 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 17:30 [PULL 00/47] tcg patch queue Richard Henderson
2023-10-03 17:30 ` [PULL 01/47] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Richard Henderson
2023-10-03 17:30 ` [PULL 02/47] accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize() Richard Henderson
2023-10-03 17:30 ` [PULL 03/47] accel: Rename accel_cpu_realize() -> accel_cpu_common_realize() Richard Henderson
2023-10-03 17:30 ` [PULL 04/47] accel: Introduce accel_cpu_common_unrealize() stub Richard Henderson
2023-10-03 17:30 ` [PULL 05/47] accel: Declare AccelClass::cpu_common_[un]realize() handlers Richard Henderson
2023-10-03 17:30 ` [PULL 06/47] accel/tcg: Have tcg_exec_realizefn() return a boolean Richard Henderson
2023-10-03 17:30 ` [PULL 07/47] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Richard Henderson
2023-10-03 17:30 ` [PULL 08/47] target/arm: Replace TARGET_PAGE_ENTRY_EXTRA Richard Henderson
2023-10-03 17:30 ` [PULL 09/47] accel/tcg: Move CPUTLB definitions from cpu-defs.h Richard Henderson
2023-10-03 17:30 ` [PULL 10/47] qom: Propagate alignment through type system Richard Henderson
2023-10-03 17:30 ` [PULL 11/47] target/arm: Remove size and alignment for cpu subclasses Richard Henderson
2023-10-03 17:30 ` [PULL 12/47] target/*: Add instance_align to all cpu base classes Richard Henderson
2023-10-03 17:30 ` [PULL 13/47] accel/tcg: Validate placement of CPUNegativeOffsetState Richard Henderson
2023-10-03 17:30 ` [PULL 14/47] accel/tcg: Move CPUNegativeOffsetState into CPUState Richard Henderson
2023-10-03 17:30 ` [PULL 15/47] accel/tcg: Remove CPUState.icount_decr_ptr Richard Henderson
2023-10-03 17:30 ` [PULL 16/47] accel/tcg: Move can_do_io to CPUNegativeOffsetState Richard Henderson
2023-10-03 17:30 ` Richard Henderson [this message]
2023-10-03 17:30 ` [PULL 18/47] tcg: Rename cpu_env to tcg_env Richard Henderson
2023-10-03 17:30 ` [PULL 19/47] accel/tcg: Replace CPUState.env_ptr with cpu_env() Richard Henderson
2023-10-03 17:30 ` [PULL 20/47] accel/tcg: Remove cpu_set_cpustate_pointers Richard Henderson
2023-10-03 17:30 ` [PULL 21/47] accel/tcg: Remove env_neg() Richard Henderson
2023-10-03 17:30 ` [PULL 22/47] tcg: Remove TCGContext.tlb_fast_offset Richard Henderson
2023-10-03 17:30 ` [PULL 23/47] accel/tcg: Modify tlb_*() to use CPUState Richard Henderson
2023-10-03 17:30 ` [PULL 24/47] accel/tcg: Modify probe_access_internal() " Richard Henderson
2023-10-03 17:30 ` [PULL 25/47] accel/tcg: Modify memory access functions " Richard Henderson
2023-10-03 17:30 ` [PULL 26/47] accel/tcg: Modify atomic_mmu_lookup() " Richard Henderson
2023-10-03 17:30 ` [PULL 27/47] accel/tcg: Use CPUState in atomicity helpers Richard Henderson
2023-10-03 17:30 ` [PULL 28/47] accel/tcg: Remove env_tlb() Richard Henderson
2023-10-03 17:30 ` [PULL 29/47] accel/tcg: Unify user and softmmu do_[st|ld]*_mmu() Richard Henderson
2023-10-03 17:30 ` [PULL 30/47] accel/tcg: move ld/st helpers to ldst_common.c.inc Richard Henderson
2023-10-03 17:30 ` [PULL 31/47] exec: Make EXCP_FOO definitions target agnostic Richard Henderson
2023-10-03 17:30 ` [PULL 32/47] exec: Move cpu_loop_foo() target agnostic functions to 'cpu-common.h' Richard Henderson
2023-10-03 17:30 ` [PULL 33/47] accel/tcg: Restrict dump_exec_info() declaration Richard Henderson
2023-10-03 17:30 ` [PULL 34/47] accel: Make accel-blocker.o target agnostic Richard Henderson
2023-10-03 17:30 ` [PULL 35/47] accel: Rename accel-common.c -> accel-target.c Richard Henderson
2023-10-03 17:30 ` [PULL 36/47] exec: Rename cpu.c -> cpu-target.c Richard Henderson
2023-10-03 17:30 ` [PULL 37/47] exec: Rename target specific page-vary.c -> page-vary-target.c Richard Henderson
2023-10-03 17:30 ` [PULL 38/47] accel/tcg: Rename target-specific 'internal.h' -> 'internal-target.h' Richard Henderson
2023-10-03 17:30 ` [PULL 39/47] accel/tcg: Make monitor.c a target-agnostic unit Richard Henderson
2023-10-03 17:30 ` [PULL 40/47] accel/tcg: Make icount.o a target agnostic unit Richard Henderson
2023-10-03 17:30 ` [PULL 41/47] accel/tcg: Make cpu-exec-common.c " Richard Henderson
2023-10-03 17:30 ` [PULL 42/47] tcg: Remove argument to tcg_prologue_init Richard Henderson
2023-10-03 17:30 ` [PULL 43/47] tcg: Split out tcg init functions to tcg/startup.h Richard Henderson
2023-10-03 17:30 ` [PULL 44/47] linux-user/hppa: Fix struct target_sigcontext layout Richard Henderson
2023-10-03 17:30 ` [PULL 45/47] build: Remove --enable-gprof Richard Henderson
2023-10-03 17:30 ` [PULL 46/47] tests/avocado: Re-enable MIPS Malta tests (GitLab issue #1884 fixed) Richard Henderson
2023-10-03 17:30 ` [PULL 47/47] tcg/loongarch64: Fix buid error Richard Henderson
2023-10-04 14:57 ` [PULL 00/47] tcg patch queue Stefan Hajnoczi
2023-10-04 16:28   ` Richard Henderson
2023-10-04 16:46     ` Stefan Hajnoczi
2023-10-04 17:08       ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231003173052.1601813-18-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).