From: kernel test robot <lkp@intel.com>
To: David Woodhouse <dwmw@amazon.co.uk>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [dwmw2:ffclock 8/10] kernel/time/timekeeping.c:2526:49: warning: shift count >= width of type
Date: Sat, 30 May 2026 06:30:02 +0800 [thread overview]
Message-ID: <202605300611.vR6jAFZe-lkp@intel.com> (raw)
tree: git://git.infradead.org/users/dwmw2/linux ffclock
head: 70c32e7a9e128f2579034276c19d34bcf79f4b0c
commit: 6fc43ccf0a8bed65163bc381478a4c6ad65f4479 [8/10] timekeeping: Add absolute reference for feed-forward clock discipline
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20260530/202605300611.vR6jAFZe-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 9409c07de6378507397ecdb6f05f628f58110112)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260530/202605300611.vR6jAFZe-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/202605300611.vR6jAFZe-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/time/timekeeping.c:2526:49: warning: shift count >= width of type [-Wshift-count-overflow]
2526 | offset_scaled = (sec_diff * (s64)(NSEC_PER_SEC << NTP_SCALE_SHIFT)) +
| ^ ~~~~~~~~~~~~~~~
kernel/time/timekeeping.c:2010:13: warning: variable 'suspend_timing_needed' set but not used [-Wunused-but-set-global]
2010 | static bool suspend_timing_needed;
| ^
2 warnings generated.
vim +2526 kernel/time/timekeeping.c
2445
2446
2447 int timekeeping_set_reference(const struct tk_reference *ref, bool step)
2448 {
2449 struct timekeeper *tks = &tk_core.shadow_timekeeper;
2450 struct timespec64 ts_delta;
2451 u64 new_tl, delta, ref_frac, ref_sec;
2452 s64 offset_ns, offset_scaled, ref_ns, sec_diff;
2453 u64 xt_shifted;
2454 unsigned long flags;
2455
2456 raw_spin_lock_irqsave(&tk_core.lock, flags);
2457
2458 if (tks->cs_id != ref->cs_id) {
2459 raw_spin_unlock_irqrestore(&tk_core.lock, flags);
2460 return -ENODEV;
2461 }
2462
2463 timekeeping_forward_now(tks);
2464
2465 /*
2466 * Compute the NTP tick_length from the reference period.
2467 * tick_length is in ns << NTP_SCALE_SHIFT (i.e. ns << 32) per tick.
2468 * period_frac_sec is the counter period as a fraction of a second
2469 * (0.period_shift fixed point), so:
2470 * tick_length = period_frac_sec * cycle_interval * NSEC_PER_SEC
2471 * >> (32 + period_shift)
2472 */
2473 new_tl = mul_u64_u64_shr(ref->period_frac_sec,
2474 (u64)tks->cycle_interval * NSEC_PER_SEC,
2475 32 + ref->period_shift);
2476 ntp_set_tick_length(tks->id, new_tl);
2477
2478 /*
2479 * Compute reference time at cycle_last (i.e. "now" after
2480 * timekeeping_forward_now). Use 128-bit arithmetic to handle
2481 * seconds overflow in ref_frac.
2482 */
2483 delta = tks->tkr_mono.cycle_last - ref->counter_value;
2484 ref_frac = mul_u64_u64_shr_add_u64(&ref_sec, delta,
2485 ref->period_frac_sec,
2486 ref->period_shift,
2487 ref->time_frac_sec);
2488 ref_sec += ref->time_sec;
2489
2490 /*
2491 * Compute the phase error between the reference time at the next
2492 * tick boundary and the kernel's xtime there.
2493 */
2494 xt_shifted = tks->tkr_mono.xtime_nsec;
2495 ref_ns = (s64)mul_u64_u64_shr(ref_frac, NSEC_PER_SEC, 64);
2496 sec_diff = (s64)(ref_sec - tks->xtime_sec);
2497
2498 offset_ns = sec_diff * NSEC_PER_SEC + ref_ns -
2499 (s64)(xt_shifted >> tks->tkr_mono.shift);
2500
2501
2502 if (step) {
2503 struct timespec64 new_xt, xt;
2504
2505 xt = tk_xtime(tks);
2506 ts_delta = ns_to_timespec64(offset_ns);
2507 new_xt = timespec64_add(xt, ts_delta);
2508 tk_set_wall_to_mono(tks,
2509 timespec64_sub(tks->wall_to_monotonic, ts_delta));
2510 tk_set_xtime(tks, &new_xt);
2511
2512 /* Recompute after step — only sub-ns residual remains */
2513 xt_shifted = tks->tkr_mono.xtime_nsec;
2514 sec_diff = (s64)(ref_sec - tks->xtime_sec);
2515 } else if (offset_ns > MAXPHASE || offset_ns < -MAXPHASE) {
2516 timekeeping_restore_shadow(&tk_core);
2517 raw_spin_unlock_irqrestore(&tk_core.lock, flags);
2518 return -EINVAL;
2519 }
2520
2521 /*
2522 * Set time_offset with full sub-ns precision. sec_diff can
2523 * only be -1, 0, or 1 at this point (bounded by MAXPHASE or
2524 * by the step having just aligned to the nearest nanosecond).
2525 */
> 2526 offset_scaled = (sec_diff * (s64)(NSEC_PER_SEC << NTP_SCALE_SHIFT)) +
2527 (((s64)mul_u64_u64_shr(ref_frac,
2528 (u64)NSEC_PER_SEC << tks->tkr_mono.shift, 64) -
2529 (s64)xt_shifted) << (NTP_SCALE_SHIFT - tks->tkr_mono.shift));
2530 ntp_set_time_offset(tks->id, offset_scaled);
2531 tks->ntp_error = 0;
2532
2533 timekeeping_update_from_shadow(&tk_core,
2534 step ? TK_CLOCK_WAS_SET : 0);
2535 raw_spin_unlock_irqrestore(&tk_core.lock, flags);
2536
2537 if (step) {
2538 clock_was_set(CLOCK_SET_WALL);
2539 audit_tk_injoffset(ts_delta);
2540 }
2541 return 0;
2542 }
2543 EXPORT_SYMBOL_GPL(timekeeping_set_reference);
2544
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-05-29 22:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202605300611.vR6jAFZe-lkp@intel.com \
--to=lkp@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox