From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: philmd@linaro.org
Subject: [PATCH v2 2/3] softmmu: Introduce AddressSpaceDispatch generation numbers
Date: Fri, 15 Sep 2023 09:32:53 -0700 [thread overview]
Message-ID: <20230915163254.123338-3-richard.henderson@linaro.org> (raw)
In-Reply-To: <20230915163254.123338-1-richard.henderson@linaro.org>
Allow the cpu to easily check if an address space update
is required. The acquire/release semantics will be used
by a subsequent patch.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
softmmu/physmem.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 88fafec1da..e1c535380a 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -163,6 +163,8 @@ struct CPUAddressSpace {
AddressSpace *as;
struct AddressSpaceDispatch *memory_dispatch;
MemoryListener tcg_as_listener;
+ uint32_t commit_gen;
+ uint32_t layout_gen;
};
struct DirtyBitmapSnapshot {
@@ -2486,14 +2488,23 @@ static void tcg_log_global_after_sync(MemoryListener *listener)
}
}
-static void tcg_commit_cpu(CPUState *cpu, run_on_cpu_data data)
+static void tcg_commit_cpu_0(CPUState *cpu, CPUAddressSpace *cpuas)
{
- CPUAddressSpace *cpuas = data.host_ptr;
-
cpuas->memory_dispatch = address_space_to_dispatch(cpuas->as);
tlb_flush(cpu);
}
+static void tcg_commit_cpu_1(CPUState *cpu, run_on_cpu_data data)
+{
+ CPUAddressSpace *cpuas = data.host_ptr;
+ uint32_t gen = qatomic_load_acquire(&cpuas->layout_gen);
+
+ if (cpuas->commit_gen != gen) {
+ cpuas->commit_gen = gen;
+ tcg_commit_cpu_0(cpu, cpuas);
+ }
+}
+
static void tcg_commit(MemoryListener *listener)
{
CPUAddressSpace *cpuas;
@@ -2518,9 +2529,10 @@ static void tcg_commit(MemoryListener *listener)
* all of the tcg machinery for run-on is initialized: thus created.
*/
if (cpu->created) {
- async_run_on_cpu(cpu, tcg_commit_cpu, RUN_ON_CPU_HOST_PTR(cpuas));
+ qatomic_store_release(&cpuas->layout_gen, cpuas->layout_gen + 1);
+ async_run_on_cpu(cpu, tcg_commit_cpu_1, RUN_ON_CPU_HOST_PTR(cpuas));
} else {
- tcg_commit_cpu(cpu, RUN_ON_CPU_HOST_PTR(cpuas));
+ tcg_commit_cpu_0(cpu, cpuas);
}
}
--
2.34.1
next prev parent reply other threads:[~2023-09-15 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 16:32 [PATCH v2 0/3] accel/tcg: Alternate fix for #1866 Richard Henderson
2023-09-15 16:32 ` [PATCH v2 1/3] softmmu: Use cpu->created in tcg_commit Richard Henderson
2023-09-15 16:55 ` Philippe Mathieu-Daudé
2023-09-15 16:32 ` Richard Henderson [this message]
2023-09-15 16:32 ` [PATCH v2 3/3] softmmu: Introduce cpu_address_space_sync Richard Henderson
2023-09-15 16:57 ` Philippe Mathieu-Daudé
2023-09-15 17:19 ` Richard Henderson
2023-09-15 16:55 ` [PATCH v2 0/3] accel/tcg: Alternate fix for #1866 Philippe Mathieu-Daudé
2023-09-15 17:18 ` Richard Henderson
2023-09-15 18:54 ` 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=20230915163254.123338-3-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).