Commit fe52f966 authored by Prasanna Meda's avatar Prasanna Meda Committed by Linus Torvalds

[PATCH] fork: total_forks not counted under tasklist_lock

Bring the total_forks under tasklist_lock.  When most of the fork code
icluding nr_threads is moved to copy_process() from do_fork() code in 2.6,
this is left out.

Althought accuracy of total_forks is not important, it would be nice to add
this.  It does not involve additional cost, and the code will be cleaner if
it is grouped with nr_threads.  The difference is, total_forks will
increase on fork, but nr_threads will increase on fork and decrease on the
exit.

I also moved extern decleration to sched.h from proc_misc.c.
Signed-off-by: default avatarPrasanna Meda <pmeda@akamai.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bb51bc59
......@@ -322,7 +322,6 @@ static struct file_operations proc_slabinfo_operations = {
int show_stat(struct seq_file *p, void *v)
{
int i;
extern unsigned long total_forks;
unsigned long jif;
u64 sum = 0, user = 0, nice = 0, system = 0,
idle = 0, iowait = 0, irq = 0, softirq = 0;
......
......@@ -88,6 +88,7 @@ extern unsigned long avenrun[]; /* Load averages */
#define CT_TO_SECS(x) ((x) / HZ)
#define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ)
extern unsigned long total_forks;
extern int nr_threads;
extern int last_pid;
DECLARE_PER_CPU(unsigned long, process_counts);
......
......@@ -48,13 +48,13 @@
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
/* The idle threads do not count..
* Protected by write_lock_irq(&tasklist_lock)
/*
* Protected counters by write_lock_irq(&tasklist_lock)
*/
int nr_threads;
int max_threads;
unsigned long total_forks; /* Handle normal Linux uptimes. */
int nr_threads; /* The idle threads do not count.. */
int max_threads; /* tunable limit on nr_threads */
DEFINE_PER_CPU(unsigned long, process_counts) = 0;
......@@ -1035,6 +1035,7 @@ static task_t *copy_process(unsigned long clone_flags,
}
nr_threads++;
total_forks++;
write_unlock_irq(&tasklist_lock);
retval = 0;
......@@ -1167,7 +1168,6 @@ long do_fork(unsigned long clone_flags,
wake_up_new_task(p, clone_flags);
else
p->state = TASK_STOPPED;
++total_forks;
if (unlikely (trace)) {
current->ptrace_message = pid;
......
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