linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Egmont Koblinger <egmont@gmail.com>
To: linux-serial@vger.kernel.org
Subject: PROBLEM: tty devices with future timestamps
Date: Sat, 27 Jun 2020 10:33:38 +0200	[thread overview]
Message-ID: <CAGWcZk+qZaNN1LOWxWjsBiP+JfSKDvD5+atNHe3LeWgWQhC=gw@mail.gmail.com> (raw)
In-Reply-To: <CAGWcZkJ5LMK59UWPP6zsV3ipgVNbk+mH7tVcmRGsp1PJzxBdTA@mail.gmail.com>

Hi,

An active terminal line (/dev/pts/N), in about 6% of the cases, has a
future timestamp.

I noticed that the command
  ls -l $(tty)
occasionally prints the timestamp in "month day year" format, rather
than "month day hour:minute". This is what coreutils's "ls" does when
the timestamp is either 6+ months back in the past, or is in the
future. Let's test the "in the future" hypothesis:

  ls -l --full-time $(tty); date +%H:%M:%S.%N
occasionally produces something like
  crw--w---- 1 egmont tty 136, 8 2020-06-27 09:57:28.686473296 +0200 /dev/pts/8
  09:57:28.170717548
Yep, the timestamp of the tty line is a slightly higher value than the
system date at a later point.

Running
  ls -l --full-time $(tty)
in an endless loop causes the seconds to increment in steps of 8, but
the subseconds part remains unchanged, like:
crw--w---- 1 egmont tty 136, 8 2020-06-27 10:07:12.686473296 +0200 /dev/pts/8
crw--w---- 1 egmont tty 136, 8 2020-06-27 10:07:12.686473296 +0200 /dev/pts/8
crw--w---- 1 egmont tty 136, 8 2020-06-27 10:07:20.686473296 +0200 /dev/pts/8
crw--w---- 1 egmont tty 136, 8 2020-06-27 10:07:20.686473296 +0200 /dev/pts/8

drivers/tty/tty_io.c : tty_update_time() seems to be responsible for
this jump in 8 seconds, leaving the milliseconds intact.

I think zeroing out the milliseconds in this method would solve the
problem – although then it's maybe inconsistent that at creation time
the device would have subsecond precision which would be gone soon
afterwards. Maybe it's better to create the device with no subseconds
right away? I'll leave it to you guys to decide.

I'm experiencing this on two different machines with Ubuntu 20.04,
using their 5.4.0 kernel. The method setting the seconds but not the
nanoseconds is still present in latest kernel git.

Thanks a lot,
egmont

       reply	other threads:[~2020-06-27  8:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGWcZkJ5LMK59UWPP6zsV3ipgVNbk+mH7tVcmRGsp1PJzxBdTA@mail.gmail.com>
2020-06-27  8:33 ` Egmont Koblinger [this message]
2020-07-01 13:23   ` PROBLEM: tty devices with future timestamps Greg KH
2020-07-02  7:16     ` Egmont Koblinger
2020-07-02  7:27       ` Greg KH
     [not found]         ` <CAGWcZkL0tFJO-A-UV1CugQ9Jpb=P1PJfn8r8d8qzeMcSF1+-1A@mail.gmail.com>
2020-07-02  7:56           ` Fwd: " Egmont Koblinger

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='CAGWcZk+qZaNN1LOWxWjsBiP+JfSKDvD5+atNHe3LeWgWQhC=gw@mail.gmail.com' \
    --to=egmont@gmail.com \
    --cc=linux-serial@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).