[lkml]   [2011]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[RFC patch 00/32] TRACE_EVENT: cleanup for code-size reduction (v2)

I implemented the TRACE_EVENT macros as arrays of fields and arrays of
events in LTTng, and realised that it could benefit Ftrace too by
cutting down its code size. As I know that code size footprint is an
issue Steven has been wanting to tackle for a while, I am sending this
"semicolon removal" patchset, which is a prerequisite to be able to
generate arrays of events.

* Changelog since v1
- Removed all ifdefs around declarations (it is now _only_ a semicolon
removal patchset).

The main difference between the approaches Ftrace and LTTng have taken
is that Ftrace creates a "ftrace_define_fields_##call" function for each
event which calls trace_define_field for each field of each event. In
LTTng, I did the following (code snippet from [1]):

struct lttng_event_field {
const char *name;
const struct lttng_type type;
struct lttng_event_desc {
const struct lttng_event_field *fields;
const char *name;
unsigned int nr_fields;
#define DEFINE_EVENT(_template, _name, _proto, _args) \
{ \
.fields = __event_fields___##_template, \
.name = #_name, \
.nr_fields = ARRAY_SIZE(__event_fields___##_template), \
#define TP_ID1(_token, _system) _token##_system
#define TP_ID(_token, _system) TP_ID1(_token, _system)

static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
And for creation of __event_fields___##_template, which allows to keep
all fields in another array (which should be defined in a phase prior to
the event array definition), I did:

#undef __field
#define __field(_type, _item) \
{ .name = #_item, .type = { .atype = atype_integer, .name = #_type} },
(similar for __field_ext, __array, __dynamic_array, __string)

#undef TP_STRUCT__entry
#define TP_STRUCT__entry(args...) args /* Only one used in this phase */
#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
static const struct lttng_event_field __event_fields___##_name[] = { \
_tstruct \
For the declaration of struct lttng_type, which contains the field type
information in a union, see [2].

Best regards,



Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.

 \ /
  Last update: 2011-05-04 01:23    [W:0.219 / U:7.520 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site