From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Cc: "WANG Xuerui" <git@xen0n.name>,
"David Hildenbrand" <david@redhat.com>,
"Sergey Fedorov" <serge.fdrv@gmail.com>,
"Peter Xu" <peterx@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Emilio G . Cota" <cota@braap.org>,
"Richard Purdie" <richard.purdie@linuxfoundation.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Anton Johansson" <anjo@rev.ng>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-stable@nongnu.org
Subject: Re: [RFC PATCH] softmmu: Fix async_run_on_cpu() use in tcg_commit_cpu()
Date: Thu, 7 Sep 2023 09:28:48 -0700 [thread overview]
Message-ID: <1d405e13-c98c-d288-2644-ee79bc8c4234@linaro.org> (raw)
In-Reply-To: <20230907161415.6102-1-philmd@linaro.org>
On 9/7/23 09:14, Philippe Mathieu-Daudé wrote:
> CPUState::halt_cond is an accelerator specific pointer, used
> in particular by TCG (which tcg_commit() is about).
> The pointer is set by the AccelOpsClass::create_vcpu_thread()
> handler.
> AccelOpsClass::create_vcpu_thread() is called by the generic
> qemu_init_vcpu(), which expect the accelerator handler to
> eventually call cpu_thread_signal_created() which is protected
> with a QemuCond. It is safer to check the vCPU is created with
> this field rather than the 'halt_cond' pointer set in
> create_vcpu_thread() before the vCPU thread is initialized.
>
> This avoids calling tcg_commit() until all CPUs are realized.
>
> Here we can see for a machine with N CPUs, tcg_commit()
> is called N times before the 'machine_creation_done' event:
>
> (lldb) settings set -- target.run-args "-M" "virt" "-smp" "512" "-display" "none"
> (lldb) breakpoint set --name qemu_machine_creation_done --one-shot true
> (lldb) breakpoint set --name tcg_commit_cpu --auto-continue true
> (lldb) run
> Process 84089 launched: 'qemu-system-aarch64' (arm64)
> Process 84089 stopped
> * thread #1, queue = 'com.apple.main-thread', stop reason = one-shot breakpoint 2
> (lldb) breakpoint list --brief
> Current breakpoints:
> 2: name = 'tcg_commit_cpu', locations = 2, resolved = 2, hit count = 512 Options: enabled auto-continue
> ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
>
Of course the function is called 512 times: you asked for 512 cpus, and each has its own
address space which needs initializing.
If you skip the call before cpu->created, when exactly are you going to do it?
r~
next prev parent reply other threads:[~2023-09-07 16:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 16:14 [RFC PATCH] softmmu: Fix async_run_on_cpu() use in tcg_commit_cpu() Philippe Mathieu-Daudé
2023-09-07 16:28 ` Richard Henderson [this message]
2023-09-07 19:36 ` Philippe Mathieu-Daudé
2023-09-08 10:49 ` Philippe Mathieu-Daudé
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=1d405e13-c98c-d288-2644-ee79bc8c4234@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=anjo@rev.ng \
--cc=cota@braap.org \
--cc=david@redhat.com \
--cc=git@xen0n.name \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.purdie@linuxfoundation.org \
--cc=serge.fdrv@gmail.com \
--cc=stefanha@redhat.com \
/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).