Bug 815958

Summary: time not corrected when system is suspended during DST switch
Product: [openSUSE] openSUSE 12.3 Reporter: Ulrich Windl <Ulrich.Windl>
Component: BasesystemAssignee: Susanne Oberhauser-Hirschoff <froh>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: crrodriguez, ddobrev, froh, msvec
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 12.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Ulrich Windl 2013-04-18 13:58:03 UTC
User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0

When a system was suspended (to disk) before swicth to daylight-saving-time (DST), and it is resumed after DST, the clock is not corrected. (Windows/XP seems able to do that, in contrast)

Reproducible: Didn't try

Steps to Reproduce:
1. Suspend your system at maybe UTC+0100
2. Resume your system at maybe UTC+0200

Actual Results:  
Clock is one hour behind

Expected Results:  
Clock is corrected

As there's a dual-boot system with Windows/XP also, the CMOS clock is using local time.
Comment 1 Susanne Oberhauser-Hirschoff 2013-04-22 10:25:38 UTC
What is your /etc/sysconfig/clock setting of HWCLOCK?
Comment 2 Ulrich Windl 2013-04-22 11:51:11 UTC
It's (copied by typing)
SYSTOHC=""
TIMEZONE="Europe/Berlin"
FORCE_SYSTOHC="no"
BADYEAR="no"
SYSTOHC_DEVICE=""
USE_HWCLOCK="yes"
USE_ADJUST="no"
Comment 3 Susanne Oberhauser-Hirschoff 2013-04-22 15:41:23 UTC
hm.  this is not a 12.1 system is it?

according to https://www.suse.com/releasenotes/x86_64/openSUSE/12.2/
the info from HWCLOCK has moved to /etc/adjtime, as described e.g. here

http://forums.opensuse.org/blogs/jdmcdaniel3/what-utc-gmt-time-possible-issue-opensuse-12-2-its-solution-116/

If that file does not exist on your install, you have been hit by bug#779440
Comment 4 Ulrich Windl 2013-04-23 06:17:31 UTC
On comment #3: Actually I upgraded the system from 12.1 to 12.3 after having reported the bug (hoping for improvement). My current /etc/adjtime has:
---
0.0 0 0.0
0
LOCAL
---
Comment 5 Susanne Oberhauser-Hirschoff 2013-04-23 12:20:52 UTC
ok the topic is messy.  the proper fix, teaching windows to take the hardware clock in utc, seems to be there but not perfect yet:

http://www.cl.cam.ac.uk/~mgk25/mswish/ut-rtc.html


Vojtech,

on SUSE, it looks to me, the kernel is by default storing and restoring time from hwclock at hibernate/resume.  looking at the kernel source, it will do that using UTC, not some local time.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/rtc

esp. class.c and rtc-lib.c

which btw also means:  never ever boot windows on a hibernated machine...


on the other hand, at some point preparations had been made to explicitely sync the hardware clock with the system clock at suspend/resume:

https://gitorious.org/opensuse/pm-utils/blobs/master/pm/sleep.d/90clock

do you think that should be the hook to use for the case hwclock is set to local time?
Comment 6 Vojtech Dziewiecki 2013-04-26 13:05:04 UTC
I'm not sure, it just calls hwclock --systohc and hwclock --hctosys. This probably has the same effect as the kernel function, that's why the hook has this line:


is_set "$NEED_CLOCK_SYNC" || exit $NA

Which means it isn't used at all.
Comment 7 Susanne Oberhauser-Hirschoff 2013-04-29 14:38:08 UTC
good that you came to the same conclusion that the script does nothing currently...


now I think this would be the place to take corrective action if hwclock uses local time instead of utc.

looking deeper into this, I suspect that with CONFIG_RTC_HCTOSYS=y, the kernel will not store the time as local time.  I think the kernel actually will never care about local time.  It looks to me as if local time is a userspace thing.


So for hwclock in local time, I think we'd need to disable CONFIG_RTC_HCTOSYS for that case, and then we'd need to modify the sleep.d/90clock script to save and restore the system clock on suspend and on resume.
Comment 9 Vojtech Dziewiecki 2013-04-29 15:05:40 UTC
Well we should avoid using pm-utils and try to replace their functionality with systemd so that they can be removed later, since they are dead upstream.

CC'ing Cristian, he usually knows how to do things without pm-utils.
Comment 10 Susanne Oberhauser-Hirschoff 2013-04-29 16:04:34 UTC
systemd!  duh!
http://www.freedesktop.org/wiki/Software/systemd/timedated

well, I think we should really do some housekeeping and remove unused cruft from pm_utils.  this had never occurred to me.  We really need to remove dead code like sleep.d/90clock then...

anyhow:  christian, do you know whether the systemd implementation will handle DST switch during suspend gracefully?
Comment 11 Cristian Rodríguez 2013-04-29 16:30:26 UTC
Hrmmm.. keeping the CMOS in localtime and expecting this to work is not very realistic.

systemd-timedated knows when and why the next DST update will happend

 timedatectl
      Local time: lun 2013-04-29 12:19:38 CLT
  Universal time: lun 2013-04-29 16:19:38 UTC
        Timezone: America/Santiago (CLT, -0400)
     NTP enabled: n/a
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  sáb 2013-04-27 23:59:59 CLST
                  sáb 2013-04-27 23:00:00 CLT
 Next DST change: DST begins (the clock jumps one hour forward) at
                  sáb 2013-09-07 23:59:59 CLT
                  dom 2013-09-08 01:00:00 CLST

Buuut, timedated is not always running, it comes up when something tries to access its dbus interface.

I am not sure what to do about this, gonna ask somebody else ;-)
Comment 12 Ulrich Windl 2013-04-30 07:02:11 UTC
I know the subject is messy: IMHO the system needs to record the time when the hwclock was corrected for local time during DST change (just to avoid correcting it multiple times). Naturally the time of change should not be stored in local time for obvious reasons. To make matters worse in multi-boot environments, an other system (like Windows) can also adjust the hwclock. AFAIK, Windows/XP anly corrects the time if the system is powered on a few days after DST change; otherwise it assumes the hwclock is current. Sorry for throwing in some random thoughts. Rumors say recent Windows can work with hwclock running UTC, so there's light on the horizon...
Comment 16 Vojtech Dziewiecki 2013-06-19 06:24:16 UTC
If someone wants to take this bug and assign it to (him/her)self, it would be nice, since I can do nothing here.
Comment 18 Vojtech Dziewiecki 2014-07-16 15:30:39 UTC
Susanne, I will reassign this to you, since it seems to me that you are more likely to do something about this.
This has nothing to do with pm-utils anymore so I cannot help here.
Comment 19 Tomáš Chvátal 2018-01-25 12:47:58 UTC
Sadly release 12.3 is out of support. As such to keep cruft from our bugzilla please open a new ticket if you are still observing the issue.