mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: joelaf <joelaf@google.com>
Cc: linux-kernel@vger.kernel.org,
	John Stultz <john.stultz@linaro.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Subject: Re: [RFC] timekeeping: Use cached readouts for monotonic and raw clocks in suspend
Date: Mon, 21 Nov 2016 12:46:24 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1611210853290.3610@nanos> (raw)
In-Reply-To: <db8f4a99-7ba9-71fc-9b64-be615acc0759@google.com>

On Sun, 20 Nov 2016, joelaf wrote:
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index 37dec7e..41afa1e 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -55,6 +55,12 @@ static struct timekeeper shadow_timekeeper;
>   */
>  struct tk_fast {
>  	seqcount_t		seq;
> +
> +	/*
> +	 * first dimension is based on lower seq bit,
> +	 * second dimension is for offset type (real, boot, tai)
> +	 */
> +	ktime_t			offsets[2][3];

  s/3/TK_OFFSET_MAX/ ?

>  	struct tk_read_base	base[2];

The struct is cache line optimized which you wreckage. If at all we can put
the offsets at the end of the struct, but definitely not at the
beginning. clock monotonic is the case we optimize for.

>  /**
> @@ -392,16 +404,23 @@ static void update_fast_timekeeper(struct tk_read_base
> *tkr, struct tk_fast *tkf
>   * of the following timestamps. Callers need to be aware of that and
>   * deal with it.
>   */
> -static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf)
> +static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf, int
> offset)
>  {
>  	struct tk_read_base *tkr;
>  	unsigned int seq;
>  	u64 now;
> +	ktime_t *off;
> 
>  	do {
>  		seq = raw_read_seqcount_latch(&tkf->seq);
>  		tkr = tkf->base + (seq & 0x01);
> -		now = ktime_to_ns(tkr->base);
> +
> +		if (offset >= 0) {

This surely wants: unlikely() around the condition.

> +			off = tkf->offsets[seq & 0x01];
> +			now = ktime_to_ns(ktime_add(tkr->base, off[offset]));
> +		} else {
> +			now = ktime_to_ns(tkr->base);
> +		}

Thanks,

	tglx

      reply	other threads:[~2016-11-21 11:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-19 21:41 Joel Fernandes
2016-11-20 13:24 ` Thomas Gleixner
2016-11-21  3:09   ` joelaf
2016-11-21 11:46     ` 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.20.1611210853290.3610@nanos \
    --to=tglx@linutronix.de \
    --cc=joelaf@google.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.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®