Skip to contentSkip to conversation

RFC hwclock: refactoring

DISCUSSION JWP 5 participants 10 messages Nov 22, 2014 – Feb 16, 2015 Util-Linux package

lore
Share & tools
lore

JWP

author
#0 lore raw

So, I noticed when *fdisk were rewritten that some antiquated code was dropped. I would like some opinions on whether this should be done when refactoring hwclock.

For example, do we need a workaround for the 1994 Award BIOS bug? Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

Any other ideas regarding this topic are welcome. Thank you in advance for your time.

Here are some options up for discussion:

ALPHA ONLY
--getepoch
Print the kernel's Hardware Clock epoch value to standard out- put. This is the number of years into AD to which a zero year value in the Hardware Clock refers. For example, if you are using the convention that the year counter in your Hardware Clock contains the number of full years since 1952, then the kernel's Hardware Clock epoch value must be 1952.

This epoch value is used whenever hwclock reads or sets the Hardware Clock.

--setepoch
Set the kernel's Hardware Clock epoch value to the value speci-
fied by the --epoch option. See the --getepoch option for
details.

--epoch=year
Specifies the year which is the beginning of the Hardware Clock's epoch, that is the number of years into AD to which a
zero value in the Hardware Clock's year counter refers. It is
used together with the --setepoch option to set the kernel's idea of the epoch of the Hardware Clock, or otherwise to specify the epoch for use with direct ISA access.

For example, on a Digital Unix machine:

hwclock --setepoch --epoch=1952

--arc This option is equivalent to --epoch=1980 and is used to specify
the most common epoch on Alphas with ARC console (but Ruffians have epoch 1900).

--srm This option is equivalent to --epoch=1900 and is used to specify
the most common epoch on Alphas with SRM console.

--funky-toy

--jensen
These two options specify what kind of Alpha machine you have. They are invalid if you don't have an Alpha and are usually unnecessary if you do, because hwclock should be able to deter- mine by itself what it's running on, at least when /proc is mounted. (If you find you need one of these options to make hwclock work, contact the maintainer to see if the program can
be improved to detect your system automatically. Output of
hwclock --debug' and cat /proc/cpuinfo' may be of interest.)

Option --jensen means you are running on a Jensen model. And --funky-toy means that on your machine one has to use the UF bit instead of the UIP bit in the Hardware Clock to detect a time transition. "Toy" in the option name refers to the Time Of Year facility of the machine.

AWARD BIOS BUG

--badyear
Indicate that the Hardware Clock is incapable of storing years outside the range 1994-1999. There is a problem in some BIOSes (almost all Award BIOSes made between 4/26/94 and 5/31/95)
wherein they are unable to deal with years after 1999. If one
attempts to set the year-of-century value to something less than 94 (or 95 in some cases), the value that actually gets set is 94 (or 95). Thus, if you have one of these machines, hwclock can- not set the year after 1999 and cannot use the value of the clock as the true time in the normal way.

To compensate for this (without your getting a BIOS update, which would definitely be preferable), always use --badyear if you have one of these machines. When hwclock knows it's working with a brain-damaged clock, it ignores the year part of the Hardware Clock value and instead tries to guess the year based on the last calibrated date in the adjtime file, by assuming that date is within the past year. For this to work, you had better do a hwclock --set or hwclock --systohc at least once a year!

Though hwclock ignores the year value when it reads the Hardware
Clock, it sets the year value when it sets the clock. It sets
it to 1995, 1996, 1997, or 1998, whichever one has the same position in the leap year cycle as the true year. That way, the Hardware Clock inserts leap days where they belong. Again, if you let the Hardware Clock run for more than a year without set- ting it, this scheme could be defeated and you could end up los- ing a day.

hwclock warns you that you probably need --badyear whenever it finds your Hardware Clock set to 1994 or 1995.

#1 lore raw

Hello JWP,

Quoted 2 lines · JWP

For example, do we need a workaround for the 1994 Award BIOS bug?

In my opinion machines with that BIOS are too old. So no. Also because I wondered a few times about this phrase:

Quoted 2 lines

hwclock warns you that you probably need --badyear whenever it finds your Hardware Clock set to 1994 or 1995.

Nowhere in the source of hwclock can I find this warning. But it has been there in 2000, because this user reports having gotten it:
https://groups.google.com/d/msg/alt.lang.basic/ilp_6HwLvZE/sE1nBoiD_LcJ

