linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* New kernel interface for sys_tz and timewarp?
@ 2019-08-13  9:05 Arnd Bergmann
  2019-08-13 17:10 ` John Stultz
  2019-08-13 17:30 ` Linus Torvalds
  0 siblings, 2 replies; 26+ messages in thread
From: Arnd Bergmann @ 2019-08-13  9:05 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Thomas Gleixner, John Stultz, Alexandre Belloni, Stephen Boyd,
	Florian Weimer, Linus Torvalds, Theodore Ts'o,
	H. Peter Anvin, Palmer Dabbelt, Alistair Francis, GNU C Library,
	Karel Zak, Lennart Poettering, OGAWA Hirofumi

The riscv32 kernel port uses the new time64 syscall interface that has no
'settimeofday', only 'clock_settime64'. During the review of the glibc port,
the question arose how to deal with the (old, horrible, deprecated) timezone
portion of the settimeofday() libc API.

Typical uses of timezones in gettimeofday() are broken and should use
the normal user space timezone handling built into localtime() instead,
so the initial idea was to just not bother on new architectures and
break any application at build time that tries to access the struct timezone
members to ensure they are finally fixed, and also do the same thing
across all architectures for consistency.

As it turns out, both util-linux/hwclock and systemd make use of the
timezone field in settimeofday purely for the purpose of setting the
kernel itself into a known state, for three traditional uses:

- gettimeofday reports the timezone that was last set with settimeofday,
  something that is highly discouraged relying on but that has always
  worked.

- a few device drivers and file systems (e.g. fs/fat, full list below) are
  documented as storing timestamps in local time, so the global sys_tz variable
  is used to decide the offset, in addition to a in-superblock offset in most
  cases.

- on x86, windows dual-boot has traditionally (since linux-0.12) allowed the
  hack that the first settimeofday() call after boot decides whether the RTC
  is interpreted as localtime or UTC. This is particularly important because
  with NTP enabled, the time warped mode also updates the RTC with
  the kernel time every 11 minutes. See kernel/time/ntp.c:sync_hw_clock()
  and timekeeping_warp_clock() .

The relevant discussion on libc-alpha and on for systemd is archived at:
https://patchwork.ozlabs.org/patch/1121610/
https://github.com/systemd/systemd/issues/13305

Now, to the actual questions:

* Should we allow setting the sys_tz on new architectures that use only
  time64 interfaces at all, or should we try to get away from that anyway?

* Should the NTP timewarp setting ("int persistent_clock_is_local" and
  its offset) be controllable separately from the timezone used in other
  drivers?

* If we want keep having a way to set the sys_tz, what interface
should that use?

  Suggestions so far include
   - adding a clock_settimeofday_time64() syscall on all 32-bit architectures to
     maintain the traditional behavior,
   - adding a sysctl interface for accessing sys_tz.tz_tminuteswest,
   - using a new field in 'struct timex' for the timewarp offset, and
   - adding an ioctl command on /dev/rtc/ to control the timewarp
     offset of that particular device.

         Arnd
---
Appendix A: full list of kernel code using sys_tz

$ git grep -wl sys_tz drivers/ fs/ net/
drivers/media/platform/vivid/vivid-rds-gen.c
drivers/media/platform/vivid/vivid-vbi-gen.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-sas.c
drivers/scsi/aacraid/commsup.c
drivers/scsi/arcmsr/arcmsr_hba.c
drivers/scsi/mvumi.c
drivers/scsi/mvumi.h
drivers/scsi/smartpqi/smartpqi_init.c
fs/affs/amigaffs.c
fs/affs/inode.c
fs/fat/misc.c
fs/hfs/hfs_fs.h
fs/hfs/inode.c
fs/hfs/sysdep.c
fs/hpfs/hpfs_fn.h
fs/udf/udftime.c
net/netfilter/xt_time.c

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-08-27 16:31 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13  9:05 New kernel interface for sys_tz and timewarp? Arnd Bergmann
2019-08-13 17:10 ` John Stultz
2019-08-13 21:45   ` Alexandre Belloni
2019-08-13 17:30 ` Linus Torvalds
2019-08-13 17:49   ` Paul Eggert
2019-08-13 19:31     ` Florian Weimer
2019-08-13 20:04       ` Arnd Bergmann
2019-08-13 21:56   ` Alexandre Belloni
2019-08-14  0:06   ` Theodore Y. Ts'o
2019-08-14  8:31     ` Arnd Bergmann
2019-08-14  9:09       ` Lennart Poettering
2019-08-14  9:32         ` Alexandre Belloni
2019-08-14 12:15           ` Lennart Poettering
2019-08-19 11:09           ` Karel Zak
2019-08-19 13:43             ` Thomas Gleixner
2019-08-19 13:49               ` Thomas Gleixner
2019-08-20 18:45                 ` Alexandre Belloni
2019-08-20 18:47               ` Alexandre Belloni
2019-08-20 18:58             ` Alexandre Belloni
2019-08-27 16:27               ` Arnd Bergmann
2019-08-27 16:31                 ` Alexandre Belloni
2019-08-14 16:26     ` David Laight
2019-08-14 16:47       ` hpa
2019-08-15 13:22         ` Arnd Bergmann
2019-08-15 15:05           ` Theodore Y. Ts'o
2019-08-15 15:24             ` hpa

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).