From: Denis Plotnikov <dplotnikov@virtuozzo.com>
To: kvm@vger.kernel.org, rkrcmar@redhat.com
Cc: pbonzini@redhat.com, den@virtuozzo.com, rkagan@virtuozzo.com
Subject: [PATCH v2 05/11] timekeeping: change ktime_get_with_offset interface to accept cycles pointer
Date: Fri, 21 Jul 2017 18:45:12 +0300 [thread overview]
Message-ID: <1500651918-14156-6-git-send-email-dplotnikov@virtuozzo.com> (raw)
In-Reply-To: <1500651918-14156-1-git-send-email-dplotnikov@virtuozzo.com>
It's a part of preparation to using cycle stamp values when calculating
the kerenel time
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
---
include/linux/timekeeping.h | 8 ++++----
kernel/time/timekeeping.c | 31 +++++++++++++++++--------------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index ddc229f..fc6683b 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -171,7 +171,7 @@ enum tk_offsets {
};
extern ktime_t ktime_get(void);
-extern ktime_t ktime_get_with_offset(enum tk_offsets offs);
+extern ktime_t ktime_get_with_offset(enum tk_offsets offs, u64 *cycles_stamp);
extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs);
extern ktime_t ktime_get_raw(void);
extern u32 ktime_get_resolution_ns(void);
@@ -181,7 +181,7 @@ extern u32 ktime_get_resolution_ns(void);
*/
static inline ktime_t ktime_get_real(void)
{
- return ktime_get_with_offset(TK_OFFS_REAL);
+ return ktime_get_with_offset(TK_OFFS_REAL, NULL);
}
/**
@@ -192,7 +192,7 @@ static inline ktime_t ktime_get_real(void)
*/
static inline ktime_t ktime_get_boottime(void)
{
- return ktime_get_with_offset(TK_OFFS_BOOT);
+ return ktime_get_with_offset(TK_OFFS_BOOT, NULL);
}
/**
@@ -200,7 +200,7 @@ static inline ktime_t ktime_get_boottime(void)
*/
static inline ktime_t ktime_get_clocktai(void)
{
- return ktime_get_with_offset(TK_OFFS_TAI);
+ return ktime_get_with_offset(TK_OFFS_TAI, NULL);
}
/**
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 5d0c4d0..b6d7882 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -180,7 +180,8 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
}
}
-static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
+static inline u64 timekeeping_get_delta(struct tk_read_base *tkr,
+ u64 *cycles_stamp)
{
struct timekeeper *tk = &tk_core.timekeeper;
u64 now, last, mask, max, delta;
@@ -195,7 +196,7 @@ static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
*/
do {
seq = read_seqcount_begin(&tk_core.seq);
- now = tk_clock_read(tkr, NULL);
+ now = tk_clock_read(tkr, cycles_stamp);
last = tkr->cycle_last;
mask = tkr->mask;
max = tkr->clock->max_cycles;
@@ -224,12 +225,13 @@ static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset)
{
}
-static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
+static inline u64 timekeeping_get_delta(struct tk_read_base *tkr,
+ u64 *cycles_stamp)
{
u64 cycle_now, delta;
/* read clocksource */
- cycle_now = tk_clock_read(tkr, NULL);
+ cycle_now = tk_clock_read(tkr, cycles_stamp);
/* calculate the delta since the last update_wall_time */
delta = clocksource_delta(cycle_now, tkr->cycle_last, tkr->mask);
@@ -329,11 +331,12 @@ static inline u64 timekeeping_delta_to_ns(struct tk_read_base *tkr, u64 delta)
return nsec + arch_gettimeoffset();
}
-static inline u64 timekeeping_get_ns(struct tk_read_base *tkr)
+static inline u64 timekeeping_get_ns(struct tk_read_base *tkr,
+ u64 *cycles_stamp)
{
u64 delta;
- delta = timekeeping_get_delta(tkr);
+ delta = timekeeping_get_delta(tkr, cycles_stamp);
return timekeeping_delta_to_ns(tkr, delta);
}
@@ -707,7 +710,7 @@ int __getnstimeofday64(struct timespec64 *ts)
seq = read_seqcount_begin(&tk_core.seq);
ts->tv_sec = tk->xtime_sec;
- nsecs = timekeeping_get_ns(&tk->tkr_mono);
+ nsecs = timekeeping_get_ns(&tk->tkr_mono, NULL);
} while (read_seqcount_retry(&tk_core.seq, seq));
@@ -748,7 +751,7 @@ ktime_t ktime_get(void)
do {
seq = read_seqcount_begin(&tk_core.seq);
base = tk->tkr_mono.base;
- nsecs = timekeeping_get_ns(&tk->tkr_mono);
+ nsecs = timekeeping_get_ns(&tk->tkr_mono, NULL);
} while (read_seqcount_retry(&tk_core.seq, seq));
@@ -779,7 +782,7 @@ static ktime_t *offsets[TK_OFFS_MAX] = {
[TK_OFFS_TAI] = &tk_core.timekeeper.offs_tai,
};
-ktime_t ktime_get_with_offset(enum tk_offsets offs)
+ktime_t ktime_get_with_offset(enum tk_offsets offs, u64 *cycles_stamp)
{
struct timekeeper *tk = &tk_core.timekeeper;
unsigned int seq;
@@ -791,7 +794,7 @@ ktime_t ktime_get_with_offset(enum tk_offsets offs)
do {
seq = read_seqcount_begin(&tk_core.seq);
base = ktime_add(tk->tkr_mono.base, *offset);
- nsecs = timekeeping_get_ns(&tk->tkr_mono);
+ nsecs = timekeeping_get_ns(&tk->tkr_mono, cycles_stamp);
} while (read_seqcount_retry(&tk_core.seq, seq));
@@ -833,7 +836,7 @@ ktime_t ktime_get_raw(void)
do {
seq = read_seqcount_begin(&tk_core.seq);
base = tk->tkr_raw.base;
- nsecs = timekeeping_get_ns(&tk->tkr_raw);
+ nsecs = timekeeping_get_ns(&tk->tkr_raw, NULL);
} while (read_seqcount_retry(&tk_core.seq, seq));
@@ -861,7 +864,7 @@ void ktime_get_ts64(struct timespec64 *ts)
do {
seq = read_seqcount_begin(&tk_core.seq);
ts->tv_sec = tk->xtime_sec;
- nsec = timekeeping_get_ns(&tk->tkr_mono);
+ nsec = timekeeping_get_ns(&tk->tkr_mono, NULL);
tomono = tk->wall_to_monotonic;
} while (read_seqcount_retry(&tk_core.seq, seq));
@@ -1379,7 +1382,7 @@ void getrawmonotonic64(struct timespec64 *ts)
do {
seq = read_seqcount_begin(&tk_core.seq);
- nsecs = timekeeping_get_ns(&tk->tkr_raw);
+ nsecs = timekeeping_get_ns(&tk->tkr_raw, NULL);
ts64 = tk->raw_time;
} while (read_seqcount_retry(&tk_core.seq, seq));
@@ -2224,7 +2227,7 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real,
seq = read_seqcount_begin(&tk_core.seq);
base = tk->tkr_mono.base;
- nsecs = timekeeping_get_ns(&tk->tkr_mono);
+ nsecs = timekeeping_get_ns(&tk->tkr_mono, NULL);
base = ktime_add_ns(base, nsecs);
if (*cwsseq != tk->clock_was_set_seq) {
--
2.7.4
next prev parent reply other threads:[~2017-07-21 15:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-21 15:45 [PATCH v2 00/11] make L2's kvm-clock stable, get rid of pvclock_gtod Denis Plotnikov
2017-07-21 15:45 ` [PATCH v2 01/11] timekeeper: change interface of clocksource reding functions Denis Plotnikov
2017-07-23 4:24 ` kbuild test robot
2017-07-21 15:45 ` [PATCH v2 02/11] pvclock: write cycle stamp value if a pointer given Denis Plotnikov
2017-07-21 15:45 ` [PATCH v2 03/11] kvmclock: pass cycles pointer to the changed pvclock interface Denis Plotnikov
2017-07-21 15:45 ` [PATCH v2 04/11] TSC: write cycles stamp value to input pointer Denis Plotnikov
2017-07-21 15:45 ` Denis Plotnikov [this message]
2017-07-21 15:45 ` [PATCH v2 06/11] timekeeping: add functions returning cycle stamp counter along with time Denis Plotnikov
2017-07-21 15:45 ` [PATCH v2 07/11] timekeeper: add clocksource change notifier Denis Plotnikov
2017-07-21 15:45 ` [PATCH v2 08/11] timekeeper: add a couple of the core timekeeper reading helpers Denis Plotnikov
2017-07-23 4:02 ` kbuild test robot
2017-07-23 4:02 ` kbuild test robot
2017-07-21 15:45 ` [PATCH v2 09/11] KVM: get rid of pv_clock_gtod Denis Plotnikov
2017-07-25 10:37 ` Paolo Bonzini
2017-07-21 15:45 ` [PATCH v2 10/11] pvclock: add clocksource change notification on changing of tsc stable bit Denis Plotnikov
2017-07-21 15:45 ` [PATCH v2 11/11] KVM: add pvclock to a list of stable clocks Denis Plotnikov
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=1500651918-14156-6-git-send-email-dplotnikov@virtuozzo.com \
--to=dplotnikov@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkagan@virtuozzo.com \
--cc=rkrcmar@redhat.com \
/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