Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169781
b: refs/heads/master
c: ff038f5
h: refs/heads/master
i:
  169779: 0556f61
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Nov 24, 2009
1 parent eede986 commit 0418d77
Show file tree
Hide file tree
Showing 39 changed files with 538 additions and 959 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe6126722718e51fba4879517c11ac12d9775bcc
refs/heads/master: ff038f5c37c2070829004a0678372766c2b32180
4 changes: 2 additions & 2 deletions trunk/arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2229,10 +2229,10 @@ validate_event(struct cpu_hw_events *cpuc, struct perf_event *event)
{
struct hw_perf_event fake_event = event->hw;

if (event->pmu && event->pmu != &pmu)
if (event->pmu != &pmu)
return 0;

return x86_schedule_event(cpuc, &fake_event) >= 0;
return x86_schedule_event(cpuc, &fake_event);
}

static int validate_group(struct perf_event *event)
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/linux/tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ static inline void tracepoint_synchronize_unregister(void)
* TRACE_EVENT_FN to perform any (un)registration work.
*/

#define TRACE_EVENT_TEMPLATE(name, proto, args, tstruct, assign, print)
#define DEFINE_EVENT(template, name, proto, args) \
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))

#define TRACE_EVENT(name, proto, args, struct, assign, print) \
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
#define TRACE_EVENT_FN(name, proto, args, struct, \
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/trace/define_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
assign, print, reg, unreg) \
DEFINE_TRACE_FN(name, reg, unreg)

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
DEFINE_TRACE(name)

#undef DECLARE_TRACE
#define DECLARE_TRACE(name, proto, args) \
DEFINE_TRACE(name)
Expand Down Expand Up @@ -63,6 +67,8 @@

#undef TRACE_EVENT
#undef TRACE_EVENT_FN
#undef TRACE_EVENT_TEMPLATE
#undef DEFINE_EVENT
#undef TRACE_HEADER_MULTI_READ

/* Only undef what we defined in this file */
Expand Down
149 changes: 107 additions & 42 deletions trunk/include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@

#include <linux/ftrace_event.h>

/*
* TRACE_EVENT_TEMPLATE can be used to add a generic function
* handlers for events. That is, if all events have the same
* parameters and just have distinct trace points.
* Each tracepoint can be defined with DEFINE_EVENT and that
* will map the TRACE_EVENT_TEMPLATE to the tracepoint.
*
* TRACE_EVENT is a one to one mapping between tracepoint and template.
*/
#undef TRACE_EVENT
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
TRACE_EVENT_TEMPLATE(name, \
PARAMS(proto), \
PARAMS(args), \
PARAMS(tstruct), \
PARAMS(assign), \
PARAMS(print)); \
DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));


#undef __field
#define __field(type, item) type item;

Expand All @@ -36,13 +56,15 @@
#undef TP_STRUCT__entry
#define TP_STRUCT__entry(args...) args

#undef TRACE_EVENT
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
struct ftrace_raw_##name { \
struct trace_entry ent; \
tstruct \
char __data[0]; \
}; \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(name, proto, args, tstruct, assign, print) \
struct ftrace_raw_##name { \
struct trace_entry ent; \
tstruct \
char __data[0]; \
};
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
static struct ftrace_event_call event_##name

