Re: [PATCHv3 04/27] timens: Introduce CLOCK_BOOTTIME offset

From: Cyrill Gorcunov
Date: Thu Apr 25 2019 - 16:08:11 EST


On Thu, Apr 25, 2019 at 05:13:53PM +0100, Dmitry Safonov wrote:
>
> diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h
> index 8f75d34cf34a..5f0da6858b10 100644
> --- a/include/linux/time_namespace.h
> +++ b/include/linux/time_namespace.h
> @@ -48,6 +48,14 @@ static inline void timens_add_monotonic(struct timespec64 *ts)
> *ts = timespec64_add(*ts, ns_offsets->monotonic_time_offset);
> }
>
> +static inline void timens_add_boottime(struct timespec64 *ts)
> +{
> + struct timens_offsets *ns_offsets = current->nsproxy->time_ns->offsets;
> +
> + if (ns_offsets)
> + *ts = timespec64_add(*ts, ns_offsets->monotonic_boottime_offset);
> +}
>
...

> struct timens_offsets {
> struct timespec64 monotonic_time_offset;
> + struct timespec64 monotonic_boottime_offset;
> };

Guys, is not the _offset postfix here redundant? timens_offsets
already has it and ns_offsets->monotonic_boottime_offset looks
too much.

static always_inline current_time_ns_offsets(void)
{
return current->nsproxy->time_ns->offsets;
}

static inline void timens_add_boottime(struct timespec64 *ts)
{
struct timens_offsets *tns_off = current_time_ns_offsets();

if (tns_off)
*ts = timespec64_add(*ts, tns_off->monotonic_boottime);
}

Hmm? Up to you though.