qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Our use of #include is undisciplined, and what to do ab


From: Richard Henderson
Subject: Re: [Qemu-devel] Our use of #include is undisciplined, and what to do about it
Date: Thu, 17 Mar 2016 13:14:25 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/17/2016 12:21 PM, Paolo Bonzini wrote:
> That however makes you waste a lot of cache on trace_events_dstate
> (commit 585ec72, "trace: track enabled events in a separate array",
> 2016-02-03).

I must say I'm not really convinced by that patch, since I don't see that
there's much locality between the ID's that would be polled.

> Perhaps we get the linker to do compute the id, for example by using a
> separate data section and then use te-&te_first to compute the id...
> Richard, do you have ideas on how to do this in a reasonably portable
> manner?

That works for all of the hosts we care about (ELF and MachO).

All you need is "crt0"/"crtn" files to force to be first and last, placing
symbols in known sections.  Then emit all of the "id"s as symbols in those
sections.

E.g. for an event FOO, generate

bool trace_event_FOO_dstate
  __attribute__((section(".bss.trace_event_dstate")));

TraceEvent trace_event_FOO
  __attribute__((section(".bss.trace_event")));

For portability, you must put the section attribute on the extern declaration
as well, lest the compiler make assumptions about small variables living in
".sbss" or the like, and thus being addressable with gp-relative offsets.

See gcc's crtstuff.c for examples of how to write the crt files.
Or, if you value your sanity, don't.  ;-)


r~



reply via email to

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