Netdev List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org,
	Stephen Hemminger <shemminger@linux-foundation.org>,
	netdev <netdev@vger.kernel.org>
Subject: Re: net_timedelta() affected by settimeofday() (was: [patch 12/13] net: mac80211: Remove silly timespec dance)
Date: Thu, 12 Jun 2014 10:57:57 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1406121047280.5170@nanos> (raw)
In-Reply-To: <1402562399.8095.5.camel@jlt4.sipsolutions.net>

On Thu, 12 Jun 2014, Johannes Berg wrote:

> On Thu, 2014-06-12 at 10:35 +0200, Johannes Berg wrote:
> > +netdev, Stephen
> 
> Well, stupid me. Fixing that netdev address.
> 
> > On Thu, 2014-06-12 at 10:19 +0200, Thomas Gleixner wrote:
> > > On Thu, 12 Jun 2014, Johannes Berg wrote:
> > > 
> > > > On Wed, 2014-06-11 at 23:59 +0000, Thomas Gleixner wrote:
> > > > 
> > > > > +	msrmnt = ktime_to_ms(net_timedelta(skb_arv));
> > > > 
> > > > This is probably more of a question about net_timedelta(), but is
> > > > ktime_get_real() really appropriate for duration measurements? Isn't
> > > > that non-monotonic?
> > > 
> > > Well, it's monotonic, but might be affected by settimeofday().
> > 
> > Right, but isn't that odd? Suddenly your delay measurement here might be
> > minutes, hours, or years if you settimeofday() between timestamping and
> > calculating the delta. That seems very strange to me, why would that be
> > the right behaviour in any way?

Indeed. clock monotonic is the appropriate one for measurements.
 
> > Now, it seems that there are only two current users of net_timedelta()
> > (in DCCP) so perhaps it's not too late to change some of this?
> > 
> > Maybe in general the skb timestamp should be based on a different clock
> > and only adjusted to real time when used in userspace?

You have the same problem then, just at a different place:

    ts = ktime_get();

			settimeofday()
			   offset_mono_to_real = new value;

    userts = mono_to_real(ts);

But maybe that's not a real issue, as ktime_get_real() can race with
settimeofday() or NTP as well.

   ts = ktime_get_real();
				settimeofday();
   userts = ts;

So the user might see a weird timestamp for a packet, which cannot be
correlated with the user space gettimeofday().

Thanks,

	tglx

  reply	other threads:[~2014-06-12  8:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140611234024.103571777@linutronix.de>
     [not found] ` <20140611234607.683770899@linutronix.de>
     [not found]   ` <1402555774.4224.1.camel@jlt4.sipsolutions.net>
     [not found]     ` <alpine.DEB.2.10.1406121017500.5170@nanos>
     [not found]       ` <1402562114.8095.3.camel@jlt4.sipsolutions.net>
2014-06-12  8:39         ` net_timedelta() affected by settimeofday() (was: [patch 12/13] net: mac80211: Remove silly timespec dance) Johannes Berg
2014-06-12  8:57           ` Thomas Gleixner [this message]
2014-06-12  9:21             ` Johannes Berg
     [not found]               ` <1402564914.8095.9.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
2014-06-12 14:09                 ` Thomas Gleixner
2014-06-13 17:58                   ` Johannes Berg

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=alpine.DEB.2.10.1406121047280.5170@nanos \
    --to=tglx@linutronix.de \
    --cc=johannes@sipsolutions.net \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=shemminger@linux-foundation.org \
    /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