linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Egmont Koblinger <egmont@gmail.com>
To: Greg KH <greg@kroah.com>, linux-serial@vger.kernel.org
Subject: Fwd: PROBLEM: tty devices with future timestamps
Date: Thu, 2 Jul 2020 09:56:58 +0200	[thread overview]
Message-ID: <CAGWcZkKVoQL7zMWqLr9T-d6JXUe4DeS5332feHotT-k9bxRjtQ@mail.gmail.com> (raw)
In-Reply-To: <CAGWcZkL0tFJO-A-UV1CugQ9Jpb=P1PJfn8r8d8qzeMcSF1+-1A@mail.gmail.com>

(Sorry, resending to include the list)

> As for setting it in the
> future, I don't think that's what is happening here,

Let's forget the "knock the lower bits off" part, it's irrelevant.
For the sake of simplicity, let's just pick a timestamp where those
bits are unset to begin with (i.e. a second divisible by 8).

If you set the seconds to the current seconds, but leave the
nanoseconds intact, whatever non-zero value it has, there's a good
chance that this results in a future timestamp (up to almost 1 second
into the future), as demonstrated in the example in my first mail.

In other words:  If you look at the entire, fine-grained timestamp,
you don't knock the lower bits off.  You update the higher bits, knock
the *middle* bits off, and leave the lower bits intact.

> you are just
> comparing two things that can't be compared as they are not the same
> thing.

Could you please elaborate?  (We're not understanding each other, and
I'm not sure in which direction :-))

My expectation is:  If the kernel maintains the concept of "current
time" which (apart from rare special circumstances like settimeofday()
-- we're not talking about those) always grows, and maintains the
"last access timestamp" of files, it shouldn't be possible that the
automatically updated "last access timestamp" is bigger than the
"current time".

Is this a wrong expectation?  Because if so, then I guess I should
follow up with coreutils devs to reconsider how they decide -- based
on comparing these two values: the file's "last access timestamp" and
the "current time" -- which formatting to pick.  If this is what you
referred to by "comparing two things that can't be compared" then what
they do is conceptually wrong.

> as it needs to be fast.

Zeroing out the nanoseconds -- maybe just once, at tty creation -- is
fast, and eliminates the possibility of future timestamps.

(s/milli/nano in my previous mails)


cheers,
egmont

      parent reply	other threads:[~2020-07-02  7:57 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 ` PROBLEM: tty devices with future timestamps Egmont Koblinger
2020-07-01 13:23   ` 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           ` Egmont Koblinger [this message]

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=CAGWcZkKVoQL7zMWqLr9T-d6JXUe4DeS5332feHotT-k9bxRjtQ@mail.gmail.com \
    --to=egmont@gmail.com \
    --cc=greg@kroah.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).