[Devel] [PATCH RH9 15/26] proc connector: use generic event helper for exit event

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Oct 7 15:53:55 MSK 2021


From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

(cherry picked from vz8 commit fa2549935ed5052ddf9d56aae16ac1cbffb68955)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/connector/cn_proc.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index f8c94265639d..23005ca664da 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -244,21 +244,11 @@ void proc_coredump_connector(struct task_struct *task)
 	proc_event_connector(task, PROC_EVENT_COREDUMP, 0, fill_coredump_event);
 }
 
-void proc_exit_connector(struct task_struct *task)
+static bool fill_exit_event(struct proc_event *ev, struct task_struct *task,
+			    int unused)
 {
-	struct cn_msg *msg;
-	struct proc_event *ev;
 	struct task_struct *parent;
-	__u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
 
-	if (atomic_read(&proc_event_num_listeners) < 1)
-		return;
-
-	msg = buffer_to_cn_msg(buffer);
-	ev = (struct proc_event *)msg->data;
-	memset(&ev->event_data, 0, sizeof(ev->event_data));
-	ev->timestamp_ns = ktime_get_ns();
-	ev->what = PROC_EVENT_EXIT;
 	ev->event_data.exit.process_pid = task->pid;
 	ev->event_data.exit.process_tgid = task->tgid;
 	ev->event_data.exit.exit_code = task->exit_code;
@@ -271,12 +261,12 @@ void proc_exit_connector(struct task_struct *task)
 		ev->event_data.exit.parent_tgid = parent->tgid;
 	}
 	rcu_read_unlock();
+	return true;
+}
 
-	memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
-	msg->ack = 0; /* not used */
-	msg->len = sizeof(*ev);
-	msg->flags = 0; /* not used */
-	send_msg(msg);
+void proc_exit_connector(struct task_struct *task)
+{
+	proc_event_connector(task, PROC_EVENT_EXIT, 0, fill_exit_event);
 }
 
 /*
-- 
2.31.1



More information about the Devel mailing list