Re: [PATCH 08/12] time: Add warnings when overflows or underflows are observed

From: Peter Zijlstra
Date: Fri Jan 23 2015 - 09:30:33 EST


On Thu, Jan 22, 2015 at 04:09:23PM -0800, John Stultz wrote:
> #ifdef CONFIG_DEBUG_TIMEKEEPING
> +#define WARNINGFREQ (HZ*300) /* 5 minute rate-limiting */
> +/*
> + * These simple flag variables are managed
> + * without locks, which is racy, but ok since
> + * we don't really care about being super
> + * precise about how many events were seen,
> + * just that a problem was observed.
> + */
> +static int timekeeping_underflow_seen;
> +static int timekeeping_overflow_seen;
> +
> static void timekeeping_check_update(struct timekeeper *tk, cycle_t offset)
> {
>
> cycle_t max_cycles = tk->tkr.clock->max_cycles;
> const char *name = tk->tkr.clock->name;
> + static long last_warning; /* we always hold write on timekeeper lock */
>
> if (offset > max_cycles)
> printk_deferred("ERROR: cycle offset (%lld) is larger then"
> @@ -133,28 +145,60 @@ static void timekeeping_check_update(struct timekeeper *tk, cycle_t offset)
> printk_deferred("WARNING: cycle offset (%lld) is past"
> " the %s 50%% safety margin (%lld)\n",
> offset, name, max_cycles>>1);
> +
> + if (timekeeping_underflow_seen) {
> + if (jiffies - last_warning > WARNINGFREQ) {
> + printk_deferred("WARNING: Clocksource underflow observed\n");
> + last_warning = jiffies;
> + }
> + timekeeping_underflow_seen = 0;
> + }
> + if (timekeeping_overflow_seen) {
> + if (jiffies - last_warning > WARNINGFREQ) {
> + printk_deferred("WARNING: Clocksource overflow observed\n");
> + last_warning = jiffies;
> + }
> + timekeeping_overflow_seen = 0;
> + }
> +
> }

Ah, ignore my last comment. Excellent!
--
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/