tracing/kprobe: Add tracefs to show private kprobe
PATCH 1/1 tracing/kprobe: Add tracefs to show private kprobe
List private kprobe event to new created local_event_list; Add tracefs file kprobe_local_profile to show events which in local_event_list.
Signed-off-by Jianlin Lv <[email protected]>
--- kernel/trace/trace_dynevent.c | 18 +++++++++++++ kernel/trace/trace_dynevent.h | 33 +++++++++++++++++++++++ kernel/trace/trace_kprobe.c | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+)
kernel/trace/trace_dynevent.c +18 -0
@@ -181,6 +181,24 @@ static const struct seq_operations dyn_event_seq_op = { .show = dyn_event_seq_show }; +LIST_HEAD (local_event_list); + +void *local_event_seq_start (struct seq_file *m,loff_t *pos) +{ +mutex_lock (&event_mutex); +return seq_list_start (&local_event_list, *pos); +} + +void *local_event_seq_next (struct seq_file *m,void *v,loff_t *pos) +{ +return seq_list_next (v, &local_event_list, pos); +} + +void local_event_seq_stop (struct seq_file *m,void *v) +{ +mutex_unlock (&event_mutex); +} +/* * dyn_events_release_all - Release all specific events * @type: the dyn_event_operations * which filters releasing events
kernel/trace/trace_dynevent.h +33 -0
@@ -64,6 +64,7 @@ struct dyn_event { };extern struct list_head dyn_event_list; +extern struct list_head local_event_list;static inline int dyn_event_init (struct dyn_event *ev,struct dyn_event_operations *ops)
@@ -95,12 +96,44 @@ static inline void dyn_event_remove(struct dyn_event *ev)list_del_init (&ev->list); } +static inline +int local_event_init (struct dyn_event *ev,struct dyn_event_operations *ops) +{ +if (!ev || !ops) +return -EINVAL ; + +INIT_LIST_HEAD (&ev->list); + ev->ops = ops; +return 0 ; +} + +static inline int local_event_add (struct dyn_event *ev) +{ +lockdep_assert_held (&event_mutex); + +if (!ev || !ev->ops) +return -EINVAL ; + +list_add_tail (&ev->list, &local_event_list); +return 0 ; +} + +static inline void local_event_remove (struct dyn_event *ev) +{ +lockdep_assert_held (&event_mutex); +list_del_init (&ev->list); +} +void *dyn_event_seq_start (struct seq_file *m,loff_t *pos);void *dyn_event_seq_next (struct seq_file *m,void *v,loff_t *pos);void dyn_event_seq_stop (struct seq_file *m,void *v);int dyn_events_release_all (struct dyn_event_operations *type);int dyn_event_release (const char *raw_command,struct dyn_event_operations *type); +void *local_event_seq_start (struct seq_file *m,loff_t *pos); +void *local_event_seq_next (struct seq_file *m,void *v,loff_t *pos); +void local_event_seq_stop (struct seq_file *m,void *v); +/* * for_each_dyn_event - iterate over the dyn_event list * @pos: the struct dyn_event * to use as a loop cursor
kernel/trace/trace_kprobe.c +50 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
Steven Rostedt
maintainerQuoted 3 lines · On Sun, 24 Jul 2022 09:10:50 +0000 Jianlin Lv <[email protected]> wrote:
List private kprobe event to new created
local_event_list; Add tracefs filekprobe_local_profileto show events which inlocal_event_list.
This states what you are doing, but not why you are doing it.
The subject of a commit should be the what, and the body should explain the why.
And the subject is confusing because you are not "adding tracefs", it should state:
tracing/kprobes: Add method to display private kprobes in tracefs
Or something like that.
-- Steve