History

clocksource: Avoid selecting mult values that might overflow when adjusted

For some frequencies, the clocks_calc_mult_shift() function will unfortunately select mult values very close to 0xffffffff. This has the potential to overflow when NTP adjusts the clock, adding to the mult value. This patch adds a clocksource.maxadj value, which provides an approximation of an 11% adjustment(NTP limits adjustments to 500ppm and the tick adjustment is limited to 10%), which could be made to the clocksource.mult value. This is then used to both check that the current mult value won't overflow/underflow, as well as warning us if the timekeeping_adjust() code pushes over that 11% boundary. v2: Fix max_adjustment calculation, and improve WARN_ONCE messages. v3: Don't warn before maxadj has actually been set

John Stultz committed 15 years ago

Commit d65670a1 parent e35f95b3 files · +57 −11Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/clocksource.h+2−1
@@ -156,6 +156,7 @@ extern u64 timecounter_cyc2time(struct timecounter *tc, · 155 unmodified lines
156156 * @mult: cycle to nanosecond multiplier
157157 * @shift: cycle to nanosecond divisor (power of two)
158158 * @max_idle_ns: max idle time permitted by the clocksource (nsecs)
159+ * @maxadj maximum adjustment value to mult (~11%)
159160 * @flags: flags describing special properties
160161 * @archdata: arch-specific data
161162 * @suspend: suspend function for the clocksource, if necessary
@@ -172,7 +173,7 @@ struct clocksource { · 10 unmodified lines
172173 u32 mult;
173174 u32 shift;
174175 u64 max_idle_ns;
175−
176+ u32 maxadj;
176177 #ifdef CONFIG_ARCH_CLOCKSOURCE_DATA
177178 struct arch_clocksource_data archdata;
178179 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t