Re: [PATCH v11 clocksource 6/6] clocksource: Reduce clocksource-skew threshold for TSC

From: kernel test robot
Date: Thu Apr 29 2021 - 03:03:07 EST


Hi "Paul,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/timers/core]
[also build test ERROR on tip/x86/core linux/master linus/master v5.12]
[cannot apply to next-20210428]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Paul-E-McKenney/Do-not-mark-clocks-unstable-due-to-delays-for-v5-13/20210429-093259
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 2d036dfa5f10df9782f5278fc591d79d283c1fad
config: riscv-randconfig-p002-20210428 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/26be1e45593936a0c04aa1d268522f8c1cb646de
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Paul-E-McKenney/Do-not-mark-clocks-unstable-due-to-delays-for-v5-13/20210429-093259
git checkout 26be1e45593936a0c04aa1d268522f8c1cb646de
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

kernel/time/clocksource.c: In function '__clocksource_update_freq_scale':
>> kernel/time/clocksource.c:1094:36: error: 'WATCHDOG_MAX_SKEW' undeclared (first use in this function)
1094 | if (cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW)
| ^~~~~~~~~~~~~~~~~
kernel/time/clocksource.c:1094:36: note: each undeclared identifier is reported only once for each function it appears in
>> kernel/time/clocksource.c:1097:28: error: 'WATCHDOG_THRESHOLD' undeclared (first use in this function)
1097 | cs->uncertainty_margin = WATCHDOG_THRESHOLD;
| ^~~~~~~~~~~~~~~~~~


vim +/WATCHDOG_MAX_SKEW +1094 kernel/time/clocksource.c

1039
1040 /**
1041 * __clocksource_update_freq_scale - Used update clocksource with new freq
1042 * @cs: clocksource to be registered
1043 * @scale: Scale factor multiplied against freq to get clocksource hz
1044 * @freq: clocksource frequency (cycles per second) divided by scale
1045 *
1046 * This should only be called from the clocksource->enable() method.
1047 *
1048 * This *SHOULD NOT* be called directly! Please use the
1049 * __clocksource_update_freq_hz() or __clocksource_update_freq_khz() helper
1050 * functions.
1051 */
1052 void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq)
1053 {
1054 u64 sec;
1055
1056 /*
1057 * Default clocksources are *special* and self-define their mult/shift.
1058 * But, you're not special, so you should specify a freq value.
1059 */
1060 if (freq) {
1061 /*
1062 * Calc the maximum number of seconds which we can run before
1063 * wrapping around. For clocksources which have a mask > 32-bit
1064 * we need to limit the max sleep time to have a good
1065 * conversion precision. 10 minutes is still a reasonable
1066 * amount. That results in a shift value of 24 for a
1067 * clocksource with mask >= 40-bit and f >= 4GHz. That maps to
1068 * ~ 0.06ppm granularity for NTP.
1069 */
1070 sec = cs->mask;
1071 do_div(sec, freq);
1072 do_div(sec, scale);
1073 if (!sec)
1074 sec = 1;
1075 else if (sec > 600 && cs->mask > UINT_MAX)
1076 sec = 600;
1077
1078 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq,
1079 NSEC_PER_SEC / scale, sec * scale);
1080 }
1081
1082 /*
1083 * If the uncertainty margin is not specified, calculate it.
1084 * If both scale and freq are non-zero, calculate the clock
1085 * period, but bound below at 2*WATCHDOG_MAX_SKEW. However,
1086 * if either of scale or freq is zero, be very conservative and
1087 * take the tens-of-milliseconds WATCHDOG_THRESHOLD value for the
1088 * uncertainty margin. Allow stupidly small uncertainty margins
1089 * to be specified by the caller for testing purposes, but warn
1090 * to discourage production use of this capability.
1091 */
1092 if (scale && freq && !cs->uncertainty_margin) {
1093 cs->uncertainty_margin = NSEC_PER_SEC / (scale * freq);
> 1094 if (cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW)
1095 cs->uncertainty_margin = 2 * WATCHDOG_MAX_SKEW;
1096 } else if (!cs->uncertainty_margin) {
> 1097 cs->uncertainty_margin = WATCHDOG_THRESHOLD;
1098 }
1099 WARN_ON_ONCE(cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW);
1100
1101 /*
1102 * Ensure clocksources that have large 'mult' values don't overflow
1103 * when adjusted.
1104 */
1105 cs->maxadj = clocksource_max_adjustment(cs);
1106 while (freq && ((cs->mult + cs->maxadj < cs->mult)
1107 || (cs->mult - cs->maxadj > cs->mult))) {
1108 cs->mult >>= 1;
1109 cs->shift--;
1110 cs->maxadj = clocksource_max_adjustment(cs);
1111 }
1112
1113 /*
1114 * Only warn for *special* clocksources that self-define
1115 * their mult/shift values and don't specify a freq.
1116 */
1117 WARN_ONCE(cs->mult + cs->maxadj < cs->mult,
1118 "timekeeping: Clocksource %s might overflow on 11%% adjustment\n",
1119 cs->name);
1120
1121 clocksource_update_max_deferment(cs);
1122
1123 pr_info("%s: mask: 0x%llx max_cycles: 0x%llx, max_idle_ns: %lld ns\n",
1124 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns);
1125 }
1126 EXPORT_SYMBOL_GPL(__clocksource_update_freq_scale);
1127

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip