aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/acct.c
diff options
context:
space:
mode:
authorKaiGai Kohei <kaigai@ak.jp.nec.com>2006-06-25 08:49:24 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:25 -0400
commit0e4648141af02331f21aabcd34940c70f09a2d04 (patch)
tree3e4dea992a8e3f3194be04a0fd3e14c24a313ee7 /kernel/acct.c
parent6bc392741d661eb84be503d1fdf14b6746615e4c (diff)
[PATCH] pacct: add pacct_struct to fix some pacct bugs.
The pacct facility need an i/o operation when an accounting record is generated. There is a possibility to wake OOM killer up. If OOM killer is activated, it kills some processes to make them release process memory regions. But acct_process() is called in the killed processes context before calling exit_mm(), so those processes cannot release own memory. In the results, any processes stop in this point and it finally cause a system stall.
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 *