Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1160756
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Thomas Gleixner <tglx@linutronix.de> |
| Newsgroups | linux.kernel |
| Subject | Re: [RFC][PATCH 4/4] time: Do leapsecond adjustment in gettime fastpaths |
| Date | Mon, 08 Jun 2015 22:10:02 +0200 |
| Message-ID | <pzbwS-QJ-17@gated-at.bofh.it> (permalink) |
| References | <pvz4K-6jp-9@gated-at.bofh.it> <pvz4L-6jp-33@gated-at.bofh.it> <pwQmS-4Vb-3@gated-at.bofh.it> <pwWLF-5LX-23@gated-at.bofh.it> <pxcQq-4Km-31@gated-at.bofh.it> <pxkXF-8dJ-7@gated-at.bofh.it> <pxx8t-14y-7@gated-at.bofh.it> <pxNmV-8sC-7@gated-at.bofh.it> <pxUeJ-1Bl-1@gated-at.bofh.it> <pxVNx-3WW-25@gated-at.bofh.it> <pxVXd-48x-13@gated-at.bofh.it> <pyiTL-4BE-1@gated-at.bofh.it> <pz9v4-646-13@gated-at.bofh.it> <pzaAN-7UC-3@gated-at.bofh.it> |
| X-Original-To | John Stultz <john.stultz@linaro.org> |
| User-Agent | Alpine 2.11 (DEB 23 2013-08-11) |
| MIME-Version | 1.0 |
| Content-Type | TEXT/PLAIN; charset=US-ASCII |
| X-Linutronix-Spam-Score | -1.0 |
| X-Linutronix-Spam-Level | - |
| X-Linutronix-Spam-Status | No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 84 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Peter Zijlstra <peterz@infradead.org>, Richard Cochran <richardcochran@gmail.com>, Ingo Molnar <mingo@kernel.org>, lkml <linux-kernel@vger.kernel.org>, Prarit Bhargava <prarit@redhat.com>, Daniel Bristot de Oliveira <bristot@redhat.com>, Jan Kara <jack@suse.cz>, Jiri Bohac <jbohac@suse.cz>, Ingo Molnar <mingo@redhat.com>, Shuah Khan <shuahkh@osg.samsung.com> |
| X-Original-Date | Mon, 8 Jun 2015 22:02:18 +0200 (CEST) |
| X-Original-Message-ID | <alpine.DEB.2.11.1506082151410.4133@nanos> |
| X-Original-References | <1432931068-4980-1-git-send-email-john.stultz@linaro.org> <1432931068-4980-5-git-send-email-john.stultz@linaro.org> <20150602090154.GA2590@gmail.com> <CALAqxLW6z6EHH0iCB5wbZFm-1hAUW+MrTLRmqTQin81DsuneBA@mail.gmail.com> <20150603090452.GA9490@gmail.com> <CALAqxLVq+cQ4VS0rNYkGAt-d=+8yFr4Uy8D3-LbnjoZC_+niPA@mail.gmail.com> <20150604064809.GA14685@gmail.com> <CALAqxLUo75Y-2Rt4fEdwq=V1AOU5uGsE2VH=0cP_FiSUXW+OyQ@mail.gmail.com> <20150605072913.GD19282@twins.programming.kicks-ass.net> <20150605090433.GC1528@localhost.localdomain> <1433495408.1495.8.camel@twins> <alpine.DEB.2.11.1506052237581.11961@nanos> <CALAqxLXVqxf8L=OHVWmvv56auNtVk2GQWBNnHDRKvHtqjHA3hQ@mail.gmail.com> <alpine.DEB.2.11.1506082030090.4133@nanos> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1160756 |
Show key headers only | View raw
On Mon, 8 Jun 2015, Thomas Gleixner wrote:
> On Mon, 8 Jun 2015, John Stultz wrote:
> > Now, It could be possible to do a lighter weight version of my patch,
> > which just does the adjustment only for the hrtimer_interrupt code
> > (leaving the rest of the read paths alone).
>
> Yes, that should work. As long as I can keep the cached values in the
> hrtimer cpu bases and the whole thing keeps the clock_was_set_seq
> logic intact.
>
> If we do not do the conditional version, then on every hrtimer
> interrupt we write THREE cachelines for nothing.
>
> And if we cannot cache the offsets, then we end up calling into the
> timekeeping code for every timer which is not CLOCK_MONOTONIC based
> and retrieve the offset. That hurts especially on 32bit machines,
> because we need to protect the readout with the timekeeper sequence
> counter.
Below is a patch which just has the required data in the right place
and the changes to ktime_get_update_offsets_now().
It's simpler than your version as:
- there is no requirement to do the add in the first place as we
know the monotonic time at which the leap second happens.
- we can precalculate the leap adjusted offset and just replace
the non adjusted offset for the window.
When the whole thing is over you just need to increment the
clock_was_set_seq counter so the next timer interrupt will cache the
normal values again.
Thanks,
tglx
diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h
index e1f5a1136554..ecd193c23676 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -90,6 +90,9 @@ struct timekeeper {
ktime_t offs_tai;
s32 tai_offset;
unsigned int clock_was_set_seq;
+ ktime_t next_leap_ktime;
+ ktime_t offs_real_leap_adjusted;
+
struct timespec64 raw_time;
/* The following members are for timekeeping internal use */
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 90ed5db67c1d..0de85bf9e331 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1952,15 +1952,21 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real,
base = tk->tkr_mono.base;
nsecs = timekeeping_get_ns(&tk->tkr_mono);
+ base = ktime_add_ns(base, nsecs);
+
if (*cwsseq != tk->clock_was_set_seq) {
*cwsseq = tk->clock_was_set_seq;
*offs_real = tk->offs_real;
*offs_boot = tk->offs_boot;
*offs_tai = tk->offs_tai;
}
+
+ if (base.tv64 >= tk->next_leap_ktime.tv64)
+ *offs_real = tk->offs_real_leap_adjusted;
+
} while (read_seqcount_retry(&tk_core.seq, seq));
- return ktime_add_ns(base, nsecs);
+ return base;
}
/**
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [RFC][PATCH 4/4] time: Do leapsecond adjustment in gettime fastpaths Thomas Gleixner <tglx@linutronix.de> - 2015-06-08 21:10 +0200 Re: [RFC][PATCH 4/4] time: Do leapsecond adjustment in gettime fastpaths Thomas Gleixner <tglx@linutronix.de> - 2015-06-08 22:10 +0200
csiph-web