lkml.org 
[lkml]   [2004]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectincorrect time accouting
While benchmarking, a user pointed out that time(1) reported
incorrect user and system times when running mono.
A typical example (running on 2.6.8.1 is):

$ /usr/bin/time mono so-sieve.exe 5000
Count: 1028
0.02user 0.00system 0:01.97elapsed 1%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (1major+1509minor)pagefaults 0swaps

Where so-sieve.exe is a cpu-bound benchmark.
On 2.6.8.1 very low user and system times are reported every time, while
on both 2.4.19 and 2.2.20 sometimes the correct (or at least sensible)
results are reported, while sometimes very low timings are reported as
well.
top reports high cpu usage and low idle percentages, but with no cpu
time accounted to the mono process.
This looks like a mild security issue, since it appears there is some way
to circumvent the kernel's idea of the cpu resource usage of a process,
so the limits set become useless and users could bog down the system.

http://primates.ximian.com/~lupus/time-strace has the result of
strace -tt -f time /usr/local/bin/mono so-sieve.exe 5000 2> time-strace
The highlights include:

[pid 9630] 19:22:28.609566 execve("/usr/local/bin/mono", ["/usr/local/bin/mono", "so-sieve.exe", "5000"], [/* 33 vars */]) = 0
Pid 9630 is the main process: it creates a thread that will execute the
bulk of the cpu-intensive code (pid 9633):

[pid 9630] 19:22:28.839532 clone(Process 9633 attached child_stack=0x40d17b48, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED, parent_tidptr=0x40d17bf8, {entry_number:6, base_addr:0x40d17bb0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0x40d17bf8) = 9633
The main loop starts here, after some memory allocation:

[pid 9633] 19:22:28.849138 brk(0x82ae000) = 0x82ae000
And it ends about two seconds later, with the next entry in the trace
for the 9633 pid:

[pid 9633] 19:22:30.780451 brk(0) = 0x82ae000
At the end, wait4 is called to collect the times, less than 0.5 sec
user+system:
[pid 9629] 19:22:30.821596 <... wait4 resumed> [WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL], 0, {ru_utime={0, 14997}, ru_stime={0, 1999}, ...}) = 9630

http://primates.ximian.com/~lupus/mono-1.1.1.tar.gz is the mono source,
if you don't have mono installed to reproduce (I tried to reproduce with
a simple pthread program what mono is doing, executing cpu-intensive
code in a subthread, but times are reported correctly there).
http://primates.ximian.com/~lupus/so-sieve.exe is the sample program,
but other programs exibited the same behaviour.
Let me know if more info is needed to track down the problem.

lupus

--
-----------------------------------------------------------------
lupus@debian.org debian/rules
lupus@ximian.com Monkeys do it better
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.027 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site