qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-ppc] [Qemu-devel] [PULL 20/21] Revert use of DEFINE_MACHINE()


From: Eduardo Habkost
Subject: Re: [Qemu-ppc] [Qemu-devel] [PULL 20/21] Revert use of DEFINE_MACHINE() for registrations of multiple machines
Date: Mon, 21 Sep 2015 14:57:30 -0300
User-agent: Mutt/1.5.23 (2014-03-12)

On Mon, Sep 21, 2015 at 02:24:51PM -0300, Eduardo Habkost wrote:
> On Mon, Sep 21, 2015 at 05:52:47PM +0200, Andreas Färber wrote:
> > Am 21.09.2015 um 17:49 schrieb Eduardo Habkost:
> > > On Sat, Sep 19, 2015 at 04:43:29PM +0200, Andreas Färber wrote:
> > >> The script used for converting from QEMUMachine had used one
> > >> DEFINE_MACHINE() per machine registered. In cases where multiple
> > >> machines are registered from one source file, avoid the excessive
> > >> generation of module init functions by reverting this unrolling.
> > > 
> > > Why is that a problem?
> > 
> > It's unnecessary code bloat and it blocks the usual QOM patterns. See
> > the follow-up series for an example where an abstract base type helps,
> > which your macro does not allow.
> 
> Do you have any numbers on the actual bloat impact?

This is what I see on x86_64:

$ readelf -W -s before/qemu-system-arm | grep smdkc210
  2675: 00000000001422b0    12 FUNC    LOCAL  DEFAULT   13 
exynos4_machine_smdkc210_machine_init_register_types
  2676: 00000000007051c0   104 OBJECT  LOCAL  DEFAULT   23 
exynos4_machine_smdkc210_machine_init_typeinfo
  2680: 0000000000142310    72 FUNC    LOCAL  DEFAULT   13 
exynos4_machine_smdkc210_machine_init_class_init
  2682: 00000000001424b0   264 FUNC    LOCAL  DEFAULT   13 smdkc210_init
  2693: 00000000000a4d50    17 FUNC    LOCAL  DEFAULT   13 
do_qemu_init_exynos4_machine_smdkc210_machine_init_register_types

$ readelf -W -s after/qemu-system-arm | grep smdkc210
  2675: 00000000007041c0   104 OBJECT  LOCAL  DEFAULT   23 smdkc210_type
  2676: 0000000000141ff0    72 FUNC    LOCAL  DEFAULT   13 smdkc210_class_init
  2678: 00000000001421e0   264 FUNC    LOCAL  DEFAULT   13 smdkc210_init

An additional type_register_static() call inside an existing type_init()
function adds 16 bytes to the function.

An additional type_init() functions adds 29 bytes:
* 12 bytes for the the function calling type_register_static()
* 17 bytes for the do_qemu_init_*() function

So, you are saving 13 bytes for each machine class.

For comparison on the existing per-machine-class bloat, each new machine class
already adds at least:
* 104 bytes for the TypeInfo object
* 240 bytes for each MachineClass struct allocated at runtime when
  find_machine() runs object_class_get_list()
* A variable number of bytes for strings, class_init and other machine
  code (336 bytes for class_init and instance_init, in the smdkc210
  case)

I would happily add extra 13 bytes for each machine class if it means simpler
code.

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]