* [PATCH] tracing/kprobes: Add trace event trigger invocations
@ 2013-12-29 2:24 Tom Zanussi
2014-01-06 1:16 ` Masami Hiramatsu
2014-01-06 16:10 ` Steven Rostedt
0 siblings, 2 replies; 4+ messages in thread
From: Tom Zanussi @ 2013-12-29 2:24 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu
Cc: Jean-Jacques Hiblot, Linux Kernel Mailing List
Add code to the kprobe/kretprobe event functions that will invoke any
event triggers associated with a probe's ftrace_event_file.
The code to do this is very similar to the invocation code already
used to invoke the triggers associated with static events and
essentially replaces the existing soft-disable checks with a superset
that preserves the original behavior but adds the bits needed to
support event triggers.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
kernel/trace/trace_kprobe.c | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index dae9541..1ee13eb 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -812,12 +812,20 @@ __kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs,
struct ring_buffer *buffer;
int size, dsize, pc;
unsigned long irq_flags;
+ unsigned long eflags;
+ enum event_trigger_type __tt = ETT_NONE;
struct ftrace_event_call *call = &tp->call;
WARN_ON(call != ftrace_file->event_call);
- if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
- return;
+ eflags = ftrace_file->flags;
+
+ if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
+ if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
+ event_triggers_call(ftrace_file, NULL);
+ if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
+ return;
+ }
local_save_flags(irq_flags);
pc = preempt_count();
@@ -835,9 +843,16 @@ __kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs,
entry->ip = (unsigned long)tp->rp.kp.addr;
store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
- if (!filter_check_discard(ftrace_file, entry, buffer, event))
+ if (eflags & FTRACE_EVENT_FL_TRIGGER_COND)
+ __tt = event_triggers_call(ftrace_file, entry);
+
+ if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
+ ring_buffer_discard_commit(buffer, event);
+ else if (!filter_check_discard(ftrace_file, entry, buffer, event))
trace_buffer_unlock_commit_regs(buffer, event,
irq_flags, pc, regs);
+ if (__tt)
+ event_triggers_post_call(ftrace_file, __tt);
}
static __kprobes void
@@ -860,12 +875,20 @@ __kretprobe_trace_func(struct trace_probe *tp, struct kretprobe_instance *ri,
struct ring_buffer *buffer;
int size, pc, dsize;
unsigned long irq_flags;
+ unsigned long eflags;
+ enum event_trigger_type __tt = ETT_NONE;
struct ftrace_event_call *call = &tp->call;
WARN_ON(call != ftrace_file->event_call);
- if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
- return;
+ eflags = ftrace_file->flags;
+
+ if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
+ if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
+ event_triggers_call(ftrace_file, NULL);
+ if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
+ return;
+ }
local_save_flags(irq_flags);
pc = preempt_count();
@@ -884,9 +907,16 @@ __kretprobe_trace_func(struct trace_probe *tp, struct kretprobe_instance *ri,
entry->ret_ip = (unsigned long)ri->ret_addr;
store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
- if (!filter_check_discard(ftrace_file, entry, buffer, event))
+ if (eflags & FTRACE_EVENT_FL_TRIGGER_COND)
+ __tt = event_triggers_call(ftrace_file, entry);
+
+ if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
+ ring_buffer_discard_commit(buffer, event);
+ else if (!filter_check_discard(ftrace_file, entry, buffer, event))
trace_buffer_unlock_commit_regs(buffer, event,
irq_flags, pc, regs);
+ if (__tt)
+ event_triggers_post_call(ftrace_file, __tt);
}
static __kprobes void
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/kprobes: Add trace event trigger invocations
2013-12-29 2:24 [PATCH] tracing/kprobes: Add trace event trigger invocations Tom Zanussi
@ 2014-01-06 1:16 ` Masami Hiramatsu
2014-01-06 16:10 ` Steven Rostedt
1 sibling, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2014-01-06 1:16 UTC (permalink / raw)
To: Tom Zanussi
Cc: Steven Rostedt, Jean-Jacques Hiblot, Linux Kernel Mailing List
(2013/12/29 11:24), Tom Zanussi wrote:
> Add code to the kprobe/kretprobe event functions that will invoke any
> event triggers associated with a probe's ftrace_event_file.
>
> The code to do this is very similar to the invocation code already
> used to invoke the triggers associated with static events and
> essentially replaces the existing soft-disable checks with a superset
> that preserves the original behavior but adds the bits needed to
> support event triggers.
>
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Looks good for me :)
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Thank you!
> ---
> kernel/trace/trace_kprobe.c | 42 ++++++++++++++++++++++++++++++++++++------
> 1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index dae9541..1ee13eb 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -812,12 +812,20 @@ __kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs,
> struct ring_buffer *buffer;
> int size, dsize, pc;
> unsigned long irq_flags;
> + unsigned long eflags;
> + enum event_trigger_type __tt = ETT_NONE;
> struct ftrace_event_call *call = &tp->call;
>
> WARN_ON(call != ftrace_file->event_call);
>
> - if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> - return;
> + eflags = ftrace_file->flags;
> +
> + if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
> + if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
> + event_triggers_call(ftrace_file, NULL);
> + if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
> + return;
> + }
>
> local_save_flags(irq_flags);
> pc = preempt_count();
> @@ -835,9 +843,16 @@ __kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs,
> entry->ip = (unsigned long)tp->rp.kp.addr;
> store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
>
> - if (!filter_check_discard(ftrace_file, entry, buffer, event))
> + if (eflags & FTRACE_EVENT_FL_TRIGGER_COND)
> + __tt = event_triggers_call(ftrace_file, entry);
> +
> + if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> + ring_buffer_discard_commit(buffer, event);
> + else if (!filter_check_discard(ftrace_file, entry, buffer, event))
> trace_buffer_unlock_commit_regs(buffer, event,
> irq_flags, pc, regs);
> + if (__tt)
> + event_triggers_post_call(ftrace_file, __tt);
> }
>
> static __kprobes void
> @@ -860,12 +875,20 @@ __kretprobe_trace_func(struct trace_probe *tp, struct kretprobe_instance *ri,
> struct ring_buffer *buffer;
> int size, pc, dsize;
> unsigned long irq_flags;
> + unsigned long eflags;
> + enum event_trigger_type __tt = ETT_NONE;
> struct ftrace_event_call *call = &tp->call;
>
> WARN_ON(call != ftrace_file->event_call);
>
> - if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> - return;
> + eflags = ftrace_file->flags;
> +
> + if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
> + if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
> + event_triggers_call(ftrace_file, NULL);
> + if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
> + return;
> + }
>
> local_save_flags(irq_flags);
> pc = preempt_count();
> @@ -884,9 +907,16 @@ __kretprobe_trace_func(struct trace_probe *tp, struct kretprobe_instance *ri,
> entry->ret_ip = (unsigned long)ri->ret_addr;
> store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
>
> - if (!filter_check_discard(ftrace_file, entry, buffer, event))
> + if (eflags & FTRACE_EVENT_FL_TRIGGER_COND)
> + __tt = event_triggers_call(ftrace_file, entry);
> +
> + if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> + ring_buffer_discard_commit(buffer, event);
> + else if (!filter_check_discard(ftrace_file, entry, buffer, event))
> trace_buffer_unlock_commit_regs(buffer, event,
> irq_flags, pc, regs);
> + if (__tt)
> + event_triggers_post_call(ftrace_file, __tt);
> }
>
> static __kprobes void
>
--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/kprobes: Add trace event trigger invocations
2013-12-29 2:24 [PATCH] tracing/kprobes: Add trace event trigger invocations Tom Zanussi
2014-01-06 1:16 ` Masami Hiramatsu
@ 2014-01-06 16:10 ` Steven Rostedt
2014-01-06 19:44 ` Tom Zanussi
1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2014-01-06 16:10 UTC (permalink / raw)
To: Tom Zanussi
Cc: Masami Hiramatsu, Jean-Jacques Hiblot, Linux Kernel Mailing List
On Sat, 28 Dec 2013 20:24:08 -0600
Tom Zanussi <tom.zanussi@linux.intel.com> wrote:
> Add code to the kprobe/kretprobe event functions that will invoke any
> event triggers associated with a probe's ftrace_event_file.
>
> The code to do this is very similar to the invocation code already
> used to invoke the triggers associated with static events and
> essentially replaces the existing soft-disable checks with a superset
> that preserves the original behavior but adds the bits needed to
> support event triggers.
>
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
> kernel/trace/trace_kprobe.c | 42 ++++++++++++++++++++++++++++++++++++------
> 1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index dae9541..1ee13eb 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -812,12 +812,20 @@ __kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs,
> struct ring_buffer *buffer;
> int size, dsize, pc;
> unsigned long irq_flags;
> + unsigned long eflags;
> + enum event_trigger_type __tt = ETT_NONE;
What's the significance of the "__" in the variable?
Looks as if you copied it from the ftrace_raw_event_* macro. The "__"
there is usually recommended because it is a macro and we try to avoid
namespace collisions by adding the "__".
This is a proper function, please remove the "__" from it.
Thanks,
-- Steve
> struct ftrace_event_call *call = &tp->call;
>
> WARN_ON(call != ftrace_file->event_call);
>
> - if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> - return;
> + eflags = ftrace_file->flags;
> +
> + if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
> + if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
> + event_triggers_call(ftrace_file, NULL);
> + if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
> + return;
> + }
>
> local_save_flags(irq_flags);
> pc = preempt_count();
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/kprobes: Add trace event trigger invocations
2014-01-06 16:10 ` Steven Rostedt
@ 2014-01-06 19:44 ` Tom Zanussi
0 siblings, 0 replies; 4+ messages in thread
From: Tom Zanussi @ 2014-01-06 19:44 UTC (permalink / raw)
To: Steven Rostedt
Cc: Masami Hiramatsu, Jean-Jacques Hiblot, Linux Kernel Mailing List
On Mon, 2014-01-06 at 11:10 -0500, Steven Rostedt wrote:
> On Sat, 28 Dec 2013 20:24:08 -0600
> Tom Zanussi <tom.zanussi@linux.intel.com> wrote:
>
> > Add code to the kprobe/kretprobe event functions that will invoke any
> > event triggers associated with a probe's ftrace_event_file.
> >
> > The code to do this is very similar to the invocation code already
> > used to invoke the triggers associated with static events and
> > essentially replaces the existing soft-disable checks with a superset
> > that preserves the original behavior but adds the bits needed to
> > support event triggers.
> >
> > Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> > ---
> > kernel/trace/trace_kprobe.c | 42 ++++++++++++++++++++++++++++++++++++------
> > 1 file changed, 36 insertions(+), 6 deletions(-)
> >
> > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> > index dae9541..1ee13eb 100644
> > --- a/kernel/trace/trace_kprobe.c
> > +++ b/kernel/trace/trace_kprobe.c
> > @@ -812,12 +812,20 @@ __kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs,
> > struct ring_buffer *buffer;
> > int size, dsize, pc;
> > unsigned long irq_flags;
> > + unsigned long eflags;
> > + enum event_trigger_type __tt = ETT_NONE;
>
> What's the significance of the "__" in the variable?
>
> Looks as if you copied it from the ftrace_raw_event_* macro. The "__"
> there is usually recommended because it is a macro and we try to avoid
> namespace collisions by adding the "__".
>
> This is a proper function, please remove the "__" from it.
>
Right, it was just for consistency with the other invocations. Updates
to this and the syscall invocations which also do the same thing, coming
up...
Tom
> Thanks,
>
> -- Steve
>
>
> > struct ftrace_event_call *call = &tp->call;
> >
> > WARN_ON(call != ftrace_file->event_call);
> >
> > - if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> > - return;
> > + eflags = ftrace_file->flags;
> > +
> > + if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
> > + if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
> > + event_triggers_call(ftrace_file, NULL);
> > + if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
> > + return;
> > + }
> >
> > local_save_flags(irq_flags);
> > pc = preempt_count();
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-06 19:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-29 2:24 [PATCH] tracing/kprobes: Add trace event trigger invocations Tom Zanussi
2014-01-06 1:16 ` Masami Hiramatsu
2014-01-06 16:10 ` Steven Rostedt
2014-01-06 19:44 ` Tom Zanussi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox