lkml.org 
[lkml]   [2008]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: /proc/data information
    From
    Date
    "Rafael C. de Almeida" <almeidaraf@gmail.com> writes:

    > I'm interested in knowing how the cpu data from /proc/stat is gathered.
    > Following my way from this function:
    >
    > http://lxr.linux.no/linux+v2.6.25.10/fs/proc/proc_misc.c#L459
    >
    > I've figured that the time is probably gathered using those
    > account_*_time on sched.c. I'm not sure where the times are read from,
    > though.

    They are normally (some architectures do it differently to cope with
    virtualized environments) sampled by a regular timer interrupt, which
    runs HZ times per second on each CPU. Common values for HZ is 250
    (2.5ms interval), but you can compile with others too.

    I suspect the effects you're seeing all come from sampling error.
    The interval is also not fully stable because the kernel sometimes
    disables interrupts and that will delay the timer interrupt of course.
    How often this happens depends on the workload.

    Then there are architectures like s390 who do "microstate accounting":
    they keep track instead on every kernel entry/exit and every interrupt.
    That can be more accurate, but is also more costly.

    -Andi


    \
     
     \ /
      Last update: 2008-07-14 18:41    [W:0.023 / U:0.036 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site