linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <johnstul@us.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Regression] Negative time on Acer Ferrari One with current -git
Date: Sun, 23 May 2010 15:21:02 +0200	[thread overview]
Message-ID: <201005231521.02817.rjw@sisk.pl> (raw)
In-Reply-To: <alpine.LFD.2.00.1005230815220.3368@localhost.localdomain>

On Sunday 23 May 2010, Thomas Gleixner wrote:
> On Sat, 22 May 2010, Rafael J. Wysocki wrote:
> > After reverting commit 64ce4c2f above things work again.
> > 
> > To be precise, I reverted both commit 64ce4c2f and commit 6a867a3 (time: 
> > Remove xtime_cache), but since the symptoms continued to apprear after
> > reverting the latter alone, it's quite clear that commit 64ce4c2f breaks things
> > on this box.
> 
> I assume the cmos clock of this machine is not on UTC, right ?

Yup.

> Does the patch below fix the issue ?

Yes, it does, thanks!

> @John: Can you please check the other users of timespec_add_safe() in
> timekeeping as well ?
> 
> Thanks,
> 
> 	tglx
> 
> ---------->
> Subject: timekeeping: Fix timezone update
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Sun, 23 May 2010 08:14:45 +0200
> 
> commit 64ce4c2f (time: Clean up warp_clock()) breaks the timezone
> update in a very subtle way. To avoid the direct access to timekeeping
> internals it adds the timezone delta to the current time with
> timespec_add_safe(). This works nicely when the timezone delta is > 0.
> If timezone delta is < 0 then the wrap check in timespec_add_safe()
> triggers and timespec_add_safe() returns TIME_MAX and screws up
> timekeeping completely. 
> 
> This is not surprising as the comment above timespec_add_safe() says:
>     It's assumed that both values are valid (>= 0)
> 
> The function was created to avoid overflow issues when adding the
> select() timeout to current time, where the above applies.
> 
> Add the timezone seconds adjustment directly.
> 
> Reported-by: Rafael J. Wysocki <rjw@sisk.pl>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  kernel/time.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Index: linux-2.6/kernel/time.c
> ===================================================================
> --- linux-2.6.orig/kernel/time.c
> +++ linux-2.6/kernel/time.c
> @@ -132,10 +132,10 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
>   */
>  static inline void warp_clock(void)
>  {
> -	struct timespec delta, adjust;
> -	delta.tv_sec = sys_tz.tz_minuteswest * 60;
> -	delta.tv_nsec = 0;
> -	adjust = timespec_add_safe(current_kernel_time(), delta);
> +	struct timespec adjust;
> +
> +	adjust = current_kernel_time();
> +	adjust.tv_sec += sys_tz.tz_minuteswest * 60;
>  	do_settimeofday(&adjust);
>  }

Rafael

  reply	other threads:[~2010-05-23 13:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-21 21:43 [Regression] Negative time on Acer Ferrari One with current -git Rafael J. Wysocki
2010-05-21 22:19 ` Linus Torvalds
2010-05-21 22:39   ` john stultz
2010-05-22 17:54     ` Rafael J. Wysocki
2010-05-22 14:05   ` Thomas Gleixner
2010-05-22 14:18     ` Thomas Gleixner
2010-05-22 17:34       ` Rafael J. Wysocki
2010-05-22 17:52         ` Borislav Petkov
2010-05-22 18:00           ` Rafael J. Wysocki
2010-05-22 18:25         ` Thomas Gleixner
2010-05-22 18:32           ` Thomas Gleixner
2010-05-22 20:55             ` Rafael J. Wysocki
2010-05-22 21:20               ` Rafael J. Wysocki
2010-05-23  6:40                 ` Thomas Gleixner
2010-05-23 13:21                   ` Rafael J. Wysocki [this message]
2010-05-23 21:20                   ` john stultz

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=201005231521.02817.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).