tracing/kprobes: Support custom subsystem for each kprobe event
Support specifying a custom subsystem(group) for each kprobe event. This allows users to create new group to control several probes at once, or add events to existing groups as additional tracepoints. New synopsis: p[:[subsys/]event-name] KADDR|KSYM[+offs] [ARGS] Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jason Baron <jbaron@redhat.com> Cc: K.Prasad <prasad@linux.vnet.ibm.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <20090910235353.22412.15149.stgit@dhcp-100-2-132.bos.redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
This commit is contained in:
parent
6e9f23d161
commit
f52487e9c0
2 changed files with 30 additions and 8 deletions
|
@ -25,9 +25,10 @@ probe events via /sys/kernel/debug/tracing/events/kprobes/<EVENT>/filter.
|
||||||
|
|
||||||
Synopsis of kprobe_events
|
Synopsis of kprobe_events
|
||||||
-------------------------
|
-------------------------
|
||||||
p[:EVENT] SYMBOL[+offs]|MEMADDR [FETCHARGS] : Set a probe
|
p[:[GRP/]EVENT] SYMBOL[+offs]|MEMADDR [FETCHARGS] : Set a probe
|
||||||
r[:EVENT] SYMBOL[+0] [FETCHARGS] : Set a return probe
|
r[:[GRP/]EVENT] SYMBOL[+0] [FETCHARGS] : Set a return probe
|
||||||
|
|
||||||
|
GRP : Group name. If omitted, use "kprobes" for it.
|
||||||
EVENT : Event name. If omitted, the event name is generated
|
EVENT : Event name. If omitted, the event name is generated
|
||||||
based on SYMBOL+offs or MEMADDR.
|
based on SYMBOL+offs or MEMADDR.
|
||||||
SYMBOL[+offs] : Symbol+offset where the probe is inserted.
|
SYMBOL[+offs] : Symbol+offset where the probe is inserted.
|
||||||
|
|
|
@ -36,6 +36,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
|
#define MAX_EVENT_NAME_LEN 64
|
||||||
|
#define KPROBE_EVENT_SYSTEM "kprobes"
|
||||||
|
|
||||||
/* currently, trace_kprobe only supports X86. */
|
/* currently, trace_kprobe only supports X86. */
|
||||||
|
|
||||||
|
@ -265,7 +266,8 @@ static LIST_HEAD(probe_list);
|
||||||
/*
|
/*
|
||||||
* Allocate new trace_probe and initialize it (including kprobes).
|
* Allocate new trace_probe and initialize it (including kprobes).
|
||||||
*/
|
*/
|
||||||
static struct trace_probe *alloc_trace_probe(const char *event,
|
static struct trace_probe *alloc_trace_probe(const char *group,
|
||||||
|
const char *event,
|
||||||
void *addr,
|
void *addr,
|
||||||
const char *symbol,
|
const char *symbol,
|
||||||
unsigned long offs,
|
unsigned long offs,
|
||||||
|
@ -298,9 +300,16 @@ static struct trace_probe *alloc_trace_probe(const char *event,
|
||||||
if (!tp->call.name)
|
if (!tp->call.name)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (!group)
|
||||||
|
goto error;
|
||||||
|
tp->call.system = kstrdup(group, GFP_KERNEL);
|
||||||
|
if (!tp->call.system)
|
||||||
|
goto error;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&tp->list);
|
INIT_LIST_HEAD(&tp->list);
|
||||||
return tp;
|
return tp;
|
||||||
error:
|
error:
|
||||||
|
kfree(tp->call.name);
|
||||||
kfree(tp->symbol);
|
kfree(tp->symbol);
|
||||||
kfree(tp);
|
kfree(tp);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
@ -322,6 +331,7 @@ static void free_trace_probe(struct trace_probe *tp)
|
||||||
for (i = 0; i < tp->nr_args; i++)
|
for (i = 0; i < tp->nr_args; i++)
|
||||||
free_probe_arg(&tp->args[i]);
|
free_probe_arg(&tp->args[i]);
|
||||||
|
|
||||||
|
kfree(tp->call.system);
|
||||||
kfree(tp->call.name);
|
kfree(tp->call.name);
|
||||||
kfree(tp->symbol);
|
kfree(tp->symbol);
|
||||||
kfree(tp);
|
kfree(tp);
|
||||||
|
@ -530,8 +540,8 @@ static int create_trace_probe(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Argument syntax:
|
* Argument syntax:
|
||||||
* - Add kprobe: p[:EVENT] SYMBOL[+OFFS]|ADDRESS [FETCHARGS]
|
* - Add kprobe: p[:[GRP/]EVENT] KSYM[+OFFS]|KADDR [FETCHARGS]
|
||||||
* - Add kretprobe: r[:EVENT] SYMBOL[+0] [FETCHARGS]
|
* - Add kretprobe: r[:[GRP/]EVENT] KSYM[+0] [FETCHARGS]
|
||||||
* Fetch args:
|
* Fetch args:
|
||||||
* aN : fetch Nth of function argument. (N:0-)
|
* aN : fetch Nth of function argument. (N:0-)
|
||||||
* rv : fetch return value
|
* rv : fetch return value
|
||||||
|
@ -549,7 +559,7 @@ static int create_trace_probe(int argc, char **argv)
|
||||||
struct trace_probe *tp;
|
struct trace_probe *tp;
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
int is_return = 0;
|
int is_return = 0;
|
||||||
char *symbol = NULL, *event = NULL, *arg = NULL;
|
char *symbol = NULL, *event = NULL, *arg = NULL, *group = NULL;
|
||||||
unsigned long offset = 0;
|
unsigned long offset = 0;
|
||||||
void *addr = NULL;
|
void *addr = NULL;
|
||||||
char buf[MAX_EVENT_NAME_LEN];
|
char buf[MAX_EVENT_NAME_LEN];
|
||||||
|
@ -566,6 +576,15 @@ static int create_trace_probe(int argc, char **argv)
|
||||||
|
|
||||||
if (argv[0][1] == ':') {
|
if (argv[0][1] == ':') {
|
||||||
event = &argv[0][2];
|
event = &argv[0][2];
|
||||||
|
if (strchr(event, '/')) {
|
||||||
|
group = event;
|
||||||
|
event = strchr(group, '/') + 1;
|
||||||
|
event[-1] = '\0';
|
||||||
|
if (strlen(group) == 0) {
|
||||||
|
pr_info("Group name is not specifiled\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (strlen(event) == 0) {
|
if (strlen(event) == 0) {
|
||||||
pr_info("Event name is not specifiled\n");
|
pr_info("Event name is not specifiled\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -592,6 +611,8 @@ static int create_trace_probe(int argc, char **argv)
|
||||||
argc -= 2; argv += 2;
|
argc -= 2; argv += 2;
|
||||||
|
|
||||||
/* setup a probe */
|
/* setup a probe */
|
||||||
|
if (!group)
|
||||||
|
group = KPROBE_EVENT_SYSTEM;
|
||||||
if (!event) {
|
if (!event) {
|
||||||
/* Make a new event name */
|
/* Make a new event name */
|
||||||
if (symbol)
|
if (symbol)
|
||||||
|
@ -602,7 +623,8 @@ static int create_trace_probe(int argc, char **argv)
|
||||||
is_return ? 'r' : 'p', addr);
|
is_return ? 'r' : 'p', addr);
|
||||||
event = buf;
|
event = buf;
|
||||||
}
|
}
|
||||||
tp = alloc_trace_probe(event, addr, symbol, offset, argc, is_return);
|
tp = alloc_trace_probe(group, event, addr, symbol, offset, argc,
|
||||||
|
is_return);
|
||||||
if (IS_ERR(tp))
|
if (IS_ERR(tp))
|
||||||
return PTR_ERR(tp);
|
return PTR_ERR(tp);
|
||||||
|
|
||||||
|
@ -1217,7 +1239,6 @@ static int register_probe_event(struct trace_probe *tp)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Initialize ftrace_event_call */
|
/* Initialize ftrace_event_call */
|
||||||
call->system = "kprobes";
|
|
||||||
if (probe_is_return(tp)) {
|
if (probe_is_return(tp)) {
|
||||||
tp->event.trace = print_kretprobe_event;
|
tp->event.trace = print_kretprobe_event;
|
||||||
call->raw_init = probe_event_raw_init;
|
call->raw_init = probe_event_raw_init;
|
||||||
|
|
Loading…
Reference in a new issue