[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANDhNCoW3whgp1ZW=Fpw6mFgbYowue2H_RR_Y9UYCTLstLJDrA@mail.gmail.com>
Date: Fri, 13 Jun 2025 19:51:38 -0700
From: John Stultz <jstultz@...gle.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, netdev@...r.kernel.org,
Richard Cochran <richardcochran@...il.com>, Christopher Hall <christopher.s.hall@...el.com>,
Frederic Weisbecker <frederic@...nel.org>, Anna-Maria Behnsen <anna-maria@...utronix.de>,
Miroslav Lichvar <mlichvar@...hat.com>, Werner Abt <werner.abt@...nberg-usa.com>,
David Woodhouse <dwmw2@...radead.org>, Stephen Boyd <sboyd@...nel.org>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
Kurt Kanzenbach <kurt@...utronix.de>, Nam Cao <namcao@...utronix.de>,
Antoine Tenart <atenart@...nel.org>
Subject: Re: [patch V2 17/26] timekeeping: Provide time getters for auxiliary clocks
On Mon, May 19, 2025 at 1:33 AM Thomas Gleixner <tglx@...utronix.de> wrote:
>
> Provide interfaces similar to the ktime_get*() family which provide access
> to the auxiliary clocks.
>
> These interfaces have a boolean return value, which indicates whether the
> accessed clock is valid or not.
>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
>
> ---
> include/linux/timekeeping.h | 11 +++++++
> kernel/time/timekeeping.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 73 insertions(+)
> ---
> --- a/include/linux/timekeeping.h
> +++ b/include/linux/timekeeping.h
> @@ -263,6 +263,17 @@ extern bool timekeeping_rtc_skipresume(v
>
> extern void timekeeping_inject_sleeptime64(const struct timespec64 *delta);
>
> +/*
> + * Auxiliary clock interfaces
> + */
> +#ifdef CONFIG_POSIX_AUX_CLOCKS
> +extern bool ktime_get_aux(clockid_t id, ktime_t *kt);
> +extern bool ktime_get_aux_ts64(clockid_t id, struct timespec64 *kt);
> +#else
> +static inline bool ktime_get_aux(clockid_t id, ktime_t *kt) { return false; }
> +static inline bool ktime_get_aux_ts64(clockid_t id, struct timespec64 *kt) { return false; }
> +#endif
> +
> /**
> * struct system_time_snapshot - simultaneous raw/real time capture with
> * counter value
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -2659,6 +2659,23 @@ EXPORT_SYMBOL(hardpps);
> /* Bitmap for the activated auxiliary timekeepers */
> static unsigned long aux_timekeepers;
>
> +static inline bool aux_valid_clockid(clockid_t id)
> +{
> + return id >= CLOCK_AUX && id <= CLOCK_AUX_LAST;
> +}
> +
> +static inline unsigned int clockid_to_tkid(unsigned int id)
> +{
> + return TIMEKEEPER_AUX + id - CLOCK_AUX;
> +}
> +
> +static inline struct tk_data *aux_get_tk_data(clockid_t id)
> +{
> + if (!aux_valid_clockid(id))
> + return NULL;
> + return &timekeeper_data[clockid_to_tkid(id)];
> +}
> +
> /* Invoked from timekeeping after a clocksource change */
> static void tk_aux_update_clocksource(void)
> {
> @@ -2679,6 +2696,51 @@ static void tk_aux_update_clocksource(vo
> }
> }
>
> +/**
> + * ktime_get_aux - Get TAI time for a AUX clock
Is this actually the TAI time? Wouldn't it be the MONOTONIC time for
the AUX clock?
> + * @id: ID of the clock to read (CLOCK_AUX...)
> + * @kt: Pointer to ktime_t to store the time stamp
> + *
> + * Returns: True if the timestamp is valid, false otherwise
> + */
> +bool ktime_get_aux(clockid_t id, ktime_t *kt)
> +{
> + struct tk_data *tkd = aux_get_tk_data(id);
> + struct timekeeper *tk;
Nit: Just to be super explicit, would it be good to name these aux_tk
and aux_tkd?
So it's more clear you're not working with the standard timekeeper?
thanks
-john
Powered by blists - more mailing lists