[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.2 / 0089-fix-cputime-overflow-in-uptime_proc_show.patch
1 From 36934c4efd11c4f65dd956b2a6649d99ccf5bd86 Mon Sep 17 00:00:00 2001
2 From: Martin Schwidefsky <schwidefsky@de.ibm.com>
3 Date: Thu, 15 Dec 2011 14:56:10 +0100
4 Subject: [PATCH 089/129] fix cputime overflow in uptime_proc_show
6 commit c3e0ef9a298e028a82ada28101ccd5cf64d209ee upstream.
8 For 32-bit architectures using standard jiffies the idletime calculation
9 in uptime_proc_show will quickly overflow. It takes (2^32 / HZ) seconds
10 of idle-time, or e.g. 12.45 days with no load on a quad-core with HZ=1000.
11 Switch to 64-bit calculations.
13 Cc: Michael Abbott <michael.abbott@diamond.ac.uk>
14 Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16 ---
17 fs/proc/uptime.c | 9 +++++++--
18 1 file changed, 7 insertions(+), 2 deletions(-)
20 diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
21 index 766b1d4..29166ec 100644
22 --- a/fs/proc/uptime.c
23 +++ b/fs/proc/uptime.c
24 @@ -11,15 +11,20 @@ static int uptime_proc_show(struct seq_file *m, void *v)
25 {
26 struct timespec uptime;
27 struct timespec idle;
28 + cputime64_t idletime;
29 + u64 nsec;
30 + u32 rem;
31 int i;
32 - cputime_t idletime = cputime_zero;
34 + idletime = 0;
35 for_each_possible_cpu(i)
36 idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
38 do_posix_clock_monotonic_gettime(&uptime);
39 monotonic_to_bootbased(&uptime);
40 - cputime_to_timespec(idletime, &idle);
41 + nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
42 + idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
43 + idle.tv_nsec = rem;
44 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
45 (unsigned long) uptime.tv_sec,
46 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
47 --
48 1.7.9.5