netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastien Laveze <sebastien.laveze@oss.nxp.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	yangbo.lu@nxp.com, yannick.vignon@oss.nxp.com,
	rui.sousa@oss.nxp.com
Subject: Re: [PATCH net-next] ptp: add vclock timestamp conversion IOCTL
Date: Thu, 07 Oct 2021 15:31:43 +0200	[thread overview]
Message-ID: <fea51ae9423c07e674402047851dd712ff1733bb.camel@oss.nxp.com> (raw)
In-Reply-To: <20210930143527.GA14158@hoboy.vegasvil.org>

On Thu, 2021-09-30 at 07:35 -0700, Richard Cochran wrote:
> > What we miss currently in the kernel for a better multi-domain usage
> > and would like to find a solution:
> > -allow PHC adjustment with virtual clocks. Otherwise scheduled traffic
> > cannot be used... (I've read your comments on this topic, we are
> > experimenting things on MCUs and we need to assess on measurements)
> 
> Yeah, so you cannot have it both ways, I'm afraid.  Either you adjust
> the HW clock or not.  If you don't, it becomes impractical to program
> the event registers for output signals.  (Time stamps on input signals
> are not an issue, though)

Yes, this is especially true for periodic events completely handled in
hardware like scheduled traffic.

However, not being able to support multiple domains + scheduled traffic
is a true limitation for TSN use cases.

I'm aware of your opinon on this topic:
https://lore.kernel.org/netdev/20210510231832.GA28585@hoboy.vegasvil.org/

However, a few points that _might_ change your mind:
* regular and random small adjustments don't cost that much since the
error you create for the children clocks is only the time for the PHC
to adjust. Since this time is quite small (~10 us ? ), a few ppm on
this short time is negligible.

For example:
Let's take a worst case, the PHC is adjusted every 10 ms, vclock every
1 sec with 1 ppm error.
vclock error is 1 us, now if you add the 100 PHC adjustments each of
them with an error of 1 ppm over 10 us. That gives 0.01 ns * 100 = 1
ns.
This is negligible vs the 1 us error.
Of course, in general, the vclock would be updated more frequently but
in this case even less impacted by PHC adjustments.

* large frequency adjustments are more problematic. I've checked that
some drivers allow up to 10^6 ppm... 
This could lead to non-negligible error. However, since it's already
accepted that using vclock is at the cost of loosing adjustments on the
PHC, it could be accepted that it's still adjustable but with some
restrictions. (1000 ppm max ?)

* offset adjustments do not introduce any error if performed in
software. On other systems we support, handling the offset in software
helped to improve stability as the hardware time becomes monotonic.
There is no added value in setting the offset in the PHC.

> I think the best option for user space wanting timers in multiple
> domains is to periodically do 
> 
>    gettime(monotonic); gettime(vclock); gettime(monotonic);
> 
> figure the conversion, and schedule using clock_monotonic.

Yes, having a good ratio/offset measurement should lead to decent
performance.

Thanks,
Sebastien


  reply	other threads:[~2021-10-07 13:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27  9:32 [PATCH net-next] ptp: add vclock timestamp conversion IOCTL Sebastien Laveze
2021-09-27 14:59 ` Richard Cochran
2021-09-27 16:00   ` Sebastien Laveze
2021-09-27 20:23     ` Richard Cochran
2021-09-28 11:50       ` Sebastien Laveze
2021-09-28 13:31         ` Richard Cochran
2021-09-29 15:00           ` Sebastien Laveze
2021-09-30 14:35             ` Richard Cochran
2021-10-07 13:31               ` Sebastien Laveze [this message]
2021-10-07 20:19                 ` Richard Cochran
2021-10-08  7:13                   ` Sebastien Laveze
2021-10-09 18:24                     ` Richard Cochran
2021-10-09 18:25                       ` Richard Cochran
2021-10-11 12:58                     ` Richard Cochran
2021-10-12 16:14                       ` Richard Cochran
2021-10-13  9:56                       ` Sebastien Laveze
2021-10-13 13:10                         ` Richard Cochran
2021-10-13 13:28                           ` Sebastien Laveze
2021-10-13 17:54                             ` Richard Cochran
2021-10-14 13:27                               ` Sebastien Laveze
2021-09-27 18:28 ` Randy Dunlap

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=fea51ae9423c07e674402047851dd712ff1733bb.camel@oss.nxp.com \
    --to=sebastien.laveze@oss.nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=rui.sousa@oss.nxp.com \
    --cc=yangbo.lu@nxp.com \
    --cc=yannick.vignon@oss.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;
as well as URLs for NNTP newsgroup(s).