Re: [Patch] Re: Nasty suprise with uptime

Andreas Dilger
2001-11-02T01:24:45Z

On Nov 02, 2001 01:28 +0100, Tim Schmielau wrote:
> Well, I did the next patch without waiting for progress on the stability
> front (fsck still in heavy use here). As an excercise I added proper
> locking to get_jiffies64().

Looks good.

> idle = init_tasks[0]->times.tms_utime + init_tasks[0]->times.tms_stime;
> [snip]
> */
> #if HZ!=100
> len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
> - uptime / HZ,
> - (((uptime % HZ) * 100) / HZ) % 100,
> + (unsigned long) uptime,
> + (remainder * 100) / HZ,
> idle / HZ,
> (((idle % HZ) * 100) / HZ) % 100);

Probably need to make idle a 64-bit value as well, even if the individual
items are not, just to avoid potential overflow... Calling do_div(idle,HZ)
may end up being just as fast as the hoops we jump through above to calculate
the fractions (2 divides, 2 modulus, and one multiply).

Cheers, Andreas
--
Andreas Dilger