summaryrefslogtreecommitdiff
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2004-10-25 04:18:37 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-25 04:18:37 -0700
commitdd8e157f46d3779c7d72ac44835e5845081bb11c (patch)
tree0838e233c4d90146de0750e7d343211ad770ef5f /kernel/fork.c
parentaf8b3bb25ac618287de88644ed4d97c535658b04 (diff)
[PATCH] acct: report single record for multithreaded process
This patch changes process accounting to write just one record for a process with many NPTL threads, rather than one record for each thread. No record is written until the last thread exits. The process's record shows the cumulative time of all the threads that ever lived in that process (thread group). This seems like the clearly right thing and I assume it is what anyone using process accounting really would like to see. There is a race condition between multiple threads exiting at the same time to decide which one should write the accounting record. I couldn't think of anything clever using existing bookkeeping that would get this right, so I added another counter for this. (There may be some potential to clean up existing places that figure out how many non-zombie threads are in the group, now that this count is available.) Signed-off-by: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 7d9cd6f7b278..d3bf2ae0c08c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -718,6 +718,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
if (clone_flags & CLONE_THREAD) {
atomic_inc(&current->signal->count);
+ atomic_inc(&current->signal->live);
return 0;
}
sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
@@ -725,6 +726,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
if (!sig)
return -ENOMEM;
atomic_set(&sig->count, 1);
+ atomic_set(&sig->live, 1);
sig->group_exit = 0;
sig->group_exit_code = 0;
sig->group_exit_task = NULL;