Re: [patch V3 08/11] timekeeping: Prepare do_adtimex() for auxiliary clocks

From: John Stultz
Date: Fri Jun 27 2025 - 01:01:11 EST


On Wed, Jun 25, 2025 at 11:38 AM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> Exclude ADJ_TAI, leap seconds and PPS functionality as they make no sense
> in the context of auxiliary clocks and provide a time stamp based on the
> actual clock.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> kernel/time/timekeeping.c | 39 ++++++++++++++++++++++++++++++++++++---
> 1 file changed, 36 insertions(+), 3 deletions(-)
> ---
>
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -2562,6 +2573,21 @@ static int timekeeping_validate_timex(co
> return -EINVAL;
> }
>
> + if (!aux_clock)
> + return 0;
> +
> + /* Auxiliary clocks are similar to TAI and do not have leap seconds */
> + if (txc->status & (STA_INS | STA_DEL))
> + return -EINVAL;
> +
> + /* No TAI offset setting */
> + if (txc->modes & ADJ_TAI)
> + return -EINVAL;
> +
> + /* No PPS support either */
> + if (txc->status & (STA_PPSFREQ | STA_PPSTIME))
> + return -EINVAL;
> +

Just a taste issue, but I think it would be more clear if these checks
were nested under the
if (aux_clock) {
...
}

As otherwise if you read-over and miss the !aux_clock early return it
seems like you're erroring out on normally valid cases.

But it's a minor thing.


> @@ -2592,15 +2618,22 @@ static int __do_adjtimex(struct tk_data
> struct timekeeper *tks = &tkd->shadow_timekeeper;
> struct timespec64 ts;
> s32 orig_tai, tai;
> + bool aux_clock;
> int ret;
>
> + aux_clock = IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS) && tkd->timekeeper.id != TIMEKEEPER_CORE;
> +

Again, the is_core_timekeeper() check would be helpful here (or
alternatively is_aux_timekeeper())

Otherwise:
Acked-by: John Stultz <jstultz@xxxxxxxxxx>

thanks
-john