Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac199db0 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

ftrace: event profile hooks



Impact: new tracing infrastructure feature

Provide infrastructure to generate software perf counter events
from tracepoints.

Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20090319194233.557364871@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 28bea271
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,5 +44,6 @@ obj-$(CONFIG_EVENT_TRACER) += trace_events.o
obj-$(CONFIG_EVENT_TRACER) += events.o
obj-$(CONFIG_EVENT_TRACER) += trace_export.o
obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o

libftrace-y := ftrace.o
+0 −1
Original line number Diff line number Diff line
@@ -12,4 +12,3 @@
#include "trace_events_stage_2.h"
#include "trace_events_stage_3.h"
#include <trace/trace_event_types.h>
+11 −0
Original line number Diff line number Diff line
@@ -785,12 +785,23 @@ struct ftrace_event_call {
	int		id;
	int		(*raw_init)(void);
	int		(*show_format)(struct trace_seq *s);

#ifdef CONFIG_EVENT_PROFILE
	atomic_t	profile_count;
	int		(*profile_enable)(struct ftrace_event_call *);
	void		(*profile_disable)(struct ftrace_event_call *);
#endif
};

void event_trace_printk(unsigned long ip, const char *fmt, ...);
extern struct ftrace_event_call __start_ftrace_events[];
extern struct ftrace_event_call __stop_ftrace_events[];

#define for_each_event(event)						\
	for (event = __start_ftrace_events;				\
	     (unsigned long)event < (unsigned long)__stop_ftrace_events; \
	     event++)

extern const char *__start___trace_bprintk_fmt[];
extern const char *__stop___trace_bprintk_fmt[];

+31 −0
Original line number Diff line number Diff line
/*
 * trace event based perf counter profiling
 *
 * Copyright (C) 2009 Red Hat Inc, Peter Zijlstra <pzijlstr@redhat.com>
 *
 */

#include "trace.h"

int ftrace_profile_enable(int event_id)
{
	struct ftrace_event_call *event;

	for_each_event(event) {
		if (event->id == event_id)
			return event->profile_enable(event);
	}

	return -EINVAL;
}

void ftrace_profile_disable(int event_id)
{
	struct ftrace_event_call *event;

	for_each_event(event) {
		if (event->id == event_id)
			return event->profile_disable(event);
	}
}
+2 −7
Original line number Diff line number Diff line
@@ -19,11 +19,6 @@

static DEFINE_MUTEX(event_mutex);

#define events_for_each(event)						\
	for (event = __start_ftrace_events;				\
	     (unsigned long)event < (unsigned long)__stop_ftrace_events; \
	     event++)

static void ftrace_clear_events(void)
{
	struct ftrace_event_call *call = (void *)__start_ftrace_events;
@@ -90,7 +85,7 @@ static int ftrace_set_clr_event(char *buf, int set)
	}

	mutex_lock(&event_mutex);
	events_for_each(call) {
	for_each_event(call) {

		if (!call->name || !call->regfunc)
			continue;
@@ -628,7 +623,7 @@ static __init int event_trace_init(void)
	if (!d_events)
		return 0;

	events_for_each(call) {
	for_each_event(call) {
		/* The linker may leave blanks */
		if (!call->name)
			continue;
Loading