[PATCH] rcu: Mention rcu_bh in description of rcutorture's torture_type parameter
[linux-2.6.git] / kernel / acct.c
index 4c85fdf..0aad5ca 100644 (file)
@@ -43,7 +43,6 @@
  * a struct file opened for write. Fixed. 2/6/2000, AV.
  */
 
-#include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/acct.h>
@@ -428,7 +427,6 @@ static void do_acct_process(struct file *file)
        u64 elapsed;
        u64 run_time;
        struct timespec uptime;
-       unsigned long jiffies;
 
        /*
         * First check to see if there is enough free_space to continue
@@ -469,12 +467,6 @@ static void do_acct_process(struct file *file)
 #endif
        do_div(elapsed, AHZ);
        ac.ac_btime = xtime.tv_sec - elapsed;
-       jiffies = cputime_to_jiffies(cputime_add(current->utime,
-                                                current->signal->utime));
-       ac.ac_utime = encode_comp_t(jiffies_to_AHZ(jiffies));
-       jiffies = cputime_to_jiffies(cputime_add(current->stime,
-                                                current->signal->stime));
-       ac.ac_stime = encode_comp_t(jiffies_to_AHZ(jiffies));
        /* we really need to bite the bullet and change layout */
        ac.ac_uid = current->uid;
        ac.ac_gid = current->gid;
@@ -491,22 +483,26 @@ static void do_acct_process(struct file *file)
        ac.ac_ppid = current->parent->tgid;
 #endif
 
-       read_lock(&tasklist_lock);      /* pin current->signal */
+       mutex_lock(&tty_mutex);
+       /* FIXME: Whoever is responsible for current->signal locking needs
+          to use the same locking all over the kernel and document it */
+       read_lock(&tasklist_lock);
        ac.ac_tty = current->signal->tty ?
                old_encode_dev(tty_devnum(current->signal->tty)) : 0;
        read_unlock(&tasklist_lock);
+       mutex_unlock(&tty_mutex);
 
-       spin_lock(&current->sighand->siglock);
+       spin_lock_irq(&current->sighand->siglock);
+       ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
+       ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime)));
        ac.ac_flag = pacct->ac_flag;
        ac.ac_mem = encode_comp_t(pacct->ac_mem);
+       ac.ac_minflt = encode_comp_t(pacct->ac_minflt);
+       ac.ac_majflt = encode_comp_t(pacct->ac_majflt);
        ac.ac_exitcode = pacct->ac_exitcode;
-       spin_unlock(&current->sighand->siglock);
+       spin_unlock_irq(&current->sighand->siglock);
        ac.ac_io = encode_comp_t(0 /* current->io_usage */);    /* %% */
        ac.ac_rw = encode_comp_t(ac.ac_io / 1024);
-       ac.ac_minflt = encode_comp_t(current->signal->min_flt +
-                                    current->min_flt);
-       ac.ac_majflt = encode_comp_t(current->signal->maj_flt +
-                                    current->maj_flt);
        ac.ac_swaps = encode_comp_t(0);
 
        /*
@@ -528,10 +524,12 @@ static void do_acct_process(struct file *file)
 
 /**
  * acct_init_pacct - initialize a new pacct_struct
+ * @pacct: per-process accounting info struct to initialize
  */
 void acct_init_pacct(struct pacct_struct *pacct)
 {
        memset(pacct, 0, sizeof(struct pacct_struct));
+       pacct->ac_utime = pacct->ac_stime = cputime_zero;
 }
 
 /**
@@ -555,7 +553,7 @@ void acct_collect(long exitcode, int group_dead)
                up_read(&current->mm->mmap_sem);
        }
 
-       spin_lock(&current->sighand->siglock);
+       spin_lock_irq(&current->sighand->siglock);
        if (group_dead)
                pacct->ac_mem = vsize / 1024;
        if (thread_group_leader(current)) {
@@ -569,7 +567,11 @@ void acct_collect(long exitcode, int group_dead)
                pacct->ac_flag |= ACORE;
        if (current->flags & PF_SIGNALED)
                pacct->ac_flag |= AXSIG;
-       spin_unlock(&current->sighand->siglock);
+       pacct->ac_utime = cputime_add(pacct->ac_utime, current->utime);
+       pacct->ac_stime = cputime_add(pacct->ac_stime, current->stime);
+       pacct->ac_minflt += current->min_flt;
+       pacct->ac_majflt += current->maj_flt;
+       spin_unlock_irq(&current->sighand->siglock);
 }
 
 /**
@@ -578,7 +580,7 @@ void acct_collect(long exitcode, int group_dead)
  *
  * handles process accounting for an exiting task
  */
-void acct_process()
+void acct_process(void)
 {
        struct file *file = NULL;
 
@@ -600,33 +602,3 @@ void acct_process()
        do_acct_process(file);
        fput(file);
 }
-
-
-/**
- * acct_update_integrals - update mm integral fields in task_struct
- * @tsk: task_struct for accounting
- */
-void acct_update_integrals(struct task_struct *tsk)
-{
-       if (likely(tsk->mm)) {
-               long delta =
-                       cputime_to_jiffies(tsk->stime) - tsk->acct_stimexpd;
-
-               if (delta == 0)
-                       return;
-               tsk->acct_stimexpd = tsk->stime;
-               tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm);
-               tsk->acct_vm_mem1 += delta * tsk->mm->total_vm;
-       }
-}
-
-/**
- * acct_clear_integrals - clear the mm integral fields in task_struct
- * @tsk: task_struct whose accounting fields are cleared
- */
-void acct_clear_integrals(struct task_struct *tsk)
-{
-       tsk->acct_stimexpd = 0;
-       tsk->acct_rss_mem1 = 0;
-       tsk->acct_vm_mem1 = 0;
-}