From: George Anzinger <george@mvista.com>
To: john stultz <johnstul@us.ibm.com>
Cc: Li Shaohua <shaohua.li@intel.com>,
lkml <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, Pavel Machek <pavel@suse.cz>
Subject: Re: [PATCH]time run too fast after S3
Date: Mon, 22 Nov 2004 10:54:24 -0800 [thread overview]
Message-ID: <41A235E0.8050405@mvista.com> (raw)
In-Reply-To: <1101148405.6735.107.camel@cog.beaverton.ibm.com>
john stultz wrote:
> On Mon, 2004-11-22 at 01:15, Li Shaohua wrote:
>
>>after resume from S3, 'date' shows time run too fast. Here is a patch.
>
> [snip]
>
>>diff -puN arch/i386/kernel/time.c~wall_jiffies arch/i386/kernel/time.c
>>--- 2.6/arch/i386/kernel/time.c~wall_jiffies 2004-11-22 17:04:42.720038352 +0800
>>+++ 2.6-root/arch/i386/kernel/time.c 2004-11-22 17:06:21.373040816 +0800
>>@@ -343,12 +343,13 @@ static int timer_resume(struct sys_devic
>> hpet_reenable();
>> #endif
>> sec = get_cmos_time() + clock_cmos_diff;
>>- sleep_length = get_cmos_time() - sleep_start;
>>+ sleep_length = (get_cmos_time() - sleep_start) * HZ;
>> write_seqlock_irqsave(&xtime_lock, flags);
>> xtime.tv_sec = sec;
>> xtime.tv_nsec = 0;
>> write_sequnlock_irqrestore(&xtime_lock, flags);
>>- jiffies += sleep_length * HZ;
>>+ jiffies += sleep_length;
>>+ wall_jiffies += sleep_length;
>> return 0;
>> }
>
>
> I'm not all that familiar w/ the suspend code, but yea, this looks like
> an improvement. The previous code was wrong because they are setting
> xtime themselves, and then updating only jiffies. At the next timer
> interrupt, the difference between jiffies and wall_jiffies would then be
> added to xtime again.
>
> Why they don't just use do_settimeofday() for all of this is a mystery
> to me. Are we wanting to pretend timer ticks arrived while we were
> suspended?
I think that this way the uptime and start times of init and friends will be
much more correct. settimeofday() would move those around. So, the short
answer is, yes.
--
George Anzinger george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
next prev parent reply other threads:[~2004-11-23 3:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-22 9:15 [PATCH]time run too fast after S3 Li Shaohua
2004-11-22 18:33 ` john stultz
2004-11-22 18:54 ` George Anzinger [this message]
2004-11-22 21:45 ` Nigel Cunningham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41A235E0.8050405@mvista.com \
--to=george@mvista.com \
--cc=akpm@osdl.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
--cc=shaohua.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox