• KaiGai Kohei's avatar
    [PATCH] Fix pacct bug in multithreading case. · bb231fe3
    KaiGai Kohei authored
    I noticed a bug on the process accounting facility.  In multi-threading
    process, some data would be recorded incorrectly when the group_leader dies
    earlier than one or more threads.  The attached patch fixes this problem.
    
    See below.  'bugacct' is a test program that create a worker thread after 4
    seconds sleeping, then the group_leader dies soon.  The worker thread
    consume CPU/Memory for 6 seconds, then exit.  We can estimate 10 seconds as
    etime and 6 seconds as stime + utime.  This is a sample program which the
    group_leader dies earlier than other threads.
    
    The results of same binary execution on different kernel are below.
    -- accounted records --------------------
             |   btime  | utime | stime | etime | minflt | majflt |   comm  |
    original | 13:16:40 |  0.00 |  0.00 |  6.10 |    171 |      0 | bugacct |
     patched | 13:20:21 |  5.83 |  0.18 | 10.03 |  32776 |      0 | bugacct |
    (*) bugacct allocates 128MB memory, thus 128MB / 4KB = 32768 of minflt is
      ...
    bb231fe3
acct.c 15.8 KB