lkml.org 
[lkml]   [2009]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [tip:sched/core] sched: Fix granularity of task_u/stime()
On Thu, Nov 12, 2009 at 06:12:41PM +0000, tip-bot for Hidetoshi Seto wrote:
> sched: Fix granularity of task_u/stime()
>
> Originally task_s/utime() were designed to return clock_t but
> later changed to return cputime_t by following commit:
>
> commit efe567fc8281661524ffa75477a7c4ca9b466c63
> Author: Christian Borntraeger <borntraeger@de.ibm.com>
> Date: Thu Aug 23 15:18:02 2007 +0200
>
> It only changed the type of return value, but not the
> implementation. As the result the granularity of task_s/utime()
> is still that of clock_t, not that of cputime_t.
>
> So using task_s/utime() in __exit_signal() makes values
> accumulated to the signal struct to be rounded and coarse
> grained.
>
> This patch removes casts to clock_t in task_u/stime(), to keep
> granularity of cputime_t over the calculation.

Patch make only difference on 64 arch and do not fix the ordinal utime
decreasing problem on 32 bits. Anyway except below nit looks good
for me (but I to be honest I don't understand this {u/s}time adjusting
functions at all).

> - p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime));
> + p->prev_utime = max(p->prev_utime, utime);
> return p->prev_utime;
> }
>
> cputime_t task_stime(struct task_struct *p)
> {
> - clock_t stime;
> + cputime_t stime;
>
> /*
> * Use CFS's precise accounting. (we subtract utime from
> * the total, to make sure the total observed by userspace
> * grows monotonically - apps rely on that):
> */
> - stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
> - cputime_to_clock_t(task_utime(p));
> + stime = nsecs_to_cputime(p->se.sum_exec_runtime) - task_utime(p);
>
> if (stime >= 0)

Since cputime_t is not signed type, we should just remove this or
write something like that:

runtime = nsecs_to_cputime(p->se.sum_exec_runtime);
utime = task_utime(p);
if (cputime_ge(runtime, utime))
p->prev_stime = max(p->prev_stime, runtime - utime);

Stanislaw


\
 
 \ /
  Last update: 2009-11-13 10:45    [W:0.272 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site