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

Commit 4263565d authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Frederic Weisbecker
Browse files

tracing: Generate names for each kprobe event automatically



Generate names for each kprobe event based on the probe point.
(SYMBOL+offs or MEMADDR).

Also remove generic k*probe event types because there is no user
of those types.

Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Przemysław Pawełczyk <przemyslaw@pawelczyk.it>
Cc: Roland McGrath <roland@redhat.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
LKML-Reference: <20090813203526.31965.56672.stgit@localhost.localdomain>
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
parent a82378d8
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -28,7 +28,8 @@ Synopsis of kprobe_events
  p[:EVENT] SYMBOL[+offs|-offs]|MEMADDR [FETCHARGS]	: Set a probe
  p[:EVENT] SYMBOL[+offs|-offs]|MEMADDR [FETCHARGS]	: Set a probe
  r[:EVENT] SYMBOL[+0] [FETCHARGS]			: Set a return probe
  r[:EVENT] SYMBOL[+0] [FETCHARGS]			: Set a return probe


 EVENT			: Event name.
 EVENT			: Event name. If omitted, the event name is generated
			  based on SYMBOL+offs or MEMADDR.
 SYMBOL[+offs|-offs]	: Symbol+offset where the probe is inserted.
 SYMBOL[+offs|-offs]	: Symbol+offset where the probe is inserted.
 MEMADDR		: Address where the probe is inserted.
 MEMADDR		: Address where the probe is inserted.


+0 −18
Original line number Original line Diff line number Diff line
@@ -175,22 +175,4 @@ TRACE_EVENT_FORMAT(kmem_free, TRACE_KMEM_FREE, kmemtrace_free_entry, ignore,
	TP_RAW_FMT("type:%u call_site:%lx ptr:%p")
	TP_RAW_FMT("type:%u call_site:%lx ptr:%p")
);
);


TRACE_EVENT_FORMAT(kprobe, TRACE_KPROBE, kprobe_trace_entry, ignore,
	TRACE_STRUCT(
		TRACE_FIELD(unsigned long, ip, ip)
		TRACE_FIELD(int, nargs, nargs)
		TRACE_FIELD_ZERO(unsigned long, args)
	),
	TP_RAW_FMT("%08lx: args:0x%lx ...")
);

TRACE_EVENT_FORMAT(kretprobe, TRACE_KRETPROBE, kretprobe_trace_entry, ignore,
	TRACE_STRUCT(
		TRACE_FIELD(unsigned long, func, func)
		TRACE_FIELD(unsigned long, ret_ip, ret_ip)
		TRACE_FIELD(int, nargs, nargs)
		TRACE_FIELD_ZERO(unsigned long, args)
	),
	TP_RAW_FMT("%08lx <- %08lx: args:0x%lx ...")
);
#undef TRACE_SYSTEM
#undef TRACE_SYSTEM
+33 −31
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@


#define MAX_TRACE_ARGS 128
#define MAX_TRACE_ARGS 128
#define MAX_ARGSTR_LEN 63
#define MAX_ARGSTR_LEN 63
#define MAX_EVENT_NAME_LEN 64


/* currently, trace_kprobe only supports X86. */
/* currently, trace_kprobe only supports X86. */


@@ -280,11 +281,11 @@ static struct trace_probe *alloc_trace_probe(const char *symbol,
		if (!tp->symbol)
		if (!tp->symbol)
			goto error;
			goto error;
	}
	}
	if (event) {
	if (!event)
		goto error;
	tp->call.name = kstrdup(event, GFP_KERNEL);
	tp->call.name = kstrdup(event, GFP_KERNEL);
	if (!tp->call.name)
	if (!tp->call.name)
		goto error;
		goto error;
	}


	INIT_LIST_HEAD(&tp->list);
	INIT_LIST_HEAD(&tp->list);
	return tp;
	return tp;
