Skip to content

Commit

Permalink
tracing/kprobes: add maxactive
Browse files Browse the repository at this point in the history
  • Loading branch information
alban committed Mar 27, 2017
1 parent d23a982 commit 3c713f1
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions kernel/trace/trace_kprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static struct trace_kprobe *alloc_trace_kprobe(const char *group,
void *addr,
const char *symbol,
unsigned long offs,
int maxactive,
int nargs, bool is_return)
{
struct trace_kprobe *tk;
Expand Down Expand Up @@ -307,6 +308,8 @@ static struct trace_kprobe *alloc_trace_kprobe(const char *group,
else
tk->rp.kp.pre_handler = kprobe_dispatcher;

tk->rp.maxactive = maxactive;

if (!event || !is_good_name(event)) {
ret = -EINVAL;
goto error;
Expand Down Expand Up @@ -597,7 +600,7 @@ static int create_trace_kprobe(int argc, char **argv)
/*
* Argument syntax:
* - Add kprobe: p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
* - Add kretprobe: r[:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
* - Add kretprobe: r[MAXACTIVE][:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
* Fetch args:
* $retval : fetch return value
* $stack : fetch stack address
Expand All @@ -617,6 +620,7 @@ static int create_trace_kprobe(int argc, char **argv)
int i, ret = 0;
bool is_return = false, is_delete = false;
char *symbol = NULL, *event = NULL, *group = NULL;
int maxactive = 0;
char *arg;
unsigned long offset = 0;
void *addr = NULL;
Expand All @@ -635,8 +639,18 @@ static int create_trace_kprobe(int argc, char **argv)
return -EINVAL;
}

if (argv[0][1] == ':') {
if (isdigit(argv[0][1]) && strchr(&argv[0][1], ':')) {
event = strchr(&argv[0][1], ':') + 1;
event[-1] = '\0';
ret = kstrtouint(&argv[0][1], 0, &maxactive);
if (ret) {
pr_info("Failed to parse maxactive.\n");
return ret;
}
} else if (argv[0][1] == ':')
event = &argv[0][2];

if (event) {
if (strchr(event, '/')) {
group = event;
event = strchr(group, '/') + 1;
Expand Down Expand Up @@ -716,8 +730,8 @@ static int create_trace_kprobe(int argc, char **argv)
is_return ? 'r' : 'p', addr);
event = buf;
}
tk = alloc_trace_kprobe(group, event, addr, symbol, offset, argc,
is_return);
tk = alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive,
argc, is_return);
if (IS_ERR(tk)) {
pr_info("Failed to allocate trace_probe.(%d)\n",
(int)PTR_ERR(tk));
Expand Down

0 comments on commit 3c713f1

Please sign in to comment.