Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic...
authorIngo Molnar <mingo@elte.hu>
Wed, 26 Aug 2009 06:29:02 +0000 (08:29 +0200)
committerIngo Molnar <mingo@elte.hu>
Wed, 26 Aug 2009 06:29:02 +0000 (08:29 +0200)
Conflicts:
include/linux/tracepoint.h

Signed-off-by: Ingo Molnar <mingo@elte.hu>
1  2 
include/linux/tracepoint.h
include/trace/define_trace.h
include/trace/ftrace.h
kernel/trace/trace_syscalls.c

@@@ -23,6 -23,8 +23,8 @@@ struct tracepoint
  struct tracepoint {
        const char *name;               /* Tracepoint name */
        int state;                      /* State. */
+       void (*regfunc)(void);
+       void (*unregfunc)(void);
        void **funcs;
  } __attribute__((aligned(32)));               /*
                                         * Aligned on 32 bytes because it is
   * Make sure the alignment of the structure in the __tracepoints section will
   * not add unwanted padding between the beginning of the section and the
   * structure. Force alignment to the same alignment as the section start.
-  * An optional set of (un)registration functions can be passed to perform any
-  * additional (un)registration work.
   */
- #define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)    \
+ #define DECLARE_TRACE(name, proto, args)                              \
        extern struct tracepoint __tracepoint_##name;                   \
        static inline void trace_##name(proto)                          \
        {                                                               \
        }                                                               \
        static inline int register_trace_##name(void (*probe)(proto))   \
        {                                                               \
-               int ret;                                                \
-               void (*func)(void) = reg;                               \
-                                                                       \
-               ret = tracepoint_probe_register(#name, (void *)probe);  \
-               if (func && !ret)                                       \
-                       func();                                         \
-               return ret;                                             \
+               return tracepoint_probe_register(#name, (void *)probe); \
        }                                                               \
        static inline int unregister_trace_##name(void (*probe)(proto)) \
        {                                                               \
-               int ret;                                                \
-               void (*func)(void) = unreg;                             \
-                                                                       \
-               ret = tracepoint_probe_unregister(#name, (void *)probe);\
-               if (func && !ret)                                       \
-                       func();                                         \
-               return ret;                                             \
+               return tracepoint_probe_unregister(#name, (void *)probe);\
        }
  
  
- #define DECLARE_TRACE(name, proto, args)                               \
-       DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-                                       NULL, NULL);
- #define DEFINE_TRACE(name)                                            \
+ #define DEFINE_TRACE_FN(name, reg, unreg)                             \
        static const char __tpstrtab_##name[]                           \
        __attribute__((section("__tracepoints_strings"))) = #name;      \
        struct tracepoint __tracepoint_##name                           \
        __attribute__((section("__tracepoints"), aligned(32))) =        \
-               { __tpstrtab_##name, 0, NULL }
+               { __tpstrtab_##name, 0, reg, unreg, NULL }
+ #define DEFINE_TRACE(name)                                            \
+       DEFINE_TRACE_FN(name, NULL, NULL);
  
  #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)                            \
        EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@@ -113,7 -100,7 +100,7 @@@ extern void tracepoint_update_probe_ran
        struct tracepoint *end);
  
  #else /* !CONFIG_TRACEPOINTS */
- #define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)    \
+ #define DECLARE_TRACE(name, proto, args)                              \
        static inline void _do_trace_##name(struct tracepoint *tp, proto) \
        { }                                                             \
        static inline void trace_##name(proto)                          \
                return -ENOSYS;                                         \
        }
  
- #define DECLARE_TRACE(name, proto, args)                               \
-       DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-                                       NULL, NULL);
+ #define DEFINE_TRACE_FN(name, reg, unreg)
  #define DEFINE_TRACE(name)
  #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
  #define EXPORT_TRACEPOINT_SYMBOL(name)
@@@ -181,15 -165,6 +165,15 @@@ static inline void tracepoint_synchroni
  
  #define PARAMS(args...) args
  
 +#endif /* _LINUX_TRACEPOINT_H */
 +
 +/*
 + * Note: we keep the TRACE_EVENT outside the include file ifdef protection.
 + *  This is due to the way trace events work. If a file includes two
 + *  trace event headers under one "CREATE_TRACE_POINTS" the first include
 + *  will override the TRACE_EVENT and break the second include.
 + */
 +
  #ifndef TRACE_EVENT
  /*
   * For use with the TRACE_EVENT macro:
   * can also by used by generic instrumentation like SystemTap), and
   * it is also used to expose a structured trace record in
   * /sys/kernel/debug/tracing/events/.
+  *
+  * A set of (un)registration functions can be passed to the variant
+  * TRACE_EVENT_FN to perform any (un)registration work.
   */
  
  #define TRACE_EVENT(name, proto, args, struct, assign, print) \
        DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 -#endif
+ #define TRACE_EVENT_FN(name, proto, args, struct,             \
+               assign, print, reg, unreg)                      \
+       DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
  
 -#endif
 +#endif /* ifdef TRACE_EVENT (see note above) */
  #define TRACE_EVENT(name, proto, args, tstruct, assign, print)        \
        DEFINE_TRACE(name)
  
+ #undef TRACE_EVENT_FN
+ #define TRACE_EVENT_FN(name, proto, args, tstruct,            \
+               assign, print, reg, unreg)                      \
+       DEFINE_TRACE_FN(name, reg, unreg)
  #undef DECLARE_TRACE
  #define DECLARE_TRACE(name, proto, args)      \
        DEFINE_TRACE(name)
