Commit 5650b736 authored by Matt Helsley's avatar Matt Helsley Committed by Linus Torvalds

[PATCH] Add timestamp field to process events

This adds a timestamp field to the events sent via the process event
connector.  The timestamp allows listeners to accurately account the
duration(s) between a process' events and offers strong means with which
to determine the order of events with respect to a given task while also
avoiding the addition of per-task data.

This alters the size and layout of the event structure and hence would
break compatibility if process events connector as it stands in 2.6.15-rc2
were released as a mainline kernel.
Signed-off-by: default avatarMatt Helsley <matthltc@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 64123fd4
...@@ -56,6 +56,7 @@ void proc_fork_connector(struct task_struct *task) ...@@ -56,6 +56,7 @@ void proc_fork_connector(struct task_struct *task)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
getnstimestamp(&ev->timestamp);
ev->what = PROC_EVENT_FORK; ev->what = PROC_EVENT_FORK;
ev->event_data.fork.parent_pid = task->real_parent->pid; ev->event_data.fork.parent_pid = task->real_parent->pid;
ev->event_data.fork.parent_tgid = task->real_parent->tgid; ev->event_data.fork.parent_tgid = task->real_parent->tgid;
...@@ -81,6 +82,7 @@ void proc_exec_connector(struct task_struct *task) ...@@ -81,6 +82,7 @@ void proc_exec_connector(struct task_struct *task)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
getnstimestamp(&ev->timestamp);
ev->what = PROC_EVENT_EXEC; ev->what = PROC_EVENT_EXEC;
ev->event_data.exec.process_pid = task->pid; ev->event_data.exec.process_pid = task->pid;
ev->event_data.exec.process_tgid = task->tgid; ev->event_data.exec.process_tgid = task->tgid;
...@@ -114,6 +116,7 @@ void proc_id_connector(struct task_struct *task, int which_id) ...@@ -114,6 +116,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
} else } else
return; return;
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
getnstimestamp(&ev->timestamp);
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
...@@ -133,6 +136,7 @@ void proc_exit_connector(struct task_struct *task) ...@@ -133,6 +136,7 @@ void proc_exit_connector(struct task_struct *task)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
getnstimestamp(&ev->timestamp);
ev->what = PROC_EVENT_EXIT; ev->what = PROC_EVENT_EXIT;
ev->event_data.exit.process_pid = task->pid; ev->event_data.exit.process_pid = task->pid;
ev->event_data.exit.process_tgid = task->tgid; ev->event_data.exit.process_tgid = task->tgid;
...@@ -165,6 +169,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack) ...@@ -165,6 +169,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
msg->seq = rcvd_seq; msg->seq = rcvd_seq;
getnstimestamp(&ev->timestamp);
ev->cpu = -1; ev->cpu = -1;
ev->what = PROC_EVENT_NONE; ev->what = PROC_EVENT_NONE;
ev->event_data.ack.err = err; ev->event_data.ack.err = err;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define CN_PROC_H #define CN_PROC_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/time.h>
#include <linux/connector.h> #include <linux/connector.h>
/* /*
...@@ -65,6 +66,7 @@ struct proc_event { ...@@ -65,6 +66,7 @@ struct proc_event {
PROC_EVENT_EXIT = 0x80000000 PROC_EVENT_EXIT = 0x80000000
} what; } what;
__u32 cpu; __u32 cpu;
struct timespec timestamp;
union { /* must be last field of proc_event struct */ union { /* must be last field of proc_event struct */
struct { struct {
__u32 err; __u32 err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment