Re: [PATCH 06/12] time: Add infrastructure to cap clocksource reads to the max_cycles value

From: Richard Cochran
Date: Sat Jan 24 2015 - 12:35:29 EST


On Thu, Jan 22, 2015 at 04:09:21PM -0800, John Stultz wrote:
> +static inline cycle_t timekeeping_get_delta(struct tk_read_base *tkr)
> +{
> + cycle_t cycle_now, delta;
> +
> + /* read clocksource */
> + cycle_now = tkr->read(tkr->clock);
> +
> + /* calculate the delta since the last update_wall_time */
> + delta = clocksource_delta(cycle_now, tkr->cycle_last, tkr->mask);
> +
> + /* Cap delta value to the max_cycles values to avoid mult overflows */
> + if (unlikely(delta > tkr->clock->max_cycles))
> + delta = tkr->clock->max_cycles;
> +
> + return delta;
> +}
> #else
> #define timekeeping_check_update(x, y)
> +static inline cycle_t timekeeping_get_delta(struct tk_read_base *tkr)
> +{
> + /* calculate the delta since the last update_wall_time */
> + return clocksource_delta(tkr->read(tkr->clock), tkr->cycle_last,
> + tkr->mask);

Coding style is strange here. It would look nicer it were like the
debug version, above.

> +}
> #endif

Series looks fine to me.

Acked-by: Richard Cochran <richardcochran@xxxxxxxxx>
--
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/