Since no one ever complained that the above phrase in the man page is incorrect, it most likely means that no one uses such machines any more.

Benno

Signature · 1 line
http://www.fastmail.com - Choose from over 50 domains or use your own
author
#2 lore raw
Quoted 17 lines · Benno Schulenberg

Hello JWP,

Quoted 2 lines · JWP

For example, do we need a workaround for the 1994 Award BIOS bug?

In my opinion machines with that BIOS are too old. So no. Also because I wondered a few times about this phrase:

Quoted 2 lines

hwclock warns you that you probably need --badyear whenever it finds your Hardware Clock set to 1994 or 1995.

Nowhere in the source of hwclock can I find this warning. But it has been there in 2000, because this user reports having gotten it:
https://groups.google.com/d/msg/alt.lang.basic/ilp_6HwLvZE/sE1nBoiD_LcJ

Quoted 6 lines

Since no one ever complained that the above phrase in the man page is incorrect, it most likely means that no one uses such machines any more.

Benno

Thanks for your time and input Benno!

#3 lore raw
In reply to JWP
Quoted 6 lines · JWP

So, I noticed when *fdisk were rewritten that some antiquated code was dropped. I would like some opinions on whether this should be done when refactoring hwclock.

For example, do we need a workaround for the 1994 Award BIOS bug?

I agree with Benno, it is time to say goodbye to that code.

Quoted 2 lines

Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

I'm not sure if there is any up to date distribution for Alpha. Kernel crew seems to still care alpha, so it is not completely dead.

http://marc.info/?t=140518903000002&r=1&w=2

Maybe the question should be rephrased. How about dropping the Alpha cmos support? It looks like Alpha has rtc support.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/alpha/kernel/rtc.c

Quoted 1 line

Any other ideas regarding this topic are welcome.

Removal of i386 references should be safe.

http://news.softpedia.com/news/Linux-Kernel-3-8-Says-Goodbye-to-i386-314293.shtml

Since there is no other than Alpha & i386 references to cmos code, all of it is subject for removal.

Signature · 2 lines
Sami Kerola
http://www.iki.fi/kerolasa/
#4 lore raw
Quoted 23 lines · Sami Kerola
Quoted 6 lines · JWP

So, I noticed when *fdisk were rewritten that some antiquated code was dropped. I would like some opinions on whether this should be done when refactoring hwclock.

For example, do we need a workaround for the 1994 Award BIOS bug?

I agree with Benno, it is time to say goodbye to that code.

Quoted 2 lines

Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

I'm not sure if there is any up to date distribution for Alpha. Kernel crew seems to still care alpha, so it is not completely dead.

http://marc.info/?t=140518903000002&r=1&w=2

Maybe the question should be rephrased. How about dropping the Alpha cmos support? It looks like Alpha has rtc support.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/alpha/kernel/rtc.c

Quoted 8 lines
Quoted 1 line

Any other ideas regarding this topic are welcome.

Removal of i386 references should be safe.

http://news.softpedia.com/news/Linux-Kernel-3-8-Says-Goodbye-to-i386-314293.shtml

Since there is no other than Alpha & i386 references to cmos code, all of it is subject for removal.

JWP,

It's a rainy day here, so I decided to make initial attempt to remove cmos & --badyear. Maybe something like these are what you are thinking of.

https://github.com/kerolasa/lelux-utiliteetit/commit/fa8825f77996dfad39bd09240729287706f6e72f
https://github.com/kerolasa/lelux-utiliteetit/commit/74edf1aa9c16d351e9fdb25a961ec1932c60c674

After a clean up like that there is still tons to do. For example this snippet here

/*
* struct rtc_time is present since 1.3.99.
* Earlier (since 1.3.89), a struct tm was used.
*/

is screaming obsolete.

Signature · 2 lines
Sami Kerola
http://www.iki.fi/kerolasa/
author
#5 lore raw
Quoted 14 lines · Sami Kerola
Quoted 14 lines · Sami Kerola
Quoted 7 lines · JWP

So, I noticed when *fdisk were rewritten that some antiquated code was dropped. I would like some opinions on whether this should be done when refactoring hwclock.

For example, do we need a workaround for the 1994 Award BIOS bug?

I agree with Benno, it is time to say goodbye to that code.

Quoted 2 lines

Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

Quoted 7 lines
Quoted 7 lines

