Re: [PATCH 1/7] time: Condense timekeeper.xtime into xtime_sec

From: Ingo Molnar
Date: Tue Feb 28 2012 - 03:07:03 EST



* John Stultz <john.stultz@xxxxxxxxxx> wrote:

> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -39,8 +39,11 @@ struct timekeeper {
> /* Raw nano seconds accumulated per NTP interval. */
> u32 raw_interval;
>
> - /* Clock shifted nano seconds remainder not stored in xtime.tv_nsec. */
> + /* Current CLOCK_REALTIME time in seconds */
> + u64 xtime_sec;
> + /* Clock shifted nano seconds */
> u64 xtime_nsec;
> +
> /* Difference between accumulated time and NTP time in ntp
> * shifted nano seconds. */
> s64 ntp_error;
> @@ -48,8 +51,6 @@ struct timekeeper {
> * ntp shifted nano seconds. */
> int ntp_error_shift;
>
> - /* The current time */
> - struct timespec xtime;

Please use consistent vertical spacing for this structure.

> +static struct timespec timekeeper_xtime(struct timekeeper *tk)
> +{
> + struct timespec ts;
> +
> + ts.tv_sec = tk->xtime_sec;
> + ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift);
> + return ts;
> +}

btw., is tk->shift intentionally a signed int? If not then it
would be better to make it u32, like tk->mult, to make sure the
compiler never does complex signed arithmetics - and to clean up
'struct timekeeper'.

> +
> +static void timekeeper_set_xtime(struct timekeeper *tk,
> + const struct timespec *ts)

Pointless (because ugly) line break.

> +{
> + tk->xtime_sec = ts->tv_sec;
> + tk->xtime_nsec = ts->tv_nsec << tk->shift;
> +}
> +
> +
> +static void timekeeper_xtime_add(struct timekeeper *tk,
> + const struct timespec *ts)

Pointless (because ugly) line break.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/