public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Heena Sirwani <heenasirwani@gmail.com>,
	linux-kernel@vger.kernel.org, john.stultz@linaro.org
Subject: Re: [PATCH v5] timekeeping: Added a function to return tv_sec portion of ktime_get_ts64()
Date: Sun, 26 Oct 2014 21:34:19 +0100	[thread overview]
Message-ID: <12673353.5lG2WgRb0V@wuerfel> (raw)
In-Reply-To: <alpine.DEB.2.11.1410251903000.5308@nanos>

On Saturday 25 October 2014 19:32:09 Thomas Gleixner wrote:
> From:	Thomas Gleixner <tglx@linutronix.de>
> To:	Arnd Bergmann <arnd@arndb.de>
> CC:	Heena Sirwani <heenasirwani@gmail.com>, linux-kernel@vger.kernel.org, john.stultz@linaro.org
> Date:	Yesterday 19:32:09
> On Sat, 25 Oct 2014, Arnd Bergmann wrote:
> > On Saturday 25 October 2014 17:22:23 Thomas Gleixner wrote:
> > > Hmm. Thinking more about it. That's actually overkill. For ktime_sec a
> > > 32bit value is plenty enough unless we care about systems with more
> > > than 136 years uptime. So if we calculate the seconds value of ktime,
> > > i.e. CLOCK_MONOTONIC, in the update function, we can read it on both
> > > 32 and 64bit w/o the seqcount loop.
> > 
> > Ah, very good point. That opens the question which type that function
> > should return. I really want to remove all uses of time_t from the
> > kernel, mostly so we know when we're done with this. However as you
> > say we know that we only need a 32-bit value here. Some possible
> > ideas:
> > 
> > - use time64_t here anyway and accept the slight inefficiency in return
> >   for clarity
> 
> Probably the simplest option.
> 
> > - introduce a monotonic_time_t (we probably also want a struct
> >   monotonic_timespec if we do that) which is basically the old time_t
> >   but is known to be y2038 safe because we only ever use it to store
> >   monotonic times.
> 
> Not sure whether its worth the trouble.

We have around 20 drivers using ktime_get_ts() or getrawmonotonic().
If we had a 'struct monotonic_timespec', we could trivially convert
them, otherwise we have to look at each one individually to figure
out what they should use, in particular if they would have noticeably
worse performance by moving to ktime_get_ts64 or getrawmonotonic64.

The way to do that would be to add 

#define monotonic_timespec timespec

now, and rename timespec to monotonic_timespec after we are done
converting all other in-kernel users of timespec. There are probably
a few drivers that today use do_gettimeofday or getnstimeofday that
could be converted to use ktime_get_ts using a 32-bit
monotonic_timespec.

The alternative to that would be to make them all use ktime_t, which
might be more efficient but also more work to do.

> > - return u32 and use the same type in the callers instead of
> >   time_t/time64_t/monotonic_time_t.
> 
> Works as well. I have no immediate preference.

I think I like the u32 approach better than ktime_t, but it's a
very mild preference. I'll wait for your reply on the monotonic_time_t/
monotonic_timespec comments above. Maybe John has an opinion as well.

Heena, could you prepare a new patch using u32 once we have worked out
the ktime_sec implementation?

	Arnd

  reply	other threads:[~2014-10-26 20:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-25 12:34 [PATCH v5] timekeeping: Added a function to return tv_sec portion of ktime_get_ts64() Heena Sirwani
2014-10-25 15:12 ` Thomas Gleixner
2014-10-25 15:22   ` Thomas Gleixner
2014-10-25 15:39     ` Arnd Bergmann
2014-10-25 17:32       ` Thomas Gleixner
2014-10-26 20:34         ` Arnd Bergmann [this message]
2014-10-28 11:26           ` Thomas Gleixner
2014-10-28 13:21             ` Arnd Bergmann
2014-10-26 21:01   ` Arnd Bergmann
2014-10-27 21:21     ` Thomas Gleixner

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=12673353.5lG2WgRb0V@wuerfel \
    --to=arnd@arndb.de \
    --cc=heenasirwani@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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