All of lore.kernel.org
 help / color / mirror / Atom feed
* [dwmw2:timekeeping 10/14] kernel/time/timekeeping.c:2957:56: warning: left shift count >= width of type
@ 2026-09-30  5:13 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-09-30  5:13 UTC (permalink / raw)
  To: David Woodhouse; +Cc: oe-kbuild-all

tree:   git://git.infradead.org/users/dwmw2/linux timekeeping
head:   6000baa1ec08e9e0880ad0b51db6574882d09ae1
commit: ff4e31e721392e007b2b38a9815e3c01f497ce2d [10/14] timekeeping: Add absolute reference for feed-forward clock discipline
config: csky-allnoconfig (https://download.01.org/0day-ci/archive/20260930/202609301335.NZqudgSP-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260930/202609301335.NZqudgSP-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609301335.NZqudgSP-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/time/timekeeping.c: In function 'timekeeping_set_reference':
>> kernel/time/timekeeping.c:2957:56: warning: left shift count >= width of type [-Wshift-count-overflow]
    2957 |         offset_scaled = (sec_diff * (s64)(NSEC_PER_SEC << NTP_SCALE_SHIFT)) +
         |                                                        ^~
--
>> Warning: kernel/time/ntp.c:581 function parameter 'ntpdata' not described in 'ntp_update_skew_delta'
>> Warning: kernel/time/ntp.c:581 function parameter 'settle' not described in 'ntp_update_skew_delta'
>> Warning: kernel/time/ntp.c:581 expecting prototype for ntp_set_time_offset(). Prototype was for ntp_update_skew_delta() instead


vim +2957 kernel/time/timekeeping.c

  2872	
  2873	int timekeeping_set_reference(const struct tk_reference *ref, bool step)
  2874	{
  2875		struct timekeeper *tks = &tk_core.shadow_timekeeper;
  2876		struct timespec64 ts_delta;
  2877		u64 new_tl, delta, ref_frac, ref_sec;
  2878		s64 offset_ns, offset_scaled, ref_ns, sec_diff;
  2879		u64 xt_shifted;
  2880		unsigned long flags;
  2881	
  2882		raw_spin_lock_irqsave(&tk_core.lock, flags);
  2883	
  2884		if (tks->cs_id != ref->cs_id) {
  2885			raw_spin_unlock_irqrestore(&tk_core.lock, flags);
  2886			return -ENODEV;
  2887		}
  2888	
  2889		/*
  2890		 * Process any pending ticks and set up a known state of the *current*
  2891		 * tick, including zero skew_delta.
  2892		 */
  2893		ntp_set_time_offset(tks->id, 0);
  2894		__timekeeping_advance(&tk_core, TK_ADV_FREQ);
  2895	
  2896		/*
  2897		 * Compute the NTP tick_length from the reference period.
  2898		 * tick_length is in ns << NTP_SCALE_SHIFT (i.e. ns << 32) per tick.
  2899		 * period_frac_sec is the counter period as a fraction of a second
  2900		 * (0.period_shift fixed point), so:
  2901		 *   tick_length = period_frac_sec * cycle_interval * NSEC_PER_SEC
  2902		 *                 >> (32 + period_shift)
  2903		 */
  2904		new_tl = mul_u64_u64_shr(ref->period_frac_sec,
  2905				(u64)tks->cycle_interval * NSEC_PER_SEC,
  2906				32 + ref->period_shift);
  2907		ntp_set_tick_length(tks->id, new_tl);
  2908	
  2909		/*
  2910		 * Compute reference time at cycle_last (i.e. "now" after
  2911		 * __timekeeping_advance()). Use 128-bit arithmetic to handle
  2912		 * seconds overflow in ref_frac.
  2913		 */
  2914		delta = tks->tkr_mono.cycle_last - ref->counter_value;
  2915		ref_frac = mul_u64_u64_shr_add_u64(&ref_sec, delta,
  2916						    ref->period_frac_sec,
  2917						    ref->period_shift,
  2918						    ref->time_frac_sec);
  2919		ref_sec += ref->time_sec;
  2920	
  2921		/*
  2922		 * Compute the phase error between the reference time at the next
  2923		 * tick boundary and the kernel's xtime there.
  2924		 */
  2925		xt_shifted = tks->tkr_mono.xtime_nsec;
  2926		ref_ns = (s64)mul_u64_u64_shr(ref_frac, NSEC_PER_SEC, 64);
  2927		sec_diff = (s64)(ref_sec - tks->xtime_sec);
  2928	
  2929		offset_ns = sec_diff * NSEC_PER_SEC + ref_ns -
  2930			    (s64)(xt_shifted >> tks->tkr_mono.shift);
  2931	
  2932	
  2933		if (step) {
  2934			struct timespec64 new_xt, xt;
  2935	
  2936			xt = tk_xtime(tks);
  2937			ts_delta = ns_to_timespec64(offset_ns);
  2938			new_xt = timespec64_add(xt, ts_delta);
  2939			tk_set_wall_to_mono(tks,
  2940				timespec64_sub(tks->wall_to_monotonic, ts_delta));
  2941			tk_set_xtime(tks, &new_xt);
  2942	
  2943			/* Recompute after step — only sub-ns residual remains */
  2944			xt_shifted = tks->tkr_mono.xtime_nsec;
  2945			sec_diff = (s64)(ref_sec - tks->xtime_sec);
  2946		} else if (offset_ns > MAXPHASE || offset_ns < -MAXPHASE) {
  2947			timekeeping_restore_shadow(&tk_core);
  2948			raw_spin_unlock_irqrestore(&tk_core.lock, flags);
  2949			return -EINVAL;
  2950		}
  2951	
  2952		/*
  2953		 * Set time_offset with full sub-ns precision. sec_diff can
  2954		 * only be -1, 0, or 1 at this point (bounded by MAXPHASE or
  2955		 * by the step having just aligned to the nearest nanosecond).
  2956		 */
> 2957		offset_scaled = (sec_diff * (s64)(NSEC_PER_SEC << NTP_SCALE_SHIFT)) +
  2958			(((s64)mul_u64_u64_shr(ref_frac,
  2959				(u64)NSEC_PER_SEC << tks->tkr_mono.shift, 64) -
  2960			  (s64)xt_shifted) << (NTP_SCALE_SHIFT - tks->tkr_mono.shift));
  2961		ntp_set_time_offset(tks->id, offset_scaled);
  2962		/*
  2963		 * Preload ntp_error with the negative of the in-progress tick's
  2964		 * accumulation delta. logarithmic_accumulation() will do:
  2965		 *   ntp_error += ntp_tick - (xtime_interval << ntp_error_shift)
  2966		 * (skew_delta is zero, so there is no skew term). Setting ntp_error to
  2967		 * the negation means that after this tick accumulates, ntp_error lands
  2968		 * at ~0 — so no spurious ±1 dithering is triggered. The cached ntp_tick
  2969		 * and xtime_interval here are exactly the ones that tick will use (the
  2970		 * new tick_length only takes effect from the tick after).
  2971		 */
  2972		tks->ntp_error = ((s64)tks->xtime_interval << tks->ntp_error_shift) -
  2973				 (s64)tks->ntp_tick;
  2974	
  2975		timekeeping_update_from_shadow(&tk_core,
  2976			step ? TK_CLOCK_WAS_SET : 0);
  2977		raw_spin_unlock_irqrestore(&tk_core.lock, flags);
  2978	
  2979		if (step) {
  2980			clock_was_set(CLOCK_SET_WALL);
  2981			audit_tk_injoffset(ts_delta);
  2982		}
  2983		return 0;
  2984	}
  2985	EXPORT_SYMBOL_GPL(timekeeping_set_reference);
  2986	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-30  5:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30  5:13 [dwmw2:timekeeping 10/14] kernel/time/timekeeping.c:2957:56: warning: left shift count >= width of type kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.