From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758383Ab1EBWEL (ORCPT ); Mon, 2 May 2011 18:04:11 -0400 Received: from smtp.polymtl.ca ([132.207.4.11]:40560 "EHLO smtp.polymtl.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757232Ab1EBWEK (ORCPT ); Mon, 2 May 2011 18:04:10 -0400 Message-Id: <20110502211123.163877033@efficios.com> User-Agent: quilt/0.48-1 Date: Mon, 02 May 2011 17:11:23 -0400 From: Mathieu Desnoyers To: LKML , Steven Rostedt Cc: Ingo Molnar , Thomas Gleixner , Frederic Weisbecker Subject: [RFC patch 00/32] TRACE_EVENT: cleanup for code-size reduction X-Poly-FromMTA: (test.dorsal.polymtl.ca [132.207.72.60]) at Mon, 2 May 2011 21:32:11 +0000 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com