summaryrefslogtreecommitdiffstats
path: root/fs/proc/uptime.c
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2011-12-15 14:56:10 +0100
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2011-12-15 14:56:19 +0100
commitc3e0ef9a298e028a82ada28101ccd5cf64d209ee (patch)
tree6a03a5df3e33ccdfda9b0794eef364afe36211f6 /fs/proc/uptime.c
parent648616343cdbe904c585a6c12e323d3b3c72e46f (diff)
downloadlinux-c3e0ef9a298e028a82ada28101ccd5cf64d209ee.tar.bz2
[S390] fix cputime overflow in uptime_proc_show
For 32-bit architectures using standard jiffies the idletime calculation in uptime_proc_show will quickly overflow. It takes (2^32 / HZ) seconds of idle-time, or e.g. 12.45 days with no load on a quad-core with HZ=1000. Switch to 64-bit calculations. Cc: stable@vger.kernel.org Cc: Michael Abbott <michael.abbott@diamond.ac.uk> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'fs/proc/uptime.c')
-rw-r--r--fs/proc/uptime.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
index ac5243657da3..ab515109fec9 100644
--- a/fs/proc/uptime.c
+++ b/fs/proc/uptime.c
@@ -11,15 +11,20 @@ static int uptime_proc_show(struct seq_file *m, void *v)
{
struct timespec uptime;
struct timespec idle;
+ cputime64_t idletime;
+ u64 nsec;
+ u32 rem;
int i;
- cputime_t idletime = 0;
+ idletime = 0;
for_each_possible_cpu(i)
idletime += kstat_cpu(i).cpustat.idle;
do_posix_clock_monotonic_gettime(&uptime);
monotonic_to_bootbased(&uptime);
- cputime_to_timespec(idletime, &idle);
+ nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
+ idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
+ idle.tv_nsec = rem;
seq_printf(m, "%lu.%02lu %lu.%02lu\n",
(unsigned long) uptime.tv_sec,
(uptime.tv_nsec / (NSEC_PER_SEC / 100)),