From: Paolo Bonzini <pbonzini@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Laurent Vivier" <lvivier@redhat.com>,
"Bruce Rogers" <brogers@suse.com>,
"Thomas Huth" <thuth@redhat.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Paul Durrant" <paul@xen.org>, "Olaf Hering" <ohering@suse.de>,
"Jason Wang" <jasowang@redhat.com>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
qemu-devel@nongnu.org, "Peter Xu" <peterx@redhat.com>,
"Dario Faggioli" <dfaggioli@suse.com>,
"Roman Bolshakov" <r.bolshakov@yadro.com>,
"Cameron Esfahani" <dirty@apple.com>,
"Colin Xu" <colin.xu@intel.com>,
"Wenchao Wang" <wenchao.wang@intel.com>,
"Anthony Perard" <anthony.perard@citrix.com>,
haxm-team@intel.com, "Sunil Muthuswamy" <sunilmut@microsoft.com>,
"Richard Henderson" <rth@twiddle.net>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Claudio Fontana" <cfontana@suse.de>
Subject: Re: [RFC v3 8/9] module: introduce MODULE_INIT_ACCEL_CPU
Date: Wed, 18 Nov 2020 15:51:44 +0100 [thread overview]
Message-ID: <a6071cd4-0787-01c8-775a-ede72e740376@redhat.com> (raw)
In-Reply-To: <20201118143643.GF1509407@habkost.net>
On 18/11/20 15:36, Eduardo Habkost wrote:
> On Wed, Nov 18, 2020 at 03:05:42PM +0100, Paolo Bonzini wrote:
>> On 18/11/20 14:48, Claudio Fontana wrote:
>>> On 11/18/20 1:48 PM, Eduardo Habkost wrote:
>>>> I don't get why we would use a new module initialization level
>>>
>>> To have a clear point in time after which all accelerator interface initialization is done.
>>> It avoids to have to hunt down the registration points spread around the code base.
>>> I'd turn it around, why not?
>>
>> I see two disadvantages:
>>
>> 1) you have to hunt down accel_cpu_inits instead of looking at accelerator
>> classes. :)
>>
>> 2) all callbacks have an "if (*_enabled())" around the actual meat. Another
>> related issue is that usually the module_call_init are unconditional.
>>
>> I think the idea of using module_call_init is good however. What about:
>>
>> static void kvm_cpu_accel_init(void)
>> {
>> x86_cpu_accel_init(&kvm_cpu_accel);
>
> What do you expect x86_cpu_accel_init() to do?
I don't know, the same that it was doing in Claudio's patches. :)
He had
if (kvm_enabled()) {
x86_cpu_accel_init(&kvm_cpu_accel);
}
and I'm calling only the function that is registered on the enabled
accelerator.
> I don't understand why a separate module init level is necessary
> here.
Because you must call accel_register_call after the TYPE_KVM type has
been registered, or object_class_by_name fails:
void
accel_register_call(const char *qom_type, void (*fn)(void))
{
AccelClass *acc = ACCEL_CLASS(object_class_by_name(qom_type));
acc->setup_calls = g_slist_append(acc->setup_calls, (void *)fn);
}
The alternative is to store the (type, function) tuple directly, with
the type as a string. Then you can just use type_init.
> Making sure module_call_init() is called at the correct moment is
> not easier or safer than just making sure accel_init_machine()
> (or another init function you create) is called at the correct
> moment.
Since there is a way to do it without a new level, that would of course
be fine for me too. Let me explain however why I think Claudio's design
had module_call_init() misplaced and what the fundamental difference is.
The basic phases in qemu_init() are:
- initialize stuff
- parse command line
- create machine
- create accelerator
- initialize machine
- create devices
- start
with a mess of other object creation sprinkled between the various
phases (but we don't care about those).
What I object to, is calling module_call_init() after the "initialize
stuff" phase. Claudio was using it to call the function directly, so it
had to be exactly at "create accelerator". This is different from all
other module_call_init() calls, which are done very early.
With the implementation I sketched, accel_register_call must still be
done after type_init, so there's still an ordering constraint, but all
it's doing is registering a callback in the "initialize stuff" phase.
Thanks,
Paolo
next prev parent reply other threads:[~2020-11-18 14:52 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 10:29 [RFC v3 0/9] i386 cleanup Claudio Fontana
2020-11-18 10:29 ` [RFC v3 1/9] i386: move kvm accel files into kvm/ Claudio Fontana
2020-11-18 10:29 ` [RFC v3 2/9] i386: move whpx accel files into whpx/ Claudio Fontana
2020-11-18 10:29 ` [RFC v3 3/9] i386: move hax accel files into hax/ Claudio Fontana
2020-11-18 10:29 ` [RFC v3 4/9] i386: hvf: remove stale MAINTAINERS entry for old hvf stubs Claudio Fontana
2020-11-18 16:09 ` Roman Bolshakov
2020-11-18 10:29 ` [RFC v3 5/9] i386: move TCG accel files into tcg/ Claudio Fontana
2020-11-18 10:29 ` [RFC v3 6/9] i386: move cpu dump out of helper.c into cpu-dump.c Claudio Fontana
2020-11-18 10:29 ` [RFC v3 7/9] i386: move TCG cpu class initialization out of helper.c Claudio Fontana
2020-11-18 10:29 ` [RFC v3 8/9] module: introduce MODULE_INIT_ACCEL_CPU Claudio Fontana
2020-11-18 12:38 ` Claudio Fontana
2020-11-18 12:48 ` Eduardo Habkost
2020-11-18 13:48 ` Claudio Fontana
2020-11-18 14:05 ` Paolo Bonzini
2020-11-18 14:36 ` Eduardo Habkost
2020-11-18 14:51 ` Paolo Bonzini [this message]
2020-11-18 15:25 ` Eduardo Habkost
2020-11-18 15:43 ` Paolo Bonzini
2020-11-18 16:11 ` Eduardo Habkost
2020-11-18 16:22 ` Paolo Bonzini
2020-11-18 17:30 ` Eduardo Habkost
2020-11-18 19:13 ` Paolo Bonzini
2020-11-18 22:07 ` Eduardo Habkost
2020-11-20 12:13 ` Claudio Fontana
2020-11-20 17:19 ` Eduardo Habkost
2020-11-20 17:41 ` Claudio Fontana
2020-11-20 18:09 ` Eduardo Habkost
2020-11-23 9:29 ` Claudio Fontana
2020-11-23 9:55 ` Claudio Fontana
2020-11-23 13:18 ` Paolo Bonzini
2020-11-23 15:02 ` Claudio Fontana
2020-11-23 15:14 ` Paolo Bonzini
2020-11-23 18:20 ` Eduardo Habkost
2020-11-18 10:29 ` [RFC v3 9/9] i386: split cpu accelerators from cpu.c Claudio Fontana
2020-11-18 18:28 ` Eduardo Habkost
2020-11-19 8:53 ` Claudio Fontana
2020-11-19 19:23 ` Eduardo Habkost
2020-11-20 9:08 ` Claudio Fontana
2020-11-23 18:24 ` Eduardo Habkost
2020-11-23 18:34 ` Claudio Fontana
2020-11-18 11:00 ` [RFC v3 0/9] i386 cleanup no-reply
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=a6071cd4-0787-01c8-775a-ede72e740376@redhat.com \
--to=pbonzini@redhat.com \
--cc=anthony.perard@citrix.com \
--cc=brogers@suse.com \
--cc=cfontana@suse.de \
--cc=colin.xu@intel.com \
--cc=dfaggioli@suse.com \
--cc=dirty@apple.com \
--cc=ehabkost@redhat.com \
--cc=haxm-team@intel.com \
--cc=jasowang@redhat.com \
--cc=lvivier@redhat.com \
--cc=mtosatti@redhat.com \
--cc=ohering@suse.de \
--cc=paul@xen.org \
--cc=peterx@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
--cc=rth@twiddle.net \
--cc=sstabellini@kernel.org \
--cc=sunilmut@microsoft.com \
--cc=thuth@redhat.com \
--cc=wenchao.wang@intel.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).