Re: Decreasing stime running confuses top

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Chuck Ebbert
Date: Thursday, October 4, 2007 - 1:21 pm

On 10/04/2007 04:00 PM, Christian Borntraeger wrote:

The code in fs/proc/array.c is... interesting.

1. task_stime() converts p->se.sum_exec_runtime to a clock_t

2. it calls task_utime() which does the same thing (can it change
   between the two reads?), does some calculations that yield a 
   clock_t, turns the result into a cputime and returns that

3. task_stime() then converts that result back into a clock_t and
   uses it!


static cputime_t task_stime(struct task_struct *p)
{
        clock_t stime;

        stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
                        cputime_to_clock_t(task_utime(p));

        return clock_t_to_cputime(stime);
}

static cputime_t task_utime(struct task_struct *p)
{
        clock_t utime = cputime_to_clock_t(p->utime),
                total = utime + cputime_to_clock_t(p->stime);
        u64 temp;

        temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime);

        if (total) {
                temp *= utime;
                do_div(temp, total);
        }
        utime = (clock_t)temp;

        return clock_t_to_cputime(utime);
}
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
top displaying 9999% CPU usage, Frans Pop, (Wed Oct 3, 5:33 am)
Re: top displaying 9999% CPU usage, Jan Engelhardt, (Wed Oct 3, 5:52 am)
Re: top displaying 9999% CPU usage, Alexander E. Patrakov, (Wed Oct 3, 6:03 am)
Re: top displaying 9999% CPU usage, Frans Pop, (Wed Oct 3, 7:04 am)
Re: top displaying 9999% CPU usage, Ilpo Järvinen, (Wed Oct 3, 7:43 am)
Re: top displaying 9999% CPU usage, Ilpo Järvinen, (Wed Oct 3, 7:51 am)
Re: Decreasing stime running confuses top, Chuck Ebbert, (Thu Oct 4, 12:32 pm)
Re: Decreasing stime running confuses top, Christian Borntraeger, (Thu Oct 4, 1:00 pm)
Re: Decreasing stime running confuses top, Chuck Ebbert, (Thu Oct 4, 1:21 pm)
[PATCH for testing] Re: Decreasing stime running confuses top, Christian Borntraeger, (Thu Oct 4, 2:10 pm)
Re: [PATCH for testing] Re: Decreasing stime running confu ..., Christian Borntraeger, (Thu Oct 4, 3:31 pm)
Re: [PATCH for testing] Re: Decreasing stime running confu ..., Christian Borntraeger, (Mon Oct 8, 9:49 am)