#undef __cpparg
Expand Down Expand Up @@ -89,12 +111,15 @@
#undef __string
#define __string(item, src) __dynamic_array(char, item, -1)

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print) \
struct ftrace_data_offsets_##call { \
tstruct; \
};

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args)

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/*
Expand Down Expand Up @@ -170,8 +195,8 @@
#undef TP_perf_assign
#define TP_perf_assign(args...)

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, func, print) \
static int \
ftrace_format_##call(struct ftrace_event_call *unused, \
struct trace_seq *s) \
Expand All @@ -186,6 +211,9 @@ ftrace_format_##call(struct ftrace_event_call *unused, \
return ret; \
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args)

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/*
Expand Down Expand Up @@ -255,10 +283,11 @@ ftrace_format_##call(struct ftrace_event_call *unused, \
ftrace_print_symbols_seq(p, value, symbols); \
})

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print) \
static enum print_line_t \
ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
ftrace_raw_output_id_##call(int event_id, const char *name, \
struct trace_iterator *iter, int flags) \
{ \
struct trace_seq *s = &iter->seq; \
struct ftrace_raw_##call *field; \
Expand All @@ -268,7 +297,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
\
entry = iter->ent; \
\
if (entry->type != event_##call.id) { \
if (entry->type != event_id) { \
WARN_ON_ONCE(1); \
return TRACE_TYPE_UNHANDLED; \
} \
Expand All @@ -277,14 +306,25 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
\
p = &get_cpu_var(ftrace_event_seq); \
trace_seq_init(p); \
ret = trace_seq_printf(s, #call ": " print); \
ret = trace_seq_printf(s, "%s: ", name); \
if (ret) \
ret = trace_seq_printf(s, print); \
put_cpu(); \
if (!ret) \
return TRACE_TYPE_PARTIAL_LINE; \
\
return TRACE_TYPE_HANDLED; \
}


#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
static enum print_line_t \
ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
{ \
return ftrace_raw_output_id_##template(event_##name.id, \
#name, iter, flags); \
}

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

#undef __field_ext
Expand Down Expand Up @@ -318,8 +358,8 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
#undef __string
#define __string(item, src) __dynamic_array(char, item, -1)

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, func, print) \
static int \
ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
{ \
Expand All @@ -335,6 +375,9 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
return ret; \
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args)

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/*
Expand All @@ -361,10 +404,10 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
__data_size += (len) * sizeof(type);

#undef __string
#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1) \
#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print) \
static inline int ftrace_get_offsets_##call( \
struct ftrace_data_offsets_##call *__data_offsets, proto) \
{ \
Expand All @@ -376,6 +419,9 @@ static inline int ftrace_get_offsets_##call( \
return __data_size; \
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args)

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

#ifdef CONFIG_EVENT_PROFILE
Expand All @@ -397,19 +443,22 @@ static inline int ftrace_get_offsets_##call( \
*
*/

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
\
static void ftrace_profile_##call(proto); \
static void ftrace_profile_##name(proto); \
\
static int ftrace_profile_enable_##call(struct ftrace_event_call *unused)\
static int ftrace_profile_enable_##name(struct ftrace_event_call *unused)\
{ \
return register_trace_##call(ftrace_profile_##call); \
return register_trace_##name(ftrace_profile_##name); \
} \
\
static void ftrace_profile_disable_##call(struct ftrace_event_call *unused)\
static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
{ \
unregister_trace_##call(ftrace_profile_##call); \
unregister_trace_##name(ftrace_profile_##name); \
}

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
Expand Down Expand Up @@ -550,15 +599,13 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *unused)\
#define __assign_str(dst, src) \
strcpy(__get_str(dst), src);

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
\
static struct ftrace_event_call event_##call; \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print) \
\
static void ftrace_raw_event_##call(proto) \
static void ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
proto) \
{ \
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
struct ftrace_event_call *event_call = &event_##call; \
struct ring_buffer_event *event; \
struct ftrace_raw_##call *entry; \
struct ring_buffer *buffer; \
Expand All @@ -572,7 +619,7 @@ static void ftrace_raw_event_##call(proto) \
__data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
\
event = trace_current_buffer_lock_reserve(&buffer, \
event_##call.id, \
event_call->id, \
sizeof(*entry) + __data_size, \
irq_flags, pc); \
if (!event) \
Expand All @@ -587,6 +634,14 @@ static void ftrace_raw_event_##call(proto) \
if (!filter_current_check_discard(buffer, event_call, entry, event)) \
trace_nowake_buffer_unlock_commit(buffer, \
event, irq_flags, pc); \
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
\
static void ftrace_raw_event_##call(proto) \
{ \
ftrace_raw_event_id_##template(&event_##call, args); \
} \
\
static int ftrace_raw_reg_event_##call(struct ftrace_event_call *unused)\
Expand Down Expand Up @@ -630,8 +685,8 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.raw_init = ftrace_raw_init_event_##call, \
.regfunc = ftrace_raw_reg_event_##call, \
.unregfunc = ftrace_raw_unreg_event_##call, \
.show_format = ftrace_format_##call, \
.define_fields = ftrace_define_fields_##call, \
.show_format = ftrace_format_##template, \
.define_fields = ftrace_define_fields_##template, \
_TRACE_PROFILE_INIT(call) \
}

Expand Down Expand Up @@ -719,14 +774,15 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
#undef __perf_count
#define __perf_count(c) __count = (c)

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
static void ftrace_profile_##call(proto) \
#undef TRACE_EVENT_TEMPLATE
#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print) \
static void \
ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \
proto) \
{ \
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
extern int perf_swevent_get_recursion_context(void); \
extern void perf_swevent_put_recursion_context(int rctx); \
struct ftrace_event_call *event_call = &event_##call; \
extern void perf_tp_event(int, u64, u64, void *, int); \
struct ftrace_raw_##call *entry; \
u64 __addr = 0, __count = 1; \
Expand Down Expand Up @@ -789,6 +845,15 @@ end_recursion: \
\
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
static void ftrace_profile_##call(proto) \
{ \
struct ftrace_event_call *event_call = &event_##call; \
\
ftrace_profile_templ_##template(event_call, args); \
}

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
#endif /* CONFIG_EVENT_PROFILE */

Expand Down
4 changes: 2 additions & 2 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ static int perf_event_read_group(struct perf_event *event,

size = n * sizeof(u64);

if (copy_to_user(buf + ret, values, size)) {
if (copy_to_user(buf + size, values, size)) {
ret = -EFAULT;
goto unlock;
}
Expand Down Expand Up @@ -3914,7 +3914,7 @@ void perf_swevent_put_recursion_context(int rctx)
{
struct perf_cpu_context *cpuctx = &__get_cpu_var(perf_cpu_context);
barrier();
cpuctx->recursion[rctx]--;
cpuctx->recursion[rctx]++;
put_cpu_var(perf_cpu_context);
}
EXPORT_SYMBOL_GPL(perf_swevent_put_recursion_context);
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ perf*.1
perf*.xml
perf*.html
common-cmds.h
perf.data
tags
TAGS
cscope*
Loading

0 comments on commit 0418d77

Please sign in to comment.