Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753225AbdLNUV3 (ORCPT ); Thu, 14 Dec 2017 15:21:29 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:34776 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752690AbdLNUUx (ORCPT ); Thu, 14 Dec 2017 15:20:53 -0500 Smtp-Origin-Hostprefix: devbig From: Teng Qin Smtp-Origin-Hostname: devbig473.prn1.facebook.com To: CC: , , , , , , , Teng Qin Smtp-Origin-Cluster: prn1c29 Subject: [PATCH tip 2/3] Improve sched_process_fork Tracepoint Date: Thu, 14 Dec 2017 12:20:43 -0800 Message-ID: <20171214202044.1629279-3-qinteng@fb.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171214202044.1629279-1-qinteng@fb.com> References: <20171214202044.1629279-1-qinteng@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-14_12:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2245 Lines: 66 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 --- 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