netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miroslav Lichvar <mlichvar@redhat.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: "Keller, Jacob E" <jacob.e.keller@intel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Richard Cochran <richardcochran@gmail.com>,
	Jiri Benc <jbenc@redhat.com>, Denny Page <dennypage@me.com>,
	Willem de Bruijn <willemb@google.com>
Subject: Re: Extending socket timestamping API for NTP
Date: Mon, 27 Feb 2017 16:23:39 +0100	[thread overview]
Message-ID: <20170227152339.GB12043@localhost> (raw)
In-Reply-To: <CAF=yD-JLiABx6TcVg_8mS5ZhomRaZ+cZ8edx00hJNG8PDrsSjg@mail.gmail.com>

On Tue, Feb 07, 2017 at 02:32:04PM -0800, Willem de Bruijn wrote:
> >> 4) allow sockets to use both SW and HW TX timestamping at the same time
> >>
> >>    When using a socket which is not bound to a specific interface, it
> >>    would be nice to get transmit SW timestamps when HW timestamps are
> >>    missing. I suspect it's difficult to predict if a HW timestamp will
> >>    be available. Maybe it would be acceptable to get from the error
> >>    queue two messages per transmission if the interface supports both
> >>    SW and HW timestamping?
> >
> >
> > This seems useful,
> 
> Agreed, as long as it is optional so that it does not change the
> behavior for existing applications.

Do you think it is safe to assume that no application enabled both SW
and HW TX timestamping? Do we need a new option for this?

> > but not sure how best to implement it.
> 
> It might be sufficient to just remove the second line in sw_tx_timestamp
> 
> static inline void sw_tx_timestamp(struct sk_buff *skb)
> {
>         if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP &&
>             !(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))
>                 skb_tstamp_tx(skb, NULL);
> }

With this change I'm getting two error messages per transmission, but
it looks like it may need some additional changes.

If the first error message is received after the HW timestamp was
captured, it contains both timestamps as the HW timestamp is in the
shared info of the skb. Is it possible it could contain a partially
updated HW timestamp? I'm not sure how locking works here. Is
scm_timestamping actually allowed to contain more than one timestamp?
The timestamping.txt document says "Only one field is non-zero at any
time.", but that wasn't true even before if both SW and HW RX
timestamping was enabled.

If SO_TIMESTAMP{,NS} is enabled, ts[0] in the second error message
will contain a bogus SW timestamp added by __sock_recv_timestamp() for
a "Race occurred between timestamp enabling and packet receiving". Is
there a guarantee applications will get a timestamp for all messages
after enabling SO_TIMESTAMP? The original code is older than the git
repo, so I'm not sure what was the reason for this. To me it would
make more sense to not add any SCM_TIMESTAMP (and SW timestamp in
SCM_TIMESTAMPING) when the the timestamp is missing. If that's not
always acceptable, maybe it could be restricted to sockets that have
HW timestamping enabled?

Some drivers don't call skb_tx_timestamp() when HW timestamp was
requested. From a cursory look it is e1000e, xgbe, sxgbe, and stmmac.
This should hopefully be an easy fix.

Thoughts?

-- 
Miroslav Lichvar

  parent reply	other threads:[~2017-02-27 15:24 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07 14:01 Extending socket timestamping API for NTP Miroslav Lichvar
2017-02-07 17:45 ` Keller, Jacob E
2017-02-07 22:32   ` Willem de Bruijn
2017-02-08 14:18     ` Soheil Hassas Yeganeh
2017-02-27 15:23     ` Miroslav Lichvar [this message]
2017-02-28  0:01       ` Willem de Bruijn
2017-02-28  8:26         ` Miroslav Lichvar
2017-02-28 21:05           ` Willem de Bruijn
2017-02-08  1:52   ` Denny Page
2017-02-08  5:27     ` Richard Cochran
2017-02-08  5:48       ` Denny Page
2017-02-08 17:27       ` Denny Page
2017-02-07 18:54 ` Soheil Hassas Yeganeh
2017-02-08 10:14   ` Miroslav Lichvar
2017-02-07 20:37 ` sdncurious
2017-02-08 10:26   ` Miroslav Lichvar
2017-02-08 23:27     ` sdncurious
2017-02-08 23:34     ` sdncurious
2017-02-08  1:18 ` Denny Page
     [not found] ` <CAHoNx58u=Fze4e5V2Wb_LiBhka1Mzny3zOVNfvuzjnmQ4wBO=Q@mail.gmail.com>
2017-02-08  3:06   ` Denny Page
2017-02-09  0:45 ` Denny Page
2017-02-09 11:15   ` Miroslav Lichvar
2017-02-09 20:25   ` Denny Page
2017-02-09  8:02 ` Richard Cochran
2017-02-09 11:09   ` Miroslav Lichvar
2017-02-09 19:42     ` sdncurious
2017-02-09 20:37       ` Denny Page
2017-02-10  0:33       ` Denny Page
2017-02-10 18:55         ` Denny Page
2017-03-23 16:21     ` Miroslav Lichvar
2017-03-23 18:54       ` Denny Page
2017-03-23 19:07       ` Richard Cochran
2017-03-24  7:25         ` Miroslav Lichvar
     [not found]       ` <6121D504-288F-4C9B-9AB3-D1C8292965D5@me.com>
2017-03-24  9:45         ` Miroslav Lichvar
2017-03-24 17:17           ` Denny Page
2017-03-24 18:52             ` Keller, Jacob E
2017-03-27 10:13             ` Miroslav Lichvar
2017-03-27 14:29               ` Richard Cochran
2017-03-27 16:25                 ` Denny Page
2017-03-27 18:28                   ` Richard Cochran
2017-03-27 19:18                     ` Denny Page
2017-03-27 20:58                       ` Richard Cochran
2017-03-27 21:20                         ` Denny Page
2017-03-27 19:21                     ` Denny Page
2017-03-27 19:21                     ` Denny Page
     [not found]                     ` <5FD283AB-39DE-4A9D-902A-BA5F0F0B62A3@me.com>
2017-03-27 21:00                       ` Richard Cochran
2017-03-24  9:55         ` Jiri Benc

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=20170227152339.GB12043@localhost \
    --to=mlichvar@redhat.com \
    --cc=dennypage@me.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jbenc@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=willemb@google.com \
    --cc=willemdebruijn.kernel@gmail.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).