From: Thomas Gleixner <tglx@linutronix.de>
To: Richard Cochran <richardcochran@gmail.com>
Cc: Miroslav Lichvar <mlichvar@redhat.com>,
Daphne Preston-Kendall <dpk@nonceword.org>,
LKML <linux-kernel@vger.kernel.org>,
John Stultz <john.stultz@linaro.org>,
"Michael Kerrisk \(man-pages\)" <mtk.manpages@gmail.com>
Subject: Re: [Bug 212265] New: clock_gettime(CLOCK_TAI, ...) should return an error when TAI has not been configured
Date: Mon, 29 Mar 2021 20:28:23 +0200 [thread overview]
Message-ID: <87im597r20.ffs@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20210329153604.GA21716@hoboy.vegasvil.org>
On Mon, Mar 29 2021 at 08:36, Richard Cochran wrote:
> On Mon, Mar 29, 2021 at 04:57:55PM +0200, Thomas Gleixner wrote:
>> I think adjtimex is the right place and not yet another random file
>> somewhere. Something like the below.
>
> Perfect.
>
> Acked-by: Richard Cochran <richardcochran@gmail.com>
But one problem is with that trivial bit that the interface does not
tell you whether that bit will ever be set or not, i.e. it won't on an
older kernel even if TAI was set by ntp/chrony/...
So that needs some thoughts. The trivial hack is in the updated patch
below. If you want to spare the extra bits in status then you could use
one of the spare int's at the end for this.
If someone has cycles and can turn that into a proper patch with all the
bells and whistels (changelog, manpage update, example ..), that would
be appreciated. Otherwise I stick it to the other things on that ever
growing todo list and tend to it Mañana. :)
Thanks,
tglx
---
include/uapi/linux/timex.h | 8 ++++++--
kernel/time/ntp.c | 6 ++++--
2 files changed, 10 insertions(+), 4 deletions(-)
--- a/include/uapi/linux/timex.h
+++ b/include/uapi/linux/timex.h
@@ -188,9 +188,13 @@ struct __kernel_timex {
#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
+#define STA_TAIREF 0x10000 /* Set TAI offset is reflected in STA_TAISET (ro) */
+#define STA_TAISET 0x20000 /* TAI offset was set via adjtimex (ro) */
+
/* read-only bits */
-#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
- STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
+ STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | \
+ STA_CLK | STA_TAIREF | STA_TAISET)
/*
* Clock states (time_state)
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -57,7 +57,7 @@ static u64 tick_length_base;
static int time_state = TIME_OK;
/* clock status bits: */
-static int time_status = STA_UNSYNC;
+static int time_status = STA_UNSYNC | STA_TAIREF;
/* time adjustment (nsecs): */
static s64 time_offset;
@@ -741,8 +741,10 @@ static inline void process_adjtimex_mode
}
if (txc->modes & ADJ_TAI &&
- txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
+ txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET) {
*time_tai = txc->constant;
+ time_status |= STA_TAISET;
+ }
if (txc->modes & ADJ_OFFSET)
ntp_update_offset(txc->offset);
prev parent reply other threads:[~2021-03-29 18:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 11:13 [Bug 212265] New: clock_gettime(CLOCK_TAI, ...) should return an error when TAI has not been configured Thomas Gleixner
2021-03-27 3:28 ` Richard Cochran
2021-03-29 9:16 ` Miroslav Lichvar
2021-03-29 9:56 ` Daphne Preston-Kendal
2021-03-29 14:18 ` Richard Cochran
2021-03-29 14:21 ` Richard Cochran
2021-03-29 14:26 ` Richard Cochran
2021-03-29 14:57 ` Thomas Gleixner
2021-03-29 15:36 ` Richard Cochran
2021-03-29 18:28 ` Thomas Gleixner [this message]
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=87im597r20.ffs@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=dpk@nonceword.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=mtk.manpages@gmail.com \
--cc=richardcochran@gmail.com \
/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).