2013-03-12 2 views
2

나는 taskstats 구조체의 통계가 합산되는 방법을 파악하려고합니다. IO를하고 종료하는 간단한 C 프로그램을 작성했습니다. taskstats netlink 멀티 캐스트 그룹에서 얻은 taskstats 구조체를 사용하여이 프로그램의 통계를 모니터합니다. I는 cpu_delay_total, blkio_delay_total, swapin_delay_total, freepages_delay_total, ac_utimeac_stime의 값을 합계하면, I는 경과 시간의 값보다 약 0.5 초 정도 큰 값을 얻을 여기 (ac_etime)taskstats stats are added up

은 3.5 초 통계는 실행

ac_etime: 3536036 ac_utime: 172000 ac_stime: 3032000 cpu_delay_total: 792528445 blkio_delay_total: 46320128 swapin_delay_total: 0 etime3536036 동안

, 지연 utime의 수율 및 STIME 4042848.573 (마이크로 변환 1000에 의해 지연 나누기) 값을 합산! ac_utime + ac_stime: 3204000

가 taskstats.h의 댓글이 명확하게한다고 것을에도 불구하고 cpu_run_real_total 필드, CPU 시간을주지 않지만, cpu_run_real_total: 3204000129 :

흥미롭게도, 벽 시계 시간은 + STIME을 UTIME하기 위해 실질적으로 동일 값을 제공합니다 이건 벽시계 야? 그리고 이들 필드의 합이 경과 시간보다 큰 이유는 무엇일까요?

내 커널 버전은 3.2.0-38입니다.

답변

0

(1) cpu_run_real_total = ac_utime + ac_stime, 내가 ./kernel/delayacct.c의 코드를 확인, 기능 __delayacct_add_tsk() :

위의 코드에서
tmp = (s64)d->cpu_run_real_total; 
cputime_to_timespec(tsk->utime + tsk->stime, &ts); 
tmp += timespec_to_ns(&ts); 
d->cpu_run_real_total = (tmp < (s64)d->cpu_run_real_total) ? 0 : tmp; 

, 우리가 cpu_run_real_total는 utime와 합 알고 그리고 stime up.

(2) 왜 cpu_delay_total, blkio_delay_total, swapin_delay_total, freepages_delay_total, ac_utime 및 ac_stime의 값을 합산 할 때 값이 ac_etime의 값보다 큰지?

나는 이유를 알아 내지 못했습니다. 그러나 나는 짐작한다 : stime은 다양한 * _delay_total 카운터와 다소 겹칠 수있다.