lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 14 Dec 2017 12:20:44 -0800
From:   Teng Qin <qinteng@...com>
To:     <peterz@...radead.org>
CC:     <mingo@...hat.com>, <ast@...com>, <bgregg@...flix.com>,
        <daniel@...earbox.net>, <yhs@...com>,
        <linux-kernel@...r.kernel.org>, <Kernel-team@...com>,
        Teng Qin <qinteng@...com>
Subject: [PATCH tip 3/3] Improve sched_process_exit Tracepoint

This commit adds group_dead value to sched_process_exit's Tracepoint
struct. The value is passed as an argument of the Tracepoint. It is
useful to differentiate exits of a regular process or the last process
of the process group.

This commit also exposes pointers of exited task. BPF program can read task
information via task struct pointer. Exposing the pointer explicitly gives
BPF programs an easy and reliable way of using the Tracepoint.

Signed-off-by: Teng Qin <qinteng@...com>
---
 include/trace/events/sched.h | 37 +++++++++++++++++++++++++++++--------
 kernel/exit.c                |  2 +-
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index e8bb6b0..c741f4e 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -204,6 +204,35 @@ TRACE_EVENT(sched_migrate_task,
 		  __entry->orig_cpu, __entry->dest_cpu)
 );
 
+/*
+ * Tracepoint for a task exiting:
+ */
+TRACE_EVENT(sched_process_exit,
+
+	TP_PROTO(struct task_struct *p, bool group_dead),
+
+	TP_ARGS(p, group_dead),
+
+	TP_STRUCT__entry(
+		__array(	char,	comm,	TASK_COMM_LEN	)
+		__field(	pid_t,	pid			)
+		__field(	int,	prio			)
+		__field(	bool,	group_dead		)
+		__field(	void *,	task_struct		)
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+		__entry->pid		= p->pid;
+		__entry->prio		= p->prio;
+		__entry->group_dead	= group_dead;
+		__entry->task_struct	= (void *)p;
+	),
+
+	TP_printk("comm=%s pid=%d prio=%d",
+		  __entry->comm, __entry->pid, __entry->prio)
+);
+
 DECLARE_EVENT_CLASS(sched_process_template,
 
 	TP_PROTO(struct task_struct *p),
@@ -233,14 +262,6 @@ DEFINE_EVENT(sched_process_template, sched_process_free,
 	     TP_PROTO(struct task_struct *p),
 	     TP_ARGS(p));
 	     
-
-/*
- * Tracepoint for a task exiting:
- */
-DEFINE_EVENT(sched_process_template, sched_process_exit,
-	     TP_PROTO(struct task_struct *p),
-	     TP_ARGS(p));
-
 /*
  * Tracepoint for waiting on task to unschedule:
  */
diff --git a/kernel/exit.c b/kernel/exit.c
index 6b4298a..b613594 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -853,7 +853,7 @@ void __noreturn do_exit(long code)
 
 	if (group_dead)
 		acct_process();
-	trace_sched_process_exit(tsk);
+	trace_sched_process_exit(tsk, group_dead);
 
 	exit_sem(tsk);
 	exit_shm(tsk);
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