From: Paolo Bonzini <pbonzini@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, serge.fdrv@gmail.com, sergey.fedorov@linaro.org
Subject: Re: [Qemu-devel] [PATCH 02/10] tcg: Pass last_tb by value to tb_find_fast()
Date: Thu, 8 Sep 2016 15:28:15 +0200 [thread overview]
Message-ID: <5f69179b-c88b-dd6e-e262-1bca6834d2a2@redhat.com> (raw)
In-Reply-To: <87wpimy31h.fsf@linaro.org>
On 08/09/2016 14:44, Alex Bennée wrote:
>> > cpu->tb_flushed = false; /* reset before first TB lookup */
>> > for(;;) {
>> > cpu_handle_interrupt(cpu, &last_tb);
>> > - tb = tb_find_fast(cpu, &last_tb, tb_exit);
>> > + tb = tb_find_fast(cpu, last_tb, tb_exit);
> Maybe a comment here for those that missed the subtly in the commit
> message?
>
> /* cpu_loop_exec_tb updates a to a new last_tb */
>
>> > cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
> You could even make it explicit and change cpu_loop_exec_tb to return
> last_tb instead of passing by reference. Then it would be even clearer
> when reading the code.
>
I gave it a quick shot and it's not that simple... One simpler possibility
is to take this patch one step further and merge "tb" and "last_tb", but
I've not tested it yet:
diff --git a/cpu-exec.c b/cpu-exec.c
index cf511f1..80e6ff5 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -515,11 +515,11 @@ static inline void cpu_handle_interrupt(CPUState *cpu,
}
}
-static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
- TranslationBlock **last_tb, int *tb_exit,
- SyncClocks *sc)
+static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock **last_tb,
+ int *tb_exit, SyncClocks *sc)
{
uintptr_t ret;
+ TranslationBlock *tb = *last_tb;
if (unlikely(cpu->exit_request)) {
return;
@@ -609,7 +609,7 @@ int cpu_exec(CPUState *cpu)
for(;;) {
/* prepare setjmp context for exception handling */
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
- TranslationBlock *tb, *last_tb = NULL;
+ TranslationBlock *tb = NULL;
int tb_exit = 0;
/* if an exception is pending, we execute it here */
@@ -619,9 +619,9 @@ int cpu_exec(CPUState *cpu)
cpu->tb_flushed = false; /* reset before first TB lookup */
for(;;) {
- cpu_handle_interrupt(cpu, &last_tb);
- tb = tb_find_fast(cpu, last_tb, tb_exit);
- cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
+ cpu_handle_interrupt(cpu, &tb);
+ tb = tb_find_fast(cpu, tb, tb_exit);
+ cpu_loop_exec_tb(cpu, &tb, &tb_exit, &sc);
/* Try to align the host and virtual clocks
if the guest is in advance */
align_clocks(&sc, cpu);
It seems better to me to do it as a follow-up step.
Paolo
next prev parent reply other threads:[~2016-09-08 13:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 8:32 [Qemu-devel] [PATCH v5 00/10] Reduce lock contention on TCG hot-path Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 01/10] util/qht: Document memory ordering assumptions Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 02/10] tcg: Pass last_tb by value to tb_find_fast() Paolo Bonzini
2016-09-08 12:44 ` Alex Bennée
2016-09-08 13:28 ` Paolo Bonzini [this message]
2016-07-19 8:32 ` [Qemu-devel] [PATCH 03/10] tcg: Prepare safe tb_jmp_cache lookup out of tb_lock Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 04/10] tcg: Prepare safe access to tb_flushed " Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 05/10] tcg: Prepare TB invalidation for lockless TB lookup Paolo Bonzini
2016-07-19 19:56 ` Sergey Fedorov
2016-07-19 22:27 ` Paolo Bonzini
2016-07-21 8:36 ` Sergey Fedorov
2016-07-21 9:04 ` Paolo Bonzini
2016-07-21 11:25 ` Paolo Bonzini
2016-07-21 17:42 ` Sergey Fedorov
2016-07-19 8:32 ` [Qemu-devel] [PATCH 06/10] tcg: set up tb->page_addr before insertion Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 07/10] tcg: cpu-exec: remove tb_lock from the hot-path Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 08/10] tcg: Avoid bouncing tb_lock between tb_gen_code() and tb_add_jump() Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 09/10] tcg: Merge tb_find_slow() and tb_find_fast() Paolo Bonzini
2016-07-19 8:32 ` [Qemu-devel] [PATCH 10/10] tcg: rename tb_find_physical() Paolo Bonzini
2016-09-08 12:39 ` Alex Bennée
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=5f69179b-c88b-dd6e-e262-1bca6834d2a2@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=serge.fdrv@gmail.com \
--cc=sergey.fedorov@linaro.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).