This commit adds value of the clone_flag to sched_process_fork's Tracepoint struct. The value is passed as an argument of the Tracepoint. It is useful when debugging Processes created via different clone flags.
This commit also exposes pointers of the parent and child task_struct in the Tracepoint's struct. BPF programs can read task information via task struct pointer. Exposing these pointers explicitly gives BPF programs an easy and reliable way of using the Tracepoint. Signed-off-by: Teng Qin <[email protected]> --- include/trace/events/sched.h | 11 +++++++++-- kernel/fork.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 9297b33..e8bb6b0 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -278,15 +278,19 @@ TRACE_EVENT(sched_process_wait, */ TRACE_EVENT(sched_process_fork, - TP_PROTO(struct task_struct *parent, struct task_struct *child), + TP_PROTO(struct task_struct *parent, struct task_struct *child, + unsigned long clone_flags), - TP_ARGS(parent, child), + TP_ARGS(parent, child, clone_flags), TP_STRUCT__entry( __array( char, parent_comm, TASK_COMM_LEN ) __field( pid_t, parent_pid ) __array( char, child_comm, TASK_COMM_LEN ) __field( pid_t, child_pid ) + __field( unsigned long, clone_flags ) + __field( void *, parent_task ) + __field( void *, child_task ) ), TP_fast_assign( @@ -294,6 +298,9 @@ TRACE_EVENT(sched_process_fork, __entry->parent_pid = parent->pid; memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN); __entry->child_pid = child->pid; + __entry->clone_flags = clone_flags; + __entry->parent_task = (void *)parent; + __entry->child_task = (void *)child; ), TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d", diff --git a/kernel/fork.c b/kernel/fork.c index 432eadf..777985e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2053,7 +2053,7 @@ long _do_fork(unsigned long clone_flags, struct completion vfork; struct pid *pid; - trace_sched_process_fork(current, p); + trace_sched_process_fork(current, p, clone_flags); pid = get_task_pid(p, PIDTYPE_PID); nr = pid_vnr(pid); -- 2.9.5

