* [PATCH -tip] timekeeping: fix getboottime() sets invalid value
@ 2009-08-25 6:08 Hiroshi Shimamoto
2009-08-25 7:13 ` [tip:timers/core] timekeeping: Fix invalid getboottime() value tip-bot for Hiroshi Shimamoto
0 siblings, 1 reply; 2+ messages in thread
From: Hiroshi Shimamoto @ 2009-08-25 6:08 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Ingo Molnar, Martin Schwidefsky, John Stultz, Daniel Walker,
linux-kernel
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Don't use timespec_add_safe() with wall_to_monotonic, because wall_to_monotonic
has negative values which will cause overflow in timespec_add_safe().
That makes btime in /proc/stat invalid.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
kernel/time/timekeeping.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 03cbeb3..fb0f46f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -826,9 +826,11 @@ void update_wall_time(void)
*/
void getboottime(struct timespec *ts)
{
- struct timespec boottime;
+ struct timespec boottime = {
+ .tv_sec = wall_to_monotonic.tv_sec + total_sleep_time.tv_sec,
+ .tv_nsec = wall_to_monotonic.tv_nsec + total_sleep_time.tv_nsec
+ };
- boottime = timespec_add_safe(wall_to_monotonic, total_sleep_time);
set_normalized_timespec(ts, -boottime.tv_sec, -boottime.tv_nsec);
}
--
1.6.3.3
^ permalink raw reply [flat|nested] 2+ messages in thread* [tip:timers/core] timekeeping: Fix invalid getboottime() value
2009-08-25 6:08 [PATCH -tip] timekeeping: fix getboottime() sets invalid value Hiroshi Shimamoto
@ 2009-08-25 7:13 ` tip-bot for Hiroshi Shimamoto
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Hiroshi Shimamoto @ 2009-08-25 7:13 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, johnstul, schwidefsky, h-shimamoto,
dwalker, tglx, mingo
Commit-ID: 36d47481b3824b661b464077db95d447984df799
Gitweb: http://git.kernel.org/tip/36d47481b3824b661b464077db95d447984df799
Author: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
AuthorDate: Tue, 25 Aug 2009 15:08:30 +0900
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 25 Aug 2009 09:09:02 +0200
timekeeping: Fix invalid getboottime() value
Don't use timespec_add_safe() with wall_to_monotonic, because
wall_to_monotonic has negative values which will cause overflow
in timespec_add_safe(). That makes btime in /proc/stat invalid.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Daniel Walker <dwalker@fifo99.com>
LKML-Reference: <4A937FDE.4050506@ct.jp.nec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/time/timekeeping.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 03cbeb3..fb0f46f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -826,9 +826,11 @@ void update_wall_time(void)
*/
void getboottime(struct timespec *ts)
{
- struct timespec boottime;
+ struct timespec boottime = {
+ .tv_sec = wall_to_monotonic.tv_sec + total_sleep_time.tv_sec,
+ .tv_nsec = wall_to_monotonic.tv_nsec + total_sleep_time.tv_nsec
+ };
- boottime = timespec_add_safe(wall_to_monotonic, total_sleep_time);
set_normalized_timespec(ts, -boottime.tv_sec, -boottime.tv_nsec);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-25 7:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-25 6:08 [PATCH -tip] timekeeping: fix getboottime() sets invalid value Hiroshi Shimamoto
2009-08-25 7:13 ` [tip:timers/core] timekeeping: Fix invalid getboottime() value tip-bot for Hiroshi Shimamoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®