@@@ -56,7 -61,6 +61,7 @@@
  #include <trace/ftrace.h>
  #endif
  
 +#undef TRACE_EVENT
  #undef TRACE_HEADER_MULTI_READ
  
  /* Only undef what we defined in this file */
diff --combined include/trace/ftrace.h
@@@ -21,9 -21,6 +21,9 @@@
  #undef __field
  #define __field(type, item)           type    item;
  
 +#undef __field_ext
 +#define __field_ext(type, item, filter_type)  type    item;
 +
  #undef __array
  #define __array(type, item, len)      type    item[len];
  
        };                                                      \
        static struct ftrace_event_call event_##name
  
+ /* Callbacks are meaningless to ftrace. */
+ #undef TRACE_EVENT_FN
+ #define TRACE_EVENT_FN(name, proto, args, tstruct,            \
+               assign, print, reg, unreg)                      \
+       TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),       \
+               TP_STRUCT__entry(tstruct),                      \
+               TP_fast_assign(assign),                         \
+               TP_printk(print))
  #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  
  
   */
  
  #undef __field
 -#define __field(type, item);
 +#define __field(type, item)
 +
 +#undef __field_ext
 +#define __field_ext(type, item, filter_type)
  
  #undef __array
  #define __array(type, item, len)
        if (!ret)                                                       \
                return 0;
  
 +#undef __field_ext
 +#define __field_ext(type, item, filter_type)  __field(type, item)
 +
  #undef __array
  #define __array(type, item, len)                                              \
        ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t"    \
@@@ -274,33 -274,28 +283,33 @@@ ftrace_raw_output_##call(struct trace_i
        
  #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  
 -#undef __field
 -#define __field(type, item)                                           \
 +#undef __field_ext
 +#define __field_ext(type, item, filter_type)                          \
        ret = trace_define_field(event_call, #type, #item,              \
                                 offsetof(typeof(field), item),         \
 -                               sizeof(field.item), is_signed_type(type));     \
 +                               sizeof(field.item),                    \
 +                               is_signed_type(type), filter_type);    \
        if (ret)                                                        \
                return ret;
  
 +#undef __field
 +#define __field(type, item)   __field_ext(type, item, FILTER_OTHER)
 +
  #undef __array
  #define __array(type, item, len)                                      \
        BUILD_BUG_ON(len > MAX_FILTER_STR_VAL);                         \
        ret = trace_define_field(event_call, #type "[" #len "]", #item, \
                                 offsetof(typeof(field), item),         \
 -                               sizeof(field.item), 0);                \
 +                               sizeof(field.item), 0, FILTER_OTHER);  \
        if (ret)                                                        \
                return ret;
  
  #undef __dynamic_array
  #define __dynamic_array(type, item, len)                                     \
        ret = trace_define_field(event_call, "__data_loc " #type "[]", #item,  \
 -                              offsetof(typeof(field), __data_loc_##item),    \
 -                               sizeof(field.__data_loc_##item), 0);
 +                               offsetof(typeof(field), __data_loc_##item),   \
 +                               sizeof(field.__data_loc_##item), 0,           \
 +                               FILTER_OTHER);
  
  #undef __string
  #define __string(item, src) __dynamic_array(char, item, -1)
@@@ -334,9 -329,6 +343,9 @@@ ftrace_define_fields_##call(struct ftra
  #undef __field
  #define __field(type, item)
  
 +#undef __field_ext
 +#define __field_ext(type, item, filter_type)
 +
  #undef __array
  #define __array(type, item, len)
  
@@@ -1,4 -1,5 +1,5 @@@
  #include <trace/syscall.h>
+ #include <trace/events/syscalls.h>
  #include <linux/kernel.h>
  #include <linux/ftrace.h>
  #include <linux/perf_counter.h>
@@@ -194,8 -195,7 +195,8 @@@ int syscall_enter_define_fields(struct 
        for (i = 0; i < meta->nb_args; i++) {
                ret = trace_define_field(call, meta->types[i],
                                         meta->args[i], offset,
 -                                       sizeof(unsigned long), 0);
 +                                       sizeof(unsigned long), 0,
 +                                       FILTER_OTHER);
                offset += sizeof(unsigned long);
        }
  
@@@ -211,8 -211,7 +212,8 @@@ int syscall_exit_define_fields(struct f
        if (ret)
                return ret;
  
 -      ret = trace_define_field(call, SYSCALL_FIELD(unsigned long, ret), 0);
 +      ret = trace_define_field(call, SYSCALL_FIELD(unsigned long, ret), 0,
 +                               FILTER_OTHER);
  
        return ret;
  }
@@@ -288,7 -287,7 +289,7 @@@ int reg_event_syscall_enter(void *ptr
                return -ENOSYS;
        mutex_lock(&syscall_trace_lock);
        if (!sys_refcount_enter)
-               ret = register_trace_syscall_enter(ftrace_syscall_enter);
+               ret = register_trace_sys_enter(ftrace_syscall_enter);
        if (ret) {
                pr_info("event trace: Could not activate"
                                "syscall entry trace point");
@@@ -313,7 -312,7 +314,7 @@@ void unreg_event_syscall_enter(void *pt
        sys_refcount_enter--;
        clear_bit(num, enabled_enter_syscalls);
        if (!sys_refcount_enter)
-               unregister_trace_syscall_enter(ftrace_syscall_enter);
+               unregister_trace_sys_enter(ftrace_syscall_enter);
        mutex_unlock(&syscall_trace_lock);
  }
  
@@@ -329,7 -328,7 +330,7 @@@ int reg_event_syscall_exit(void *ptr
                return -ENOSYS;
        mutex_lock(&syscall_trace_lock);
        if (!sys_refcount_exit)
-               ret = register_trace_syscall_exit(ftrace_syscall_exit);
+               ret = register_trace_sys_exit(ftrace_syscall_exit);
        if (ret) {
                pr_info("event trace: Could not activate"
                                "syscall exit trace point");
@@@ -354,7 -353,7 +355,7 @@@ void unreg_event_syscall_exit(void *ptr
        sys_refcount_exit--;
        clear_bit(num, enabled_exit_syscalls);
        if (!sys_refcount_exit)
-               unregister_trace_syscall_exit(ftrace_syscall_exit);
+               unregister_trace_sys_exit(ftrace_syscall_exit);
        mutex_unlock(&syscall_trace_lock);
  }
  
@@@ -420,7 -419,7 +421,7 @@@ int reg_prof_syscall_enter(char *name
  
        mutex_lock(&syscall_trace_lock);
        if (!sys_prof_refcount_enter)
-               ret = register_trace_syscall_enter(prof_syscall_enter);
+               ret = register_trace_sys_enter(prof_syscall_enter);
        if (ret) {
                pr_info("event trace: Could not activate"
                                "syscall entry trace point");
@@@ -444,7 -443,7 +445,7 @@@ void unreg_prof_syscall_enter(char *nam
        sys_prof_refcount_enter--;
        clear_bit(num, enabled_prof_enter_syscalls);
        if (!sys_prof_refcount_enter)
-               unregister_trace_syscall_enter(prof_syscall_enter);
+               unregister_trace_sys_enter(prof_syscall_enter);
        mutex_unlock(&syscall_trace_lock);
  }
  
@@@ -481,7 -480,7 +482,7 @@@ int reg_prof_syscall_exit(char *name
  
        mutex_lock(&syscall_trace_lock);
        if (!sys_prof_refcount_exit)
-               ret = register_trace_syscall_exit(prof_syscall_exit);
+               ret = register_trace_sys_exit(prof_syscall_exit);
        if (ret) {
                pr_info("event trace: Could not activate"
                                "syscall entry trace point");
@@@ -505,7 -504,7 +506,7 @@@ void unreg_prof_syscall_exit(char *name
        sys_prof_refcount_exit--;
        clear_bit(num, enabled_prof_exit_syscalls);
        if (!sys_prof_refcount_exit)
-               unregister_trace_syscall_exit(prof_syscall_exit);
+               unregister_trace_sys_exit(prof_syscall_exit);
        mutex_unlock(&syscall_trace_lock);
  }