@@ -314,7 +315,7 @@ static struct trace_probe *find_probe_event(const char *event)
	struct trace_probe *tp;
	struct trace_probe *tp;


	list_for_each_entry(tp, &probe_list, list)
	list_for_each_entry(tp, &probe_list, list)
		if (tp->call.name && !strcmp(tp->call.name, event))
		if (!strcmp(tp->call.name, event))
			return tp;
			return tp;
	return NULL;
	return NULL;
}
}
@@ -330,7 +331,6 @@ static void __unregister_trace_probe(struct trace_probe *tp)
/* Unregister a trace_probe and probe_event: call with locking probe_lock */
/* Unregister a trace_probe and probe_event: call with locking probe_lock */
static void unregister_trace_probe(struct trace_probe *tp)
static void unregister_trace_probe(struct trace_probe *tp)
{
{
	if (tp->call.name)
	unregister_probe_event(tp);
	unregister_probe_event(tp);
	__unregister_trace_probe(tp);
	__unregister_trace_probe(tp);
	list_del(&tp->list);
	list_del(&tp->list);
@@ -360,7 +360,6 @@ static int register_trace_probe(struct trace_probe *tp)
		goto end;
		goto end;
	}
	}
	/* register as an event */
	/* register as an event */
	if (tp->call.name) {
	old_tp = find_probe_event(tp->call.name);
	old_tp = find_probe_event(tp->call.name);
	if (old_tp) {
	if (old_tp) {
		/* delete old event */
		/* delete old event */
@@ -372,7 +371,6 @@ static int register_trace_probe(struct trace_probe *tp)
		pr_warning("Faild to register probe event(%d)\n", ret);
		pr_warning("Faild to register probe event(%d)\n", ret);
		__unregister_trace_probe(tp);
		__unregister_trace_probe(tp);
	}
	}
	}
	list_add_tail(&tp->list, &probe_list);
	list_add_tail(&tp->list, &probe_list);
end:
end:
	mutex_unlock(&probe_lock);
	mutex_unlock(&probe_lock);
@@ -580,6 +578,17 @@ static int create_trace_probe(int argc, char **argv)
	argc -= 2; argv += 2;
	argc -= 2; argv += 2;


	/* setup a probe */
	/* setup a probe */
	if (!event) {
		/* Make a new event name */
		char buf[MAX_EVENT_NAME_LEN];
		if (symbol)
			snprintf(buf, MAX_EVENT_NAME_LEN, "%c@%s%+ld",
				 is_return ? 'r' : 'p', symbol, offset);
		else
			snprintf(buf, MAX_EVENT_NAME_LEN, "%c@0x%p",
				 is_return ? 'r' : 'p', addr);
		tp = alloc_trace_probe(symbol, buf, argc);
	} else
		tp = alloc_trace_probe(symbol, event, argc);
		tp = alloc_trace_probe(symbol, event, argc);
	if (IS_ERR(tp))
	if (IS_ERR(tp))
		return PTR_ERR(tp);
		return PTR_ERR(tp);
@@ -661,7 +670,6 @@ static int probes_seq_show(struct seq_file *m, void *v)
	char buf[MAX_ARGSTR_LEN + 1];
	char buf[MAX_ARGSTR_LEN + 1];


	seq_printf(m, "%c", probe_is_return(tp) ? 'r' : 'p');
	seq_printf(m, "%c", probe_is_return(tp) ? 'r' : 'p');
	if (tp->call.name)
	seq_printf(m, ":%s", tp->call.name);
	seq_printf(m, ":%s", tp->call.name);


	if (tp->symbol)
	if (tp->symbol)
@@ -780,10 +788,7 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)
	struct ring_buffer_event *event;
	struct ring_buffer_event *event;
	int size, i, pc;
	int size, i, pc;
	unsigned long irq_flags;
	unsigned long irq_flags;
	struct ftrace_event_call *call = &event_kprobe;
	struct ftrace_event_call *call = &tp->call;

	if (&tp->call.name)
		call = &tp->call;


	local_save_flags(irq_flags);
	local_save_flags(irq_flags);
	pc = preempt_count();
	pc = preempt_count();
@@ -815,10 +820,7 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri,
	struct ring_buffer_event *event;
	struct ring_buffer_event *event;
	int size, i, pc;
	int size, i, pc;
	unsigned long irq_flags;
	unsigned long irq_flags;
	struct ftrace_event_call *call = &event_kretprobe;
	struct ftrace_event_call *call = &tp->call;

	if (&tp->call.name)
		call = &tp->call;


	local_save_flags(irq_flags);
	local_save_flags(irq_flags);
	pc = preempt_count();
	pc = preempt_count();