Skip to content

Commit 8380d24

Browse files
committed
ftrace: Separate unlimited probes from count limited probes
The function tracing probes that trigger traceon or traceoff can be set to unlimited, or given a count of # of times to execute. By separating these two types of probes, we can then use the dynamic ftrace function filtering directly, and remove the brute force "check if this function called is my probe" routines in ftrace. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 8b8fa62 commit 8380d24

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

‎kernel/trace/trace_functions.c‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int update_count(void **data)
228228
}
229229

230230
static void
231-
ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
231+
ftrace_traceon_count(unsigned long ip, unsigned long parent_ip, void **data)
232232
{
233233
if (tracing_is_on())
234234
return;
@@ -238,7 +238,7 @@ ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
238238
}
239239

240240
static void
241-
ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
241+
ftrace_traceoff_count(unsigned long ip, unsigned long parent_ip, void **data)
242242
{
243243
if (!tracing_is_on())
244244
return;
@@ -247,10 +247,38 @@ ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
247247
tracing_off();
248248
}
249249

250+
static void
251+
ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
252+
{
253+
if (tracing_is_on())
254+
return;
255+
256+
tracing_on();
257+
}
258+
259+
static void
260+
ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
261+
{
262+
if (!tracing_is_on())
263+
return;
264+
265+
tracing_off();
266+
}
267+
250268
static int
251269
ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip,
252270
struct ftrace_probe_ops *ops, void *data);
253271

272+
static struct ftrace_probe_ops traceon_count_probe_ops = {
273+
.func = ftrace_traceon_count,
274+
.print = ftrace_trace_onoff_print,
275+
};
276+
277+
static struct ftrace_probe_ops traceoff_count_probe_ops = {
278+
.func = ftrace_traceoff_count,
279+
.print = ftrace_trace_onoff_print,
280+
};
281+
254282
static struct ftrace_probe_ops traceon_probe_ops = {
255283
.func = ftrace_traceon,
256284
.print = ftrace_trace_onoff_print,
@@ -269,7 +297,7 @@ ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip,
269297

270298
seq_printf(m, "%ps:", (void *)ip);
271299

272-
if (ops == &traceon_probe_ops)
300+
if (ops == &traceon_probe_ops || ops == &traceon_count_probe_ops)
273301
seq_printf(m, "traceon");
274302
else
275303
seq_printf(m, "traceoff");
@@ -297,9 +325,9 @@ ftrace_trace_onoff_callback(struct ftrace_hash *hash,
297325

298326
/* we register both traceon and traceoff to this callback */
299327
if (strcmp(cmd, "traceon") == 0)
300-
ops = &traceon_probe_ops;
328+
ops = param ? &traceon_count_probe_ops : &traceon_probe_ops;
301329
else
302-
ops = &traceoff_probe_ops;
330+
ops = param ? &traceoff_count_probe_ops : &traceoff_probe_ops;
303331

304332
if (glob[0] == '!') {
305333
unregister_ftrace_function_probe_func(glob+1, ops);

0 commit comments

Comments
 (0)