From: "Christopher S. Hall" <christopher.s.hall@intel.com> To: tglx@linutronix.de, richardcochran@gmail.com, mingo@redhat.com, john.stultz@linaro.org, hpa@zytor.com, jeffrey.t.kirsher@intel.com Cc: "Christopher S. Hall" <christopher.s.hall@intel.com>, x86@kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, kevin.b.stanton@intel.com Subject: [RFC v5 4/6] Remove duplicate code from ktime_get_raw_and_real code Date: Mon, 4 Jan 2016 04:45:21 -0800 [thread overview] Message-ID: <1451911523-8534-5-git-send-email-christopher.s.hall@intel.com> (raw) In-Reply-To: <1451911523-8534-1-git-send-email-christopher.s.hall@intel.com> The code in ktime_get_snapshot() is a superset of the code in ktime_get_raw_and_real() code. Changes the latter to call the former. A side effect of this is that ktime_get_raw_and_real() returns two clock times corresponding to the *exact* same clock tick. Previously, this code read the underlying counter twice. Signed-off-by: Christopher S. Hall <christopher.s.hall@intel.com> --- kernel/time/timekeeping.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 5a7f784..a0f096c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -910,26 +910,14 @@ EXPORT_SYMBOL_GPL(ktime_get_snapshot); */ void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, struct timespec64 *ts_real) { - struct timekeeper *tk = &tk_core.timekeeper; - unsigned long seq; - s64 nsecs_raw, nsecs_real; + struct system_time_snapshot snap; WARN_ON_ONCE(timekeeping_suspended); - do { - seq = read_seqcount_begin(&tk_core.seq); - - *ts_raw = tk->raw_time; - ts_real->tv_sec = tk->xtime_sec; - ts_real->tv_nsec = 0; - - nsecs_raw = timekeeping_get_ns(&tk->tkr_raw); - nsecs_real = timekeeping_get_ns(&tk->tkr_mono); - - } while (read_seqcount_retry(&tk_core.seq, seq)); + ktime_get_snapshot(&snap); - timespec64_add_ns(ts_raw, nsecs_raw); - timespec64_add_ns(ts_real, nsecs_real); + *ts_raw = ktime_to_timespec64(snap.raw); + *ts_real = ktime_to_timespec64(snap.real); } EXPORT_SYMBOL(ktime_get_raw_and_real_ts64); -- 2.1.4
WARNING: multiple messages have this Message-ID (diff)
From: Christopher S. Hall <christopher.s.hall@intel.com> To: intel-wired-lan@osuosl.org Subject: [Intel-wired-lan] [RFC v5 4/6] Remove duplicate code from ktime_get_raw_and_real code Date: Mon, 4 Jan 2016 04:45:21 -0800 [thread overview] Message-ID: <1451911523-8534-5-git-send-email-christopher.s.hall@intel.com> (raw) In-Reply-To: <1451911523-8534-1-git-send-email-christopher.s.hall@intel.com> The code in ktime_get_snapshot() is a superset of the code in ktime_get_raw_and_real() code. Changes the latter to call the former. A side effect of this is that ktime_get_raw_and_real() returns two clock times corresponding to the *exact* same clock tick. Previously, this code read the underlying counter twice. Signed-off-by: Christopher S. Hall <christopher.s.hall@intel.com> --- kernel/time/timekeeping.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 5a7f784..a0f096c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -910,26 +910,14 @@ EXPORT_SYMBOL_GPL(ktime_get_snapshot); */ void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, struct timespec64 *ts_real) { - struct timekeeper *tk = &tk_core.timekeeper; - unsigned long seq; - s64 nsecs_raw, nsecs_real; + struct system_time_snapshot snap; WARN_ON_ONCE(timekeeping_suspended); - do { - seq = read_seqcount_begin(&tk_core.seq); - - *ts_raw = tk->raw_time; - ts_real->tv_sec = tk->xtime_sec; - ts_real->tv_nsec = 0; - - nsecs_raw = timekeeping_get_ns(&tk->tkr_raw); - nsecs_real = timekeeping_get_ns(&tk->tkr_mono); - - } while (read_seqcount_retry(&tk_core.seq, seq)); + ktime_get_snapshot(&snap); - timespec64_add_ns(ts_raw, nsecs_raw); - timespec64_add_ns(ts_real, nsecs_real); + *ts_raw = ktime_to_timespec64(snap.raw); + *ts_real = ktime_to_timespec64(snap.real); } EXPORT_SYMBOL(ktime_get_raw_and_real_ts64); -- 2.1.4
next prev parent reply other threads:[~2016-01-04 19:52 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-04 12:45 [RFC v5 0/6] Patchset enabling hardware based cross-timestamps for next gen Intel platforms Christopher S. Hall 2016-01-04 12:45 ` [Intel-wired-lan] " Christopher S. Hall 2016-01-04 12:45 ` [RFC v5 1/6] Timekeeping cross timestamp interface for device drivers Christopher S. Hall 2016-01-04 12:45 ` [Intel-wired-lan] " Christopher S. Hall 2016-01-06 18:55 ` John Stultz 2016-01-06 18:55 ` [Intel-wired-lan] " John Stultz 2016-01-08 0:42 ` Christopher Hall 2016-01-08 0:42 ` [Intel-wired-lan] " Christopher Hall 2016-01-08 1:05 ` John Stultz 2016-01-08 1:05 ` [Intel-wired-lan] " John Stultz 2016-01-08 9:13 ` Richard Cochran 2016-01-08 9:13 ` [Intel-wired-lan] " Richard Cochran 2016-01-04 12:45 ` [RFC v5 2/6] Always Running Timer (ART) correlated clocksource Christopher S. Hall 2016-01-04 12:45 ` [Intel-wired-lan] " Christopher S. Hall 2016-01-04 12:45 ` [RFC v5 3/6] Add history to cross timestamp interface supporting slower devices Christopher S. Hall 2016-01-04 12:45 ` [Intel-wired-lan] " Christopher S. Hall 2016-01-06 19:37 ` John Stultz 2016-01-06 19:37 ` [Intel-wired-lan] " John Stultz 2016-01-08 1:07 ` Christopher Hall 2016-01-08 1:07 ` [Intel-wired-lan] " Christopher Hall 2016-01-08 1:12 ` John Stultz 2016-01-08 1:12 ` [Intel-wired-lan] " John Stultz 2016-01-08 14:04 ` Thomas Gleixner 2016-01-08 14:04 ` [Intel-wired-lan] " Thomas Gleixner 2016-01-08 22:28 ` Christopher Hall 2016-01-08 22:28 ` [Intel-wired-lan] " Christopher Hall 2016-01-04 12:45 ` Christopher S. Hall [this message] 2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 4/6] Remove duplicate code from ktime_get_raw_and_real code Christopher S. Hall 2016-01-06 19:42 ` John Stultz 2016-01-06 19:42 ` [Intel-wired-lan] " John Stultz 2016-01-04 12:45 ` [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping Christopher S. Hall 2016-01-04 12:45 ` [Intel-wired-lan] " Christopher S. Hall 2016-01-05 15:27 ` Richard Cochran 2016-01-05 15:27 ` [Intel-wired-lan] " Richard Cochran 2016-01-07 1:42 ` Christopher Hall 2016-01-07 1:42 ` [Intel-wired-lan] " Christopher Hall 2016-01-04 12:45 ` [RFC v5 6/6] Adds hardware supported cross timestamp Christopher S. Hall 2016-01-04 12:45 ` [Intel-wired-lan] " Christopher S. Hall
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=1451911523-8534-5-git-send-email-christopher.s.hall@intel.com \ --to=christopher.s.hall@intel.com \ --cc=hpa@zytor.com \ --cc=intel-wired-lan@lists.osuosl.org \ --cc=jeffrey.t.kirsher@intel.com \ --cc=john.stultz@linaro.org \ --cc=kevin.b.stanton@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=richardcochran@gmail.com \ --cc=tglx@linutronix.de \ --cc=x86@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.