Re: [RFC][PATCH v2] timekeeping: Cap adjustments so they don't exceed the maxadj value
From: Miroslav Lichvar
Date: Mon Dec 14 2015 - 07:40:06 EST
On Thu, Dec 10, 2015 at 11:54:01AM -0800, John Stultz wrote:
> Thus its been occasionally noted that users have seen
> confusing warnings like:
>
> Adjusting tsc more than 11% (5941981 vs 7759439)
> @@ -1612,13 +1615,32 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk,
> /* preserve the direction of correction */
> negative = (tick_error < 0);
>
> - /* Sort out the magnitude of the correction */
> + /* If any adjustment would pass the max, just return */
> + if (negative && (cur_adj - 1) < (base - max))
> + return;
> + if (!negative && (cur_adj + 1) > (base + max))
> + return;
I ran the test that triggered the warning previously and it was silent
now.
But it looks like timekeeping_adjust() should check the adjustment too
before calling timekeeping_apply_adjustment(). In linux-tktest I was
able to find a configuration (-t 10 -n 150 -p 10000000) that triggered
the warning again. I'm not sure how likely it is to happen in real
world and if it's worth fixing though.
To avoid adding even more code, maybe the check could be moved to
timekeeping_apply_adjustment()? It would try decreasing adj_scale
until the check passes. When it reached -1, the function would return
immediately with no adjustment of the multiplier.
--
Miroslav Lichvar
--
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/