Adding TRACE_REG_PERF_ADD and TRACE_REG_PERF_DEL to handle perf event schedule in/out actions. The add action is invoked for when the perf event is scheduled in, while the del action is invoked when the event is scheduled out. Link: http://lkml.kernel.org/r/1329317514-8131-4-git-send-email-jolsa@redhat.com
Showing the changes to kernel (4 of 5 files). Show all
Unified · Split
| @@ -211,12 +211,14 @@ int perf_trace_add(struct perf_event *p_event, int flags) · 210 unmodified lines | |||
| 211 | list = this_cpu_ptr(pcpu_list); | 211 | list = this_cpu_ptr(pcpu_list); |
| 212 | hlist_add_head_rcu(&p_event->hlist_entry, list); | 212 | hlist_add_head_rcu(&p_event->hlist_entry, list); |
| 213 | 213 | ||
| 214 | return 0; | 214 | return tp_event->class->reg(tp_event, TRACE_REG_PERF_ADD, p_event); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | void perf_trace_del(struct perf_event *p_event, int flags) | 217 | void perf_trace_del(struct perf_event *p_event, int flags) |
| 218 | { | 218 | { |
| 219 | struct ftrace_event_call *tp_event = p_event->tp_event; | ||
| 219 | hlist_del_rcu(&p_event->hlist_entry); | 220 | hlist_del_rcu(&p_event->hlist_entry); |
| 221 | tp_event->class->reg(tp_event, TRACE_REG_PERF_DEL, p_event); | ||
| 220 | } | 222 | } |
| 221 | 223 | ||
| 222 | __kprobes void *perf_trace_buf_prepare(int size, unsigned short type, | 224 | __kprobes void *perf_trace_buf_prepare(int size, unsigned short type, |
| @@ -173,6 +173,8 @@ int ftrace_event_reg(struct ftrace_event_call *call, · 172 unmodified lines | |||
| 173 | return 0; | 173 | return 0; |
| 174 | case TRACE_REG_PERF_OPEN: | 174 | case TRACE_REG_PERF_OPEN: |
| 175 | case TRACE_REG_PERF_CLOSE: | 175 | case TRACE_REG_PERF_CLOSE: |
| 176 | case TRACE_REG_PERF_ADD: | ||
| 177 | case TRACE_REG_PERF_DEL: | ||
| 176 | return 0; | 178 | return 0; |
| 177 | #endif | 179 | #endif |
| 178 | } | 180 | } |
| @@ -1912,6 +1912,8 @@ int kprobe_register(struct ftrace_event_call *event, · 1911 unmodified lines | |||
| 1912 | return 0; | 1912 | return 0; |
| 1913 | case TRACE_REG_PERF_OPEN: | 1913 | case TRACE_REG_PERF_OPEN: |
| 1914 | case TRACE_REG_PERF_CLOSE: | 1914 | case TRACE_REG_PERF_CLOSE: |
| 1915 | case TRACE_REG_PERF_ADD: | ||
| 1916 | case TRACE_REG_PERF_DEL: | ||
| 1915 | return 0; | 1917 | return 0; |
| 1916 | #endif | 1918 | #endif |
| 1917 | } | 1919 | } |
| @@ -666,6 +666,8 @@ static int syscall_enter_register(struct ftrace_event_call *event, · 665 unmodified lines | |||
| 666 | return 0; | 666 | return 0; |
| 667 | case TRACE_REG_PERF_OPEN: | 667 | case TRACE_REG_PERF_OPEN: |
| 668 | case TRACE_REG_PERF_CLOSE: | 668 | case TRACE_REG_PERF_CLOSE: |
| 669 | case TRACE_REG_PERF_ADD: | ||
| 670 | case TRACE_REG_PERF_DEL: | ||
| 669 | return 0; | 671 | return 0; |
| 670 | #endif | 672 | #endif |
| 671 | } | 673 | } |
| @@ -690,6 +692,8 @@ static int syscall_exit_register(struct ftrace_event_call *event, · 18 unmodified lines | |||
| 690 | return 0; | 692 | return 0; |
| 691 | case TRACE_REG_PERF_OPEN: | 693 | case TRACE_REG_PERF_OPEN: |
| 692 | case TRACE_REG_PERF_CLOSE: | 694 | case TRACE_REG_PERF_CLOSE: |
| 695 | case TRACE_REG_PERF_ADD: | ||
| 696 | case TRACE_REG_PERF_DEL: | ||
| 693 | return 0; | 697 | return 0; |
| 694 | #endif | 698 | #endif |
| 695 | } | 699 | } |