Skip to content

RFC TRACE_EVENT: cleanup for code-size reduction (v2)

Mathieu Desnoyers lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest32 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/32TRACE_EVENT: gradual semicolon removalinclude/linux/tracepoint.h include/trace/ftrace.h+7 -70 replies
2/32trace event sample remove semicolonssamples/trace_events/trace-events-sample.h+1 -10 replies
3/32trace event block remove semicolonsinclude/trace/events/block.h+22 -220 replies
4/32trace event ext4 remove semicolonsinclude/trace/events/ext4.h+69 -690 replies
5/32trace event irq remove semicolonsinclude/trace/events/irq.h+6 -60 replies
6/32trace event jbd2 remove semicolonsinclude/trace/events/jbd2.h+11 -110 replies
7/32trace event kmem remove semicolonsinclude/trace/events/kmem.h+16 -160 replies
8/32trace event kvm remove semicolonsarch/powerpc/kvm/trace.h arch/x86/kvm/mmutrace.h arch/x86/kvm/trace.h +1 more+63 -630 replies
9/32trace event lock remove semicolonsinclude/trace/events/lock.h+5 -50 replies
10/32trace event mce remove semicolonsinclude/trace/events/mce.h+1 -10 replies
11/32trace event module remove semicolonsinclude/trace/events/module.h+6 -60 replies
12/32trace event napi remove semicolonsinclude/trace/events/napi.h+1 -10 replies
13/32trace event net remove semicolonsinclude/trace/events/net.h+4 -40 replies
14/32trace event power remove semicolonsinclude/trace/events/power.h+14 -140 replies
15/32trace event sched remove trailing semicoloninclude/trace/events/sched.h+19 -190 replies
16/32trace event scsi remove semicolonsinclude/trace/events/scsi.h+6 -60 replies
17/32trace event signal remove semicolonsinclude/trace/events/signal.h+5 -50 replies
18/32trace event skb remove semicolonsinclude/trace/events/skb.h+3 -30 replies
19/32trace event syscalls remove semicolonsinclude/trace/events/syscalls.h+2 -20 replies
20/32trace event timer remove semicolonsinclude/trace/events/timer.h+14 -140 replies
21/32trace event vmscan remove semicolonsinclude/trace/events/vmscan.h+16 -160 replies
22/32trace event workqueue remove semicolonsinclude/trace/events/workqueue.h+5 -50 replies
23/32trace event writeback remove semicolonsinclude/trace/events/writeback.h+24 -240 replies
24/32trace event wireless remove semicolonsdrivers/net/wireless/iwlwifi/iwl-devtrace.h drivers/net/wireless/iwmc3200wifi/trace.h net/mac80211/driver-trace.h+76 -760 replies
25/32trace event video gpu remove semicolonsdrivers/gpu/drm/drm_trace.h drivers/gpu/drm/i915/i915_trace.h+29 -294 replies
26/32trace event gfs2 remove semicolonsfs/gfs2/trace_gfs2.h+10 -100 replies
27/32trace event xfs remove semicolonsfs/xfs/linux-2.6/xfs_trace.h+267 -2670 replies
28/32trace event powerpc remove semicolonsarch/powerpc/include/asm/trace.h arch/powerpc/platforms/cell/spufs/sputrace.h+7 -70 replies
29/32trace event asoc: semicolon removalinclude/trace/events/asoc.h+17 -170 replies
30/32trace event compaction remove semicolonsinclude/trace/events/compaction.h+4 -40 replies
31/32trace event regulator remove semicolonsinclude/trace/events/regulator.h+10 -101 reply
32/32trace event btrfs remove semicolonsinclude/trace/events/btrfs.h+26 -260 replies

Reviews trailers per patch

10 of 32 patches have a Reviewed-by or Acked-by.

PatchFrederic WeisbeckerNeil HormanJean PihetSteven WhitehouseMark BrownTejun HeoJesse Barnes
1/32A-b
2/32
3/32
4/32
5/32
6/32
7/32
8/32
9/32
10/32
11/32
12/32A-b
13/32A-b
14/32A-b
15/32
16/32
17/32
18/32A-b
19/32
20/32
21/32
22/32A-b
23/32
24/32
25/32R-b R-b
26/32A-b
27/32
28/32
29/32A-b
30/32
31/32A-b
32/32

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v1 thread

Cover letter [RFC patch 00/32] TRACE_EVENT: cleanup for code-size reduction (v2)

Hi,

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;
};
#undef DEFINE_EVENT
#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)[] = { #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
};
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 */ #undef DECLARE_EVENT_CLASS

#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

[1] http://git.lttng.org/?p=lttng-modules.git;a=blob;f=probes/lttng-events.h;h=a05c29d56771b89807ffef035b7cd6df34a0b97f;hb=HEAD
[2] http://git.lttng.org/?p=lttng-modules.git;a=blob;f=probes/lttng-types.h;h=0192bffaf2f321f446f71a13901e2ab09fd69663;hb=HEAD

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com