Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1407836 > unrolled thread

[PATCH 2/3] pvclock: Cleanup to remove function pvclock_get_nsec_offset

Started byMinfei Huang <mnghuan@gmail.com>
First post2016-05-27 08:20 +0200
Last post2016-05-27 17:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/3] pvclock: Cleanup to remove function pvclock_get_nsec_offset Minfei Huang <mnghuan@gmail.com> - 2016-05-27 08:20 +0200
    Re: [PATCH 2/3] pvclock: Cleanup to remove function pvclock_get_nsec_offset Andy Lutomirski <luto@amacapital.net> - 2016-05-27 17:50 +0200

#1407836 — [PATCH 2/3] pvclock: Cleanup to remove function pvclock_get_nsec_offset

FromMinfei Huang <mnghuan@gmail.com>
Date2016-05-27 08:20 +0200
Subject[PATCH 2/3] pvclock: Cleanup to remove function pvclock_get_nsec_offset
Message-ID<rDjhL-8fO-7@gated-at.bofh.it>
Function __pvclock_read_cycles is short enough, so there is no need to
have another function pvclock_get_nsec_offset to calculate tsc delta.
It's better to combine it into function __pvclock_read_cycles.

Remove useless variables in function __pvclock_read_cycles.

Signed-off-by: Minfei Huang <mnghuan@gmail.com>
---
 arch/x86/include/asm/pvclock.h | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index 538ae94..7c1c895 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -69,31 +69,22 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
 }
 
 static __always_inline
-u64 pvclock_get_nsec_offset(const struct pvclock_vcpu_time_info *src)
-{
-	u64 delta = rdtsc_ordered() - src->tsc_timestamp;
-	return pvclock_scale_delta(delta, src->tsc_to_system_mul,
-				   src->tsc_shift);
-}
-
-static __always_inline
 unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
 			       cycle_t *cycles, u8 *flags)
 {
 	unsigned version;
-	cycle_t ret, offset;
-	u8 ret_flags;
+	cycle_t offset;
+	u64 delta;
 
 	version = src->version;
 	/* Make the latest version visible */
 	smp_rmb();
 
-	offset = pvclock_get_nsec_offset(src);
-	ret = src->system_time + offset;
-	ret_flags = src->flags;
-
-	*cycles = ret;
-	*flags = ret_flags;
+	delta = rdtsc_ordered() - src->tsc_timestamp;
+	offset = pvclock_scale_delta(delta, src->tsc_to_system_mul,
+				   src->tsc_shift);
+	*cycles = src->system_time + offset;
+	*flags = src->flags;
 	return version;
 }
 
-- 
2.6.3

[toc] | [next] | [standalone]


#1408151

FromAndy Lutomirski <luto@amacapital.net>
Date2016-05-27 17:50 +0200
Message-ID<rDsbo-5gf-19@gated-at.bofh.it>
In reply to#1407836
On Thu, May 26, 2016 at 11:17 PM, Minfei Huang <mnghuan@gmail.com> wrote:
> Function __pvclock_read_cycles is short enough, so there is no need to
> have another function pvclock_get_nsec_offset to calculate tsc delta.
> It's better to combine it into function __pvclock_read_cycles.
>
> Remove useless variables in function __pvclock_read_cycles.

LGTM.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web