[PATCH] process accounting: take original leader's start_time in non-leader exec
[sfrench/cifs-2.6.git] / fs / exec.c
index 4d38ad0b70d641ce655cd0c01daa316d22ef107e..3234a0c32d5405bdfd8f46f97cd97994e93828ee 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -678,6 +678,18 @@ static int de_thread(struct task_struct *tsk)
                while (leader->exit_state != EXIT_ZOMBIE)
                        yield();
 
                while (leader->exit_state != EXIT_ZOMBIE)
                        yield();
 
+               /*
+                * The only record we have of the real-time age of a
+                * process, regardless of execs it's done, is start_time.
+                * All the past CPU time is accumulated in signal_struct
+                * from sister threads now dead.  But in this non-leader
+                * exec, nothing survives from the original leader thread,
+                * whose birth marks the true age of this process now.
+                * When we take on its identity by switching to its PID, we
+                * also take its birthdate (always earlier than our own).
+                */
+               current->start_time = leader->start_time;
+
                spin_lock(&leader->proc_lock);
                spin_lock(&current->proc_lock);
                proc_dentry1 = proc_pid_unhash(current);
                spin_lock(&leader->proc_lock);
                spin_lock(&current->proc_lock);
                proc_dentry1 = proc_pid_unhash(current);