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~