mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH v7] timekeeping: Added a function to return tv_sec portion of ktime_get_ts64()
Date: Wed, 29 Oct 2014 10:40:00 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.11.1410291039010.5308@nanos> (raw)
In-Reply-To: <3371590.dCyFlG7rJg@wuerfel>

On Wed, 29 Oct 2014, Arnd Bergmann wrote:

> On Wednesday 29 October 2014 10:21:18 Thomas Gleixner wrote:
> > On Wed, 29 Oct 2014, Heena Sirwani wrote:
> > > +time64_t ktime_get_seconds(void)
> > > +{
> > > +     time64_t seconds;
> > > +     struct timekeeper *tk = &tk_core.timekeeper;
> > > +     unsigned int seq;
> > > +
> > > +     WARN_ON(timekeeping_suspended);
> > 
> > You want to have the same 64bit logic as you did for
> > ktime_get_real_seconds. So on 64bit it boils down to return
> > tk->ktime_sec.
> > 
> > > +
> > > +     do {
> > > +             seq = read_seqcount_begin(&tk_core.seq);
> > > +             seconds = tk->ktime_sec;
> > > +
> > > +     } while (read_seqcount_retry(&tk_core.seq, seq));
> > 
> 
> I wonder if we should just make tk->ktime_sec 'unsigned long' and
> avoid the lock for 32-bit as well. Are there any theoretical
> cases where the monotonic time could overflow a 32-bit integer?

136 years uptime :) I think we discussed that 32bit thing before, but
I forgot again.
 
> As a minor optimization 's64 nsec_offset' could also be 'long',
> since that only stores a number that is known to be less than
> 1000000000.

Indeed.

Thanks,

	tglx

      reply	other threads:[~2014-10-29  9:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29  9:13 Heena Sirwani
2014-10-29  9:21 ` Thomas Gleixner
2014-10-29  9:37   ` Arnd Bergmann
2014-10-29  9:40     ` Thomas Gleixner [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=alpine.DEB.2.11.1410291039010.5308@nanos \
    --to=tglx@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=heenasirwani@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®