From: netdev-bot+sashiko@kernel.org
To: james.hilliard1@gmail.com
Cc: netdev@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org,
richardcochran@gmail.com, andrew+netdev@lunn.ch,
yangbo.lu@nxp.com, mlichvar@redhat.com, edumazet@kernel.org,
davem@davemloft.net, linux-kernel@vger.kernel.org,
vadim.fedorenko@linux.dev
Subject: Re: [PATCH net v5 3/5] ptp: vclock: propagate physical clock sampling errors
Date: Mon, 26 Oct 2026 15:53:48 +0000 [thread overview]
Message-ID: <179303002839.3134.5595255852218546734@kernel.org> (raw)
In-Reply-To: <20261022-ptp-vclock-sampling-v5-3-06ceace17bac@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The exponential retry backoff added to ptp_vclock_refresh() in
drivers/ptp/ptp_vclock.c only looks at the previous retry delay.
--
ptp: vclock: propagate physical clock sampling errors
This patch caches a successful parent PHC sample before timecounter
operations. Read failures are now returned to callers instead of being
consumed as a zero sample. It also adds a refresh retry that starts at
10 ms and doubles on consecutive failures, up to the normal two second
interval, and makes ptp_vclock_register() return error pointers.
> diff --git a/drivers/ptp/ptp_vclock.c b/drivers/ptp/ptp_vclock.c
> index 84cb527f59ccc..c10eba6443f9a 100644
> --- a/drivers/ptp/ptp_vclock.c
> +++ b/drivers/ptp/ptp_vclock.c
[ ... ]
> @@ -13,6 +14,7 @@
> #define PTP_VCLOCK_FADJ_SHIFT 9
> #define PTP_VCLOCK_FADJ_DENOMINATOR 15625ULL
> #define PTP_VCLOCK_REFRESH_INTERVAL (HZ * 2)
> +#define PTP_VCLOCK_RETRY_INTERVAL msecs_to_jiffies(10)
[ ... ]
> @@ -151,8 +175,18 @@ static long ptp_vclock_refresh(struct ptp_clock_info *ptp)
> struct ptp_vclock *vclock = info_to_vclock(ptp);
> struct timespec64 ts;
>
> - ptp_vclock_gettime(&vclock->info, &ts);
> + /* Retry transient failures promptly, but back off during long outages. */
> + if (ptp_vclock_gettime(&vclock->info, &ts)) {
> + if (!vclock->retry_delay)
> + vclock->retry_delay = PTP_VCLOCK_RETRY_INTERVAL;
> + else
> + vclock->retry_delay = min_t(unsigned long,
> + vclock->retry_delay * 2,
> + PTP_VCLOCK_REFRESH_INTERVAL);
> + return vclock->retry_delay;
> + }
[Severity: Medium]
Can this backoff skip past the 32-bit counter wrap and lose a full wrap
of virtual time?
The doubling only looks at the previous retry_delay. It does not look at
how long ago the last successful parent sample was taken. The
cyclecounter uses CYCLECOUNTER_MASK(32), so it wraps every 2^32 ns,
about 4.295 s.
Suppose the last good refresh was at t0 and getcycles64() starts failing
at the regular t0+2 s refresh. The retries then run at about:
t0+2.010, 2.030, 2.070, 2.150, 2.310, 2.630, 3.270 s
After that the delay becomes 1280 ms, so the next attempt is at about
t0+4.550 s. At HZ=250, msecs_to_jiffies(10) rounds up to 12 ms, and the
last two attempts are at 3.524 s and 5.060 s.
If the outage ends anywhere between about 3.27 s and 4.295 s, the first
successful sample still comes more than 2^32 ns after cycle_last.
timecounter_read_delta() then masks the delta:
kernel/time/timecounter.c:timecounter_read_delta() {
...
cycle_delta = (cycle_now - tc->cycle_last) & tc->cc->mask;
...
}
As a result, tc->nsec moves forward about 0.255 s instead of about
4.55 s. The virtual clock silently steps back by about 4.295 s, and no
error is returned.
A fixed 2 s refresh would have retried at t0+4.0 s and kept the wrap.
The commit message says:
An isolated read failure
should not deliberately defer the next attempt until that sample is four
seconds old.
Here the backoff delays the next attempt until the sample is about
4.55 s old, after an outage of only about 1.3 to 2.3 s.
The later patches in this series do not change ptp_vclock_refresh(), so
this looks like it is still present at the end of the series.
Could the code record jiffies at the last successful sample and clamp
the returned delay? The next attempt would then land before
last_success + 2^32 ns, and preferably before the half-wrap point.
>
> + vclock->retry_delay = 0;
> return PTP_VCLOCK_REFRESH_INTERVAL;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261022-ptp-vclock-sampling-v5-0-06ceace17bac%40gmail.com
next prev parent reply other threads:[~2026-10-26 15:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 15:16 [PATCH net v5 0/5] ptp: make virtual clock sampling and teardown failure-safe James Hilliard
2026-10-22 15:16 ` [PATCH net v5 1/5] ptp: drain virtual clock sysfs operations before unregistering children James Hilliard
2026-10-22 15:16 ` [PATCH net v5 2/5] ptp: unwind partially completed virtual clock creation James Hilliard
2026-10-22 15:16 ` [PATCH net v5 3/5] ptp: vclock: propagate physical clock sampling errors James Hilliard
2026-10-26 15:53 ` netdev-bot+sashiko [this message]
2026-10-22 15:16 ` [PATCH net v5 4/5] ptp: vclock: serialize extended samples with counter updates James Hilliard
2026-10-22 15:16 ` [PATCH net v5 5/5] ptp: vclock: preserve missing hardware timestamps James Hilliard
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=179303002839.3134.5595255852218546734@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=yangbo.lu@nxp.com \
/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
all inboxes | Powered by JetHome®