This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: New kernel interface for sys_tz and timewarp?
- From: Alexandre Belloni <alexandre dot belloni at bootlin dot com>
- To: Arnd Bergmann <arnd at arndb dot de>
- Cc: Karel Zak <kzak at redhat dot com>, Lennart Poettering <mzxreary at 0pointer dot de>, "Theodore Y. Ts'o" <tytso at mit dot edu>, Linus Torvalds <torvalds at linux-foundation dot org>, Linux Kernel Mailing List <linux-kernel at vger dot kernel dot org>, Thomas Gleixner <tglx at linutronix dot de>, John Stultz <john dot stultz at linaro dot org>, Stephen Boyd <sboyd at kernel dot org>, Florian Weimer <fweimer at redhat dot com>, "H. Peter Anvin" <hpa at zytor dot com>, Palmer Dabbelt <palmer at dabbelt dot com>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, OGAWA Hirofumi <hirofumi at mail dot parknet dot co dot jp>
- Date: Tue, 27 Aug 2019 18:31:34 +0200
- Subject: Re: New kernel interface for sys_tz and timewarp?
- References: <CAK8P3a0VxM1BkjY1D2FfHi6L-ho_NH3v3+gBu45EfpjLF5NU5w@mail.gmail.com> <CAHk-=wiO2CWONDBud4nxoPgUJN1JEewFWhHa5wAqY8G5rrTXRQ@mail.gmail.com> <20190814000622.GB20365@mit.edu> <CAK8P3a1CXRETxn6Gh_cOxM3rZ-wUwVDu-7=yEwjqOY=uEdC6OQ@mail.gmail.com> <20190814090936.GB10516@gardel-login> <20190814093208.GG3600@piout.net> <20190819110903.if3dzhvfnlqutn6s@ws.net.home> <20190820185830.GQ3545@piout.net> <CAK8P3a0EiP-LsKp1nFHgeRF09tQ0+5kPQd9JXBEKc1is30x3SA@mail.gmail.com>
On 27/08/2019 18:27:32+0200, Arnd Bergmann wrote:
> On Tue, Aug 20, 2019 at 8:58 PM Alexandre Belloni
> <alexandre.belloni@bootlin.com> wrote:
> >
> > On 19/08/2019 13:09:03+0200, Karel Zak wrote:
> > > On Wed, Aug 14, 2019 at 11:32:08AM +0200, Alexandre Belloni wrote:
> > > > On 14/08/2019 11:09:36+0200, Lennart Poettering wrote:
> > > > > On Mi, 14.08.19 10:31, Arnd Bergmann (arnd@arndb.de) wrote:
> > > > >
> > > > > > - glibc stops passing the caller timezone argument to the kernel
> > > > > > - the distro kernel disables CONFIG_RTC_HCTOSYS,
> > > > > > CONFIG_RTC_SYSTOHC and CONFIG_GENERIC_CMOS_UPDATE
> > > > >
> > > > > What's the benefit of letting userspace do this? It sounds a lot more
> > > > > fragile to leave this syncing to userspace if the kernel can do this
> > > > > trivially on its own.
> > >
> > > Good point, why CONFIG_RTC_SYSTOHC has been added to the kernel?
> > >
> > > If I good remember than it's because synchronize userspace hwclock
> > > with rtc is pretty fragile and frustrating. We have improved this
> > > hwclock code many times and it will never be perfect. See for example
> > > hwclock --delay= option, sometimes hwclock has no clue about RTC behaviour.
> > >
> >
> > With a bit of care, we can reliably set the rtc to the system time from
> > userspace. It takes a bit of time (up to 2 seconds) but it can be
> > reliably set with an accuracy of a few ms on a slow system and an rtc on
> > a slow bus or a few ns with a fast system and a fast bus.
> > I know I did say I would implement it in hwclock and I still didn't
> > (sorry) but we could do better than the --delay option.
>
> Would you use the regular RTC_SET_TIME ioctl for that, or
> add a new RTC_SYS_TO_HC command that takes an explicit
> offset? It sounds to me that the synchronization bit (actually
> waiting for the right moment to update the rtc registers) is better
> done in the kernel, while the decision about the offset and when
> to call into the driver is better done in user space.
>
The existing ioctls are fine to do that, see:
https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/rtc-tools.git/tree/rtc-sync.c
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com