I'm not sure if there is any up to date distribution for Alpha. Kernel crew seems to still care alpha, so it is not completely dead.

http://marc.info/?t=140518903000002&r=1&w=2

Maybe the question should be rephrased. How about dropping the Alpha cmos support? It looks like Alpha has rtc support.

I intentionally did not include --directisa and hwclock-cmos.c in my RFC, because my current position is that I2C access should remain in hwclock for troubleshooting and testing purposes.

Your marc.info link seems to be broken.

Quoted 11 lines
Quoted 11 lines

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/alpha/kernel/rtc.c

Quoted 1 line

Any other ideas regarding this topic are welcome.

Removal of i386 references should be safe.

http://news.softpedia.com/news/Linux-Kernel-3-8-Says-Goodbye-to-i386-314293.shtml

Since there is no other than Alpha & i386 references to cmos code, all of it is subject for removal.

The __i386__ macro is set for all x86 platforms. They all support the ISA architecture and therefore can use direct access methods to the persistent clock. That includes x86_64, even though the current iteration of hwclock does not allow it, which is one of many hwclock bugs I will be fixing.

Quoted 13 lines

JWP,

It's a rainy day here, so I decided to make initial attempt to remove cmos & --badyear. Maybe something like these are what you are thinking of.

https://github.com/kerolasa/lelux-utiliteetit/commit/fa8825f77996dfad39bd09240729287706f6e72f
https://github.com/kerolasa/lelux-utiliteetit/commit/74edf1aa9c16d351e9fdb25a961ec1932c60c674

After a clean up like that there is still tons to do. For example this snippet here

Quoted 7 lines

/*
* struct rtc_time is present since 1.3.99.
* Earlier (since 1.3.89), a struct tm was used.
*/

is screaming obsolete.

All of the code will be changing, Karel ask me to refactor it outside of the main development channel. I wanted to see if the Alpha and Award code was somehow important to someone. My opinion is to remove it, but maybe there is something I am unaware of.

Even the source for the aboot Alpha boot-loader, and the previous center of all things Linux-Alpha, alphalinux.org is gone.

I do wonder why the kernel hasn't dropped it yet though.

I'm curious as to what Mr. Z's thoughts are going to be.

Thanks for your time and input Sami!

maintainer
#6 lore raw
Quoted 3 lines · JWP

I intentionally did not include --directisa and hwclock-cmos.c in my RFC, because my current position is that I2C access should remain in hwclock for troubleshooting and testing purposes.

Sure, hwclock-cmos.c is still usable.

Quoted 3 lines

of the main development channel. I wanted to see if the Alpha and Award code was somehow important to someone. My opinion is to remove it, but maybe there is something I am unaware of.

I think we don't have to care about Award workarounds at all.

Linux kernel provides RTC layer for Alpha, the question is usability, but I think we can be optimistic and drop the alpha specific cmos code :-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#7 lore raw
In reply to Sami Kerola
Quoted 5 lines · Sami Kerola
Quoted 2 lines · JWP

Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

I'm not sure if there is any up to date distribution for Alpha.

Gentoo still produces up-to-date releases
-mike

#8 lore raw
Quoted 10 lines · Mike Frysinger
Quoted 5 lines · Sami Kerola
Quoted 2 lines · JWP

Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

I'm not sure if there is any up to date distribution for Alpha.

Gentoo still produces up-to-date releases
-mike

Hello Mike,

Yes, I contacted the two most authoritative Alpha people I could find, Tobias Klausmann and Matt Turner. Matt requested that we continue to maintain hwclock's Alpha code. I forgot to post a follow up here about it, sorry.

William

#9 lore raw
Quoted 6 lines · J William Piggott
Quoted 5 lines · Mike Frysinger
Quoted 4 lines · Sami Kerola
Quoted 2 lines · JWP

Do we need Alpha code? Is there a Linux distro that still officially supports Alpha machines?

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

I'm not sure if there is any up to date distribution for Alpha.

Gentoo still produces up-to-date releases

Yes, I contacted the two most authoritative Alpha people I could find, Tobias Klausmann and Matt Turner. Matt requested that we continue to maintain hwclock's Alpha code. I forgot to post a follow up here about it, sorry.

no worries. if people are interested in refactoring code and want to verify alpha works (and qemu-system isn't doing it for them), we can get you access to real alpha hardware :).
-mike