aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/acct.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/acct.c')
-rw-r--r--kernel/acct.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index 44dd6bd63517..b35263137824 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -421,9 +421,9 @@ static u32 encode_float(u64 value)
421 */ 421 */
422static void do_acct_process(long exitcode, struct file *file) 422static void do_acct_process(long exitcode, struct file *file)
423{ 423{
424 struct pacct_struct *pacct = &current->signal->pacct;
424 acct_t ac; 425 acct_t ac;
425 mm_segment_t fs; 426 mm_segment_t fs;
426 unsigned long vsize;
427 unsigned long flim; 427 unsigned long flim;
428 u64 elapsed; 428 u64 elapsed;
429 u64 run_time; 429 u64 run_time;
@@ -505,20 +505,9 @@ static void do_acct_process(long exitcode, struct file *file)
505 ac.ac_flag |= ACORE; 505 ac.ac_flag |= ACORE;
506 if (current->flags & PF_SIGNALED) 506 if (current->flags & PF_SIGNALED)
507 ac.ac_flag |= AXSIG; 507 ac.ac_flag |= AXSIG;
508 508 spin_lock(&current->sighand->siglock);
509 vsize = 0; 509 ac.ac_mem = encode_comp_t(pacct->ac_mem);
510 if (current->mm) { 510 spin_unlock(&current->sighand->siglock);
511 struct vm_area_struct *vma;
512 down_read(&current->mm->mmap_sem);
513 vma = current->mm->mmap;
514 while (vma) {
515 vsize += vma->vm_end - vma->vm_start;
516 vma = vma->vm_next;
517 }
518 up_read(&current->mm->mmap_sem);
519 }
520 vsize = vsize / 1024;
521 ac.ac_mem = encode_comp_t(vsize);
522 ac.ac_io = encode_comp_t(0 /* current->io_usage */); /* %% */ 511 ac.ac_io = encode_comp_t(0 /* current->io_usage */); /* %% */
523 ac.ac_rw = encode_comp_t(ac.ac_io / 1024); 512 ac.ac_rw = encode_comp_t(ac.ac_io / 1024);
524 ac.ac_minflt = encode_comp_t(current->signal->min_flt + 513 ac.ac_minflt = encode_comp_t(current->signal->min_flt +
@@ -546,6 +535,38 @@ static void do_acct_process(long exitcode, struct file *file)
546} 535}
547 536
548/** 537/**
538 * acct_init_pacct - initialize a new pacct_struct
539 */
540void acct_init_pacct(struct pacct_struct *pacct)
541{
542 memset(pacct, 0, sizeof(struct pacct_struct));
543}
544
545/**
546 * acct_collect - collect accounting information into pacct_struct
547 */
548void acct_collect(void)
549{
550 struct pacct_struct *pacct = &current->signal->pacct;
551 unsigned long vsize = 0;
552
553 if (current->mm) {
554 struct vm_area_struct *vma;
555 down_read(&current->mm->mmap_sem);
556 vma = current->mm->mmap;
557 while (vma) {
558 vsize += vma->vm_end - vma->vm_start;
559 vma = vma->vm_next;
560 }
561 up_read(&current->mm->mmap_sem);
562 }
563
564 spin_lock(&current->sighand->siglock);
565 pacct->ac_mem = vsize / 1024;
566 spin_unlock(&current->sighand->siglock);
567}
568
569/**
549 * acct_process - now just a wrapper around do_acct_process 570 * acct_process - now just a wrapper around do_acct_process
550 * @exitcode: task exit code 571 * @exitcode: task exit code
551 * 572 *