qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 20:13:18 +0100	[thread overview]
Message-ID: <e7b70933-acd1-668c-62cd-89f480945f0f@redhat.com> (raw)
In-Reply-To: <20201118173055.GM1509407@habkost.net>

On 18/11/20 18:30, Eduardo Habkost wrote:
>> Adding a layer of indirect calls is not very different from monkey patching
>> though.
> 
> I'm a little bothered by monkey patching, but I'm more
> bothered by having to:
> 
> (1) register (module_init()) a function (kvm_cpu_accel_register()) that
>    (2) register (accel_register_call()) a function (kvm_cpu_accel_init()) that
>      (3) register (x86_cpu_accel_init()) a data structure (X86CPUAccel kvm_cpu_accel) that
>        (4) will be saved in multiple QOM classes, so that
>          (5) we will call the right X86CPUClass.accel method at the right moment
>              (common_class_init(), instance_init(), realizefn()),
> where:
>    step 4 must be done before any CPU object is created
>      (otherwise X86CPUAccel.instance_init & X86CPUAccel.realizefn
>       will be silently ignored), and
>    step 3 must be done after all QOM types were registered.
> 
>> You also have to consider that accel currently does not exist in usermode
>> emulators, so that's an issue too. I would rather get a simple change in
>> quickly, instead of designing the perfect class hierarchy.
> 
> It doesn't have to be perfect.  I agree that simple is better.
> 
> To me, registering a QOM type and looking it up when necessary is
> simpler than the above.  Even if it's a weird class having no
> object instances.  It probably could be an interface type.

Registering a QOM type still has quite some boilerplate.  Also 
registering a QOM type has a public side effect (shows up in 
qom-list-types).  In general I don't look at QOM unless I want its 
property mechanism, but maybe that's just me.

>> Perhaps another idea would be to allow adding interfaces to classes
>> *separately from the registration of the types*. Then we can use it to add
>> SOFTMMU_ACCEL and I386_ACCEL interfaces to a bare bones accel class, and
>> add the accel object to usermode emulators.
> 
> I'm not sure I follow.  What do you mean by bare bones accel
> class, and when exactly would you add the new interfaces to the
> classes?

A bare bones accel class would not have init_machine and setup_post 
methods; those would be in a TYPE_SOFTMMU_ACCEL interface.  It would 
still have properties (such as tb-size for TCG) and would be able to 
register compat properties.

Where would I add it, I don't know.  It could be a simple public wrapper 
around type_initialize_interface() if we add a new MODULE_INIT_* phase 
after QOM.

Or without adding a new phase, it could be a class_type->array of 
(interface_type, init_fn) hash table.  type_initialize would look up the 
class_type by name, add the interfaces would to the class with 
type_initialize_interface, and then call the init_fn to fill in the vtable.

Paolo



  reply	other threads:[~2020-11-18 19:16 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
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 [this message]
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=e7b70933-acd1-668c-62cd-89f480945f0f@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).