]> Pileus Git - ~andy/linux/blobdiff - include/trace/ftrace.h
tracing: Fix array size mismatch in format string
[~andy/linux] / include / trace / ftrace.h
index 5c38606613d89a06c361a56054e97031c391c2d3..1ee19a24cc5f7170a3dab525767c669f3773dc7e 100644 (file)
@@ -310,15 +310,12 @@ static struct trace_event_functions ftrace_event_type_funcs_##call = {    \
 #undef __array
 #define __array(type, item, len)                                       \
        do {                                                            \
-               mutex_lock(&event_storage_mutex);                       \
+               char *type_str = #type"["__stringify(len)"]";           \
                BUILD_BUG_ON(len > MAX_FILTER_STR_VAL);                 \
-               snprintf(event_storage, sizeof(event_storage),          \
-                        "%s[%d]", #type, len);                         \
-               ret = trace_define_field(event_call, event_storage, #item, \
+               ret = trace_define_field(event_call, type_str, #item,   \
                                 offsetof(typeof(field), item),         \
                                 sizeof(field.item),                    \
                                 is_signed_type(type), FILTER_OTHER);   \
-               mutex_unlock(&event_storage_mutex);                     \
                if (ret)                                                \
                        return ret;                                     \
        } while (0);
@@ -418,6 +415,8 @@ static inline notrace int ftrace_get_offsets_##call(                        \
  *     struct ftrace_event_file *ftrace_file = __data;
  *     struct ftrace_event_call *event_call = ftrace_file->event_call;
  *     struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
+ *     unsigned long eflags = ftrace_file->flags;
+ *     enum event_trigger_type __tt = ETT_NONE;
  *     struct ring_buffer_event *event;
  *     struct ftrace_raw_<call> *entry; <-- defined in stage 1
  *     struct ring_buffer *buffer;
@@ -425,9 +424,12 @@ static inline notrace int ftrace_get_offsets_##call(                       \
  *     int __data_size;
  *     int pc;
  *
- *     if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
- *                  &ftrace_file->flags))
- *             return;
+ *     if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
+ *             if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
+ *                     event_triggers_call(ftrace_file, NULL);
+ *             if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
+ *                     return;
+ *     }
  *
  *     local_save_flags(irq_flags);
  *     pc = preempt_count();
@@ -445,8 +447,17 @@ static inline notrace int ftrace_get_offsets_##call(                       \
  *     { <assign>; }  <-- Here we assign the entries by the __field and
  *                        __array macros.
  *
- *     if (!filter_check_discard(ftrace_file, entry, buffer, event))
+ *     if (eflags & FTRACE_EVENT_FL_TRIGGER_COND)
+ *             __tt = event_triggers_call(ftrace_file, entry);
+ *
+ *     if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
+ *                  &ftrace_file->flags))
+ *             ring_buffer_discard_commit(buffer, event);
+ *     else if (!filter_check_discard(ftrace_file, entry, buffer, event))
  *             trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
+ *
+ *     if (__tt)
+ *             event_triggers_post_call(ftrace_file, __tt);
  * }
  *
  * static struct trace_event ftrace_event_type_<call> = {
@@ -539,8 +550,7 @@ ftrace_raw_event_##call(void *__data, proto)                                \
        int __data_size;                                                \
        int pc;                                                         \
                                                                        \
-       if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,                 \
-                    &ftrace_file->flags))                              \
+       if (ftrace_trigger_soft_disabled(ftrace_file))                  \
                return;                                                 \
                                                                        \
        local_save_flags(irq_flags);                                    \
@@ -560,8 +570,8 @@ ftrace_raw_event_##call(void *__data, proto)                                \
                                                                        \
        { assign; }                                                     \
                                                                        \
-       if (!filter_check_discard(ftrace_file, entry, buffer, event))   \
-               trace_buffer_unlock_commit(buffer, event, irq_flags, pc); \
+       event_trigger_unlock_commit(ftrace_file, buffer, event, entry, \
+                                   irq_flags, pc);                    \
 }
 /*
  * The ftrace_test_probe is compiled out, it is only here as